Closed jcteague closed 10 years ago
So Model citizen only support the JavaBean way of setting properties right now, it depends on the getter and setter having the same type so it can reflect them when it builds the model. Can you share snippets of the Model Citizen blueprint and the class with the property that is giving you grief?
I had a feeling that was the case. It fairly simple, with the exception that the paramters are different. I think the original author thought it would make is easier since the values come from a Rest interface. // class Long percent_complete; public void setPercent_complete(String percent_complete) { this.percent_complete = Double.valueOf(percent_complete); }
//blueprint @Default public FieldCallback percent_complete = new FieldCallback() { @Override public Object get(Object referenceModel) { return Long.getLong("55.5"); } };
Tried it with the FieldCallback and without.
What about an AfterCreateCallback, example at the bottom of the Car blueprint.
After the model is created, check if the percent_complete
is null and set a default value.
I'll try that. I solved it by setting the value before on the object then passing it to the model factory
Ideally Model Citizen would support a more customization way to reflect the methods mapped in the Blueprints. For right now, using a callback is your best bet.
The AfterCallback worked as well and is a better solution as I have several fields with this same format.
Thanks
I've got a field that is of type long, but the setter method takes a string value for input. m-c throws an error on this field:
Property 'percent_complete' has no setter method in class
I tried adding a FieldCallback for this field, but error still persists. Is there another way to fake this?