In my current spring project, I am looking for a way to assign some value for the attributes of some of the my POJO classes.
This feature is similar to the use of the annotations PathVariable
and ModelAttribute
for some parameters in the methods of a controller: when a parameter is annotated with one of this annotations, the own system read the value for this parameter and assign to the variable, without need use <variable> = <value>
.
In my project, I have some POJO class like this:
class Class {
private <type> <attribute>
public <type> get<attribute>() {
return <attribute>;
}
public void set<attribute>(<type> <parameter>) {
<attribute> = <parameter>;
}
}
if add an annotation to the attribute (for instance: @Setting), when I create a new instance of this class, the system should read a value in a file and assign to the variable.
Anyone can tell me how to do this?