Use focused Lombok annotations and preserve generated API documentation
This commit is contained in:
+16
-1
@@ -39,7 +39,22 @@ Paths below are relative to this module. Java sources share `src/main/java/de/ne
|
||||
| `src/test/resources/de/neitzel/fx/example/NameLine.fxml` | Test-only second View of the same Person without reusable Component nodes |
|
||||
| `view/AgeConverter`, `StreetConverter`, `VisitedOnConverter` | Text adaptation, validation failures and ISO dates |
|
||||
|
||||
Use the actual source directories to locate helper services such as `AgeSuffix`, `StreetPolicy` and `FormHeading`. The injection guide explains constructor, field and setter injection with these types. No code generation is required to run this example; `PersonViewModel` is handwritten.
|
||||
Use the actual source directories to locate helper services such as `AgeSuffix`, `StreetPolicy` and `FormHeading`. The injection guide explains constructor, field and setter injection with these types. No Designer code generation is required to run this example; `PersonViewModel` is handwritten.
|
||||
|
||||
## Lombok and annotation processing
|
||||
|
||||
`Person`, `Address` and `Note` use `@Getter`/`@Setter` to generate ordinary JavaBean
|
||||
accessors. Their defaults, mutable lists and object identity are unchanged; no
|
||||
`@Data` equality or string representation is generated. JavaFX property methods
|
||||
remain explicit. `AgeConverter` and `VisitRow` use
|
||||
`@RequiredArgsConstructor(onConstructor_ = @Inject)` so the generated public
|
||||
constructors retain the injection annotation.
|
||||
|
||||
Lombok is inherited from the parent as a compile-time-only dependency. The
|
||||
optional `designer-preview` profile explicitly lists **both** Lombok and the
|
||||
Designer Model metadata processor. Keep both when changing that profile:
|
||||
metadata discovery must see the generated accessors during compilation. The
|
||||
normal build needs no Designer processor; Lombok still runs.
|
||||
|
||||
## Try the behaviors
|
||||
|
||||
|
||||
+5
-8
@@ -36,14 +36,6 @@
|
||||
<build>
|
||||
<finalName>${jar.filename}</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<!-- This module has no Lombok types. Skip the processor so a newer JDK can compile it. -->
|
||||
<proc>none</proc>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-maven-plugin</artifactId>
|
||||
@@ -132,6 +124,11 @@
|
||||
<configuration>
|
||||
<proc>full</proc>
|
||||
<annotationProcessorPaths combine.self="override">
|
||||
<path>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</path>
|
||||
<path>
|
||||
<groupId>de.neitzel.fxdesigner</groupId>
|
||||
<artifactId>designer-model-processor</artifactId>
|
||||
|
||||
@@ -1,10 +1,14 @@
|
||||
package de.neitzel.fx.example.model;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* An ordinary address the desk edits.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class Address {
|
||||
|
||||
/**
|
||||
@@ -44,78 +48,6 @@ public class Address {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the street.
|
||||
*
|
||||
* @return the street
|
||||
*/
|
||||
public String getStreet() {
|
||||
return street;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the street.
|
||||
*
|
||||
* @param street the street
|
||||
*/
|
||||
public void setStreet(String street) {
|
||||
this.street = street;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the city.
|
||||
*
|
||||
* @return the city
|
||||
*/
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the city.
|
||||
*
|
||||
* @param city the city
|
||||
*/
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the day of the visit.
|
||||
*
|
||||
* @return the date, or {@code null} when none is set
|
||||
*/
|
||||
public LocalDate getVisitedOn() {
|
||||
return visitedOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the day of the visit.
|
||||
*
|
||||
* @param visitedOn the date, or {@code null} to clear it
|
||||
*/
|
||||
public void setVisitedOn(LocalDate visitedOn) {
|
||||
this.visitedOn = visitedOn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the note attached to this address.
|
||||
*
|
||||
* @return the note, or {@code null} when none is set
|
||||
*/
|
||||
public Note getNote() {
|
||||
return note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the note attached to this address.
|
||||
*
|
||||
* @param note the note, or {@code null} when there is none
|
||||
*/
|
||||
public void setNote(Note note) {
|
||||
this.note = note;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the street and city, for a combo box row.
|
||||
*
|
||||
|
||||
@@ -1,11 +1,16 @@
|
||||
package de.neitzel.fx.example.model;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* A short note attached to an address.
|
||||
* <p>
|
||||
* The class is a complex attribute of {@link Address}: it has a read-write property of its own.
|
||||
* The home address form nests a component that edits this note.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class Note {
|
||||
|
||||
/**
|
||||
@@ -28,21 +33,4 @@ public class Note {
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the note text.
|
||||
*
|
||||
* @return the text
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the note text.
|
||||
*
|
||||
* @param text the text
|
||||
*/
|
||||
public void setText(String text) {
|
||||
this.text = text;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,12 +2,16 @@ package de.neitzel.fx.example.model;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* An ordinary person the desk edits.
|
||||
* <p>
|
||||
* Read-write attributes are what the View binds to. The class carries no JavaFX types.
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class Person {
|
||||
|
||||
/**
|
||||
@@ -56,151 +60,4 @@ public class Person {
|
||||
public Person() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name.
|
||||
*
|
||||
* @return the name
|
||||
*/
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the name.
|
||||
*
|
||||
* @param name the name
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the age in years.
|
||||
*
|
||||
* @return the age, or {@code null} when none is set
|
||||
*/
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the age in years.
|
||||
*
|
||||
* @param age the age
|
||||
*/
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the home address.
|
||||
*
|
||||
* @return the home address, or {@code null} when none is set
|
||||
*/
|
||||
public Address getHome() {
|
||||
return home;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the home address.
|
||||
*
|
||||
* @param home the home address
|
||||
*/
|
||||
public void setHome(Address home) {
|
||||
this.home = home;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visits.
|
||||
* <p>
|
||||
* After the View has loaded, this is the list the View is watching.
|
||||
*
|
||||
* @return the visits
|
||||
*/
|
||||
public List<Address> getVisits() {
|
||||
return visits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visits.
|
||||
*
|
||||
* @param visits the visits
|
||||
*/
|
||||
public void setVisits(List<Address> visits) {
|
||||
this.visits = visits;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the visit chosen in the table and the combo box.
|
||||
*
|
||||
* @return the selected visit, or {@code null} when none is selected
|
||||
*/
|
||||
public Address getSelectedVisit() {
|
||||
return selectedVisit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the visit chosen in the table and the combo box.
|
||||
*
|
||||
* @param selectedVisit the selected visit
|
||||
*/
|
||||
public void setSelectedVisit(Address selectedVisit) {
|
||||
this.selectedVisit = selectedVisit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tags.
|
||||
* <p>
|
||||
* After the View has loaded, this is the list the View is watching.
|
||||
*
|
||||
* @return the tags
|
||||
*/
|
||||
public List<String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the tags.
|
||||
*
|
||||
* @param tags the tags
|
||||
*/
|
||||
public void setTags(List<String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether the person is active.
|
||||
*
|
||||
* @return {@code true} when the person is active
|
||||
*/
|
||||
public boolean isActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets whether the person is active.
|
||||
*
|
||||
* @param active {@code true} when the person is active
|
||||
*/
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the role.
|
||||
*
|
||||
* @return the role, or {@code null} when none is set
|
||||
*/
|
||||
public Role getRole() {
|
||||
return role;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the role.
|
||||
*
|
||||
* @param role the role
|
||||
*/
|
||||
public void setRole(Role role) {
|
||||
this.role = role;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,11 +3,13 @@ package de.neitzel.fx.example.view;
|
||||
import de.neitzel.fx.view.Converter;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.inject.Singleton;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Translates an age between the Model and the text field.
|
||||
*/
|
||||
@Singleton
|
||||
@RequiredArgsConstructor(onConstructor_ = @Inject)
|
||||
public class AgeConverter implements Converter {
|
||||
|
||||
/**
|
||||
@@ -15,16 +17,6 @@ public class AgeConverter implements Converter {
|
||||
*/
|
||||
private final AgeSuffix suffix;
|
||||
|
||||
/**
|
||||
* Creates a converter that reads its suffix from the injected service.
|
||||
*
|
||||
* @param suffix the suffix written in front of the age
|
||||
*/
|
||||
@Inject
|
||||
public AgeConverter(AgeSuffix suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes the suffix in front of the age.
|
||||
*
|
||||
|
||||
@@ -7,6 +7,7 @@ import javafx.beans.property.ObjectProperty;
|
||||
import javafx.beans.property.SimpleObjectProperty;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.scene.layout.HBox;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
/**
|
||||
* Row that edits one visit in the visit table.
|
||||
@@ -16,6 +17,7 @@ import javafx.scene.layout.HBox;
|
||||
* order: street, city, then the visit date. Remove sits after them and is not a column.
|
||||
*/
|
||||
@Singleton
|
||||
@RequiredArgsConstructor(onConstructor_ = @Inject)
|
||||
public class VisitRow extends HBox {
|
||||
|
||||
/**
|
||||
@@ -28,16 +30,6 @@ public class VisitRow extends HBox {
|
||||
*/
|
||||
private final ObjectProperty<Object> model = new SimpleObjectProperty<>(this, "model");
|
||||
|
||||
/**
|
||||
* Creates a row that can remove its visit.
|
||||
*
|
||||
* @param desk the desk controller
|
||||
*/
|
||||
@Inject
|
||||
public VisitRow(DeskController desk) {
|
||||
this.desk = desk;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the model property the table sets.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user