Content deleted Content added
Amomchilov (talk | contribs) m Remove links to pages that direct to this page |
added ref to lombok |
||
Line 40:
The definition of the POJO can be as follows:
<syntaxhighlight lang="java">public class MyBean {
public class MyBean {▼
private String someProperty;
Line 52 ⟶ 51:
this.someProperty = someProperty;
}
}</syntaxhighlight>▼
▲</syntaxhighlight>
Because of the JavaBean naming conventions the single "someProperty" reference can be automatically translated to the "getSomeProperty()" (or "isSomeProperty()" if the property is of [[Boolean type]]) method for getting a value, and to the "setSomeProperty(String)" method for setting a value.
The [https://projectlombok.org/ lombok] library allows to change the code dynamically to integrate those conventions without the hassle to write them. The following code would generate the same bean, with the addition of an empty constructor :<syntaxhighlight lang="java">@NoArgsConstructor
▲public class MyBean {
@Getter @Setter
private String someProperty;
}</syntaxhighlight>Other libraries or framework generate code (or bytecode) with those conventions directly. The addition of those tools help alleviate the [[Boilerplate code|boilerplate]], which in turn reduces the bugs frequency and maintenance cost .
===Transparently adding services===
|