Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@Type #40

Open
mcasasola opened this issue Aug 12, 2011 · 12 comments
Open

@Type #40

mcasasola opened this issue Aug 12, 2011 · 12 comments

Comments

@mcasasola
Copy link

Could implement @type, same as hibernate. Class to convert cursor result to object.

@jonatasdaniel
Copy link
Owner

A Custom formatter specified to an attr solve the problem?

@mcasasola
Copy link
Author

thats the idea.

@jonatasdaniel
Copy link
Owner

If you look at the sources, we have a class DateFormatter, implementing the interface Formatter. Then create a property called 'formatter' would receive a class that extends Formatter.

@mcasasola
Copy link
Author

Don't figureted, i see Formatter property but where use it?

@jonatasdaniel
Copy link
Owner

Maybe in Property class.
I'll prepare an example next week.

@mcasasola
Copy link
Author

ok, maybe annotated attr and automagically apply formatter, transparently. Without touch property.

@jonatasdaniel
Copy link
Owner

I think something like this:

MyProperty {

public void set(Object in, Object value) {
value = myCustomFormatter.parse(value);
invoke(in, setMethod).withParams(value);
}

public Object get(Object of) {
object value = invoke(of, getMethod).withoutParams();
return myCustomFormatter.format(value);
}

}

@mcasasola
Copy link
Author

But properties are create by framework, how you make relation of entities that requiere formatter and property create in manager initialization?

@jonatasdaniel
Copy link
Owner

The format would be an attribute of the property, and if the entity attribute is not annotated with @column, a standard format and defined

@mcasasola
Copy link
Author

With a attr in @column you defined a formatter implementation?

@jonatasdaniel
Copy link
Owner

Something like this:

@column(formatter=MyCustomFormatter.class)
private Integer myAttr;

@mcasasola
Copy link
Author

ok, i like that way. great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants