Open mcasasola opened 13 years ago
A Custom formatter specified to an attr solve the problem?
thats the idea.
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.
Don't figureted, i see Formatter property but where use it?
Maybe in Property class. I'll prepare an example next week.
ok, maybe annotated attr and automagically apply formatter, transparently. Without touch property.
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); }
}
But properties are create by framework, how you make relation of entities that requiere formatter and property create in manager initialization?
The format would be an attribute of the property, and if the entity attribute is not annotated with @Column, a standard format and defined
With a attr in @Column you defined a formatter implementation?
Something like this:
@Column(formatter=MyCustomFormatter.class) private Integer myAttr;
ok, i like that way. great.
Could implement @Type, same as hibernate. Class to convert cursor result to object.