Use focused Lombok annotations and preserve generated API documentation

This commit is contained in:
2026-11-14 07:32:08 +01:00
parent 922ede8608
commit 5eb7d635d3
31 changed files with 233 additions and 890 deletions
@@ -3,6 +3,7 @@ package de.neitzel.fx.view;
import de.neitzel.injection.ApplicationContext;
import javafx.beans.DefaultProperty;
import javafx.scene.Parent;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@@ -20,6 +21,7 @@ public class BindingList {
/**
* The binding elements, in document order.
*/
@Getter
private final List<Object> elements = new ArrayList<>();
/**
@@ -29,18 +31,6 @@ public class BindingList {
LoadSession.register(this);
}
/**
* Returns the binding elements in this list.
* <p>
* FXML appends child elements to the returned list. A child is a {@link DirectBinding}, a
* {@link ComputedBinding}, or a {@link Repeat}.
*
* @return the mutable list of binding elements
*/
public List<Object> getElements() {
return elements;
}
/**
* Applies every binding element in this list.
*
@@ -6,6 +6,8 @@ import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
/**
* Carries one child ViewModel's current notices onto its parent.
@@ -15,6 +17,7 @@ import java.util.Set;
* source is the Attribute name, a dot, and the child source. A further parent carries that copy
* the same way, so the source grows into a Path. The copy is not logged again.
*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
final class ChildMessageMirror implements MessageListener {
/**
@@ -37,19 +40,6 @@ final class ChildMessageMirror implements MessageListener {
*/
private final Map<Message, Message> copies = new IdentityHashMap<>();
/**
* Creates a mirror. {@link #attach} registers it and copies notices already present.
*
* @param parent the parent ViewModel
* @param attribute the Attribute that leads to the child
* @param child the child ViewModel
*/
private ChildMessageMirror(ViewModel parent, String attribute, ViewModel child) {
this.parent = parent;
this.attribute = attribute;
this.child = child;
}
/**
* Starts carrying {@code child} onto {@code parent} under {@code attribute}.
* <p>
@@ -1,5 +1,8 @@
package de.neitzel.fx.view;
import lombok.Getter;
import lombok.Setter;
/**
* One Column of a {@link Table}.
* <p>
@@ -11,11 +14,15 @@ public class Column {
/**
* The header text.
*/
@Getter
@Setter
private String header;
/**
* The Attribute of the row element.
*/
@Getter
@Setter
private String attribute;
/**
@@ -23,42 +30,6 @@ public class Column {
*/
private Double width;
/**
* Sets the header text.
*
* @param header the header text
*/
public void setHeader(String header) {
this.header = header;
}
/**
* Returns the header text.
*
* @return the header text
*/
public String getHeader() {
return header;
}
/**
* Sets the Attribute name.
*
* @param attribute the Attribute of the row element
*/
public void setAttribute(String attribute) {
this.attribute = attribute;
}
/**
* Returns the Attribute name.
*
* @return the Attribute of the row element
*/
public String getAttribute() {
return attribute;
}
/**
* Sets the starting width.
* <p>
@@ -1,22 +1,23 @@
package de.neitzel.fx.view;
import de.neitzel.injection.ApplicationContext;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.util.AbstractMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javafx.beans.property.Property;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.util.Builder;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.AbstractMap;
import java.util.LinkedHashMap;
import java.util.Set;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.net.URL;
import java.util.List;
import java.util.Map;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
/**
* Loads a Component from {@code ClassName.fxml} in the Component's package.
@@ -70,6 +71,7 @@ final class Components {
* Collects instance properties while FXML constructs an injected Component.
* Properties are applied after its own document and model listener are ready.
*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
private static final class ComponentBuilder extends AbstractMap<String, Object> implements Builder<Object> {
/** The injected instance. */
private final Object component;
@@ -78,16 +80,6 @@ final class Components {
/** Values already resolved by the containing FXMLLoader. */
private final Map<String, Object> values = new LinkedHashMap<>();
/**
* Creates a builder for an injected instance.
* @param component the instance
* @param context its dependency context
*/
private ComponentBuilder(Object component, ApplicationContext context) {
this.component = component;
this.context = context;
}
/**
* Records a property for application after Component initialization.
* @param key the property name
@@ -1,5 +1,8 @@
package de.neitzel.fx.view;
import lombok.Getter;
import lombok.Setter;
/**
* A Computed binding declared in FXML.
* <p>
@@ -8,6 +11,8 @@ package de.neitzel.fx.view;
* {@code #workingAge}. The method may read the Controller's fields. Its result is written to
* the control property. The method does not write the Model.
*/
@Getter
@Setter
public class ComputedBinding {
/**
@@ -25,57 +30,4 @@ public class ComputedBinding {
*/
private String method;
/**
* Sets the {@code fx:id} of the control.
*
* @param control the control id
*/
public void setControl(String control) {
this.control = control;
}
/**
* Sets the control property name, such as {@code text}.
*
* @param property the property name
*/
public void setProperty(String property) {
this.property = property;
}
/**
* Sets the Controller method. A {@code #method} value names a no-argument method.
*
* @param method the method value, such as {@code #workingAge}
*/
public void setMethod(String method) {
this.method = method;
}
/**
* Returns the {@code fx:id} of the control.
*
* @return the control id
*/
public String getControl() {
return control;
}
/**
* Returns the control property name.
*
* @return the property name
*/
public String getProperty() {
return property;
}
/**
* Returns the Controller method value.
*
* @return the method value, such as {@code #workingAge}
*/
public String getMethod() {
return method;
}
}
@@ -1,5 +1,8 @@
package de.neitzel.fx.view;
import lombok.Getter;
import lombok.Setter;
/**
* A Direct binding declared in FXML.
* <p>
@@ -10,6 +13,8 @@ package de.neitzel.fx.view;
* Model instance behind the ViewModel. Direction values are {@code view}, {@code model}, and
* {@code both}. The Converter value is the class name. The container creates that class.
*/
@Getter
@Setter
public class DirectBinding {
/**
@@ -37,93 +42,4 @@ public class DirectBinding {
*/
private String converter;
/**
* Sets the {@code fx:id} of the control.
*
* @param control the control id
*/
public void setControl(String control) {
this.control = control;
}
/**
* Sets the control property name, such as {@code text}.
*
* @param property the property name
*/
public void setProperty(String property) {
this.property = property;
}
/**
* Sets the Path. One name is an Attribute of this View's ViewModel.
*
* @param path the path
*/
public void setPath(String path) {
this.path = path;
}
/**
* Sets the direction. Accepted values are {@code view}, {@code model}, and {@code both}.
*
* @param direction the direction value
*/
public void setDirection(String direction) {
this.direction = direction;
}
/**
* Sets the Converter class name. The container creates that class.
*
* @param converter the converter class name, or {@code null} when values pass through
*/
public void setConverter(String converter) {
this.converter = converter;
}
/**
* Returns the {@code fx:id} of the control.
*
* @return the control id
*/
public String getControl() {
return control;
}
/**
* Returns the control property name.
*
* @return the property name
*/
public String getProperty() {
return property;
}
/**
* Returns the Path.
*
* @return the path
*/
public String getPath() {
return path;
}
/**
* Returns the direction value.
*
* @return {@code view}, {@code model}, or {@code both}
*/
public String getDirection() {
return direction;
}
/**
* Returns the Converter class name.
*
* @return the class name, or {@code null} when values pass through
*/
public String getConverter() {
return converter;
}
}
@@ -1,13 +1,14 @@
package de.neitzel.fx.view;
import de.neitzel.injection.ApplicationContext;
import javafx.beans.property.Property;
import javafx.collections.ObservableList;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Map;
import javafx.beans.property.Property;
import javafx.collections.ObservableList;
import lombok.AccessLevel;
import lombok.RequiredArgsConstructor;
/**
* Connects one Direct binding to a control property and a ViewModel Attribute.
@@ -93,6 +94,7 @@ final class DirectBindingApplier {
* {@code name} is the last segment. A conversion failure is recorded on {@code owner} with that
* name as the source, so a parent only carries the extended copy.
*/
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
private static final class Resolved {
/**
@@ -115,20 +117,6 @@ final class DirectBindingApplier {
*/
private final String name;
/**
* Records one resolved Path.
*
* @param attribute the Attribute
* @param complex whether the Attribute is complex
* @param owner the ViewModel that owns it
* @param name the last segment
*/
private Resolved(Property<?> attribute, boolean complex, ViewModel owner, String name) {
this.attribute = attribute;
this.complex = complex;
this.owner = owner;
this.name = name;
}
}
/**
@@ -2,15 +2,20 @@ package de.neitzel.fx.view;
import javafx.beans.property.Property;
import javafx.scene.Parent;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
/**
* The scene-graph root and ViewModel produced by loading a View for a Model instance.
*/
@RequiredArgsConstructor(access = AccessLevel.PACKAGE)
public final class LoadedView {
/**
* The scene-graph root of the loaded View.
*/
@Getter
private final Parent root;
/**
@@ -18,27 +23,6 @@ public final class LoadedView {
*/
private final Object viewModel;
/**
* Creates the result of one load.
*
* @param root the scene-graph root
* @param viewModel the ViewModel built for the Model instance, or a replacement that exposes
* JavaFX properties by name
*/
LoadedView(Parent root, Object viewModel) {
this.root = root;
this.viewModel = viewModel;
}
/**
* Returns the scene-graph root.
*
* @return the root
*/
public Parent getRoot() {
return root;
}
/**
* Returns the ViewModel the View is bound to.
* <p>
@@ -1,5 +1,7 @@
package de.neitzel.fx.view;
import lombok.Getter;
/**
* A notice on a ViewModel with a severity, a text, and a source.
*/
@@ -22,16 +24,19 @@ public final class Message {
/**
* How serious the notice is.
*/
@Getter
private final Severity severity;
/**
* The notice text. A binding failure updates this in place.
*/
@Getter
private String text;
/**
* Where the notice came from, such as a binding Path.
*/
@Getter
private final String source;
/**
@@ -52,33 +57,6 @@ public final class Message {
this.source = source;
}
/**
* Returns how serious the notice is.
*
* @return the severity
*/
public Severity getSeverity() {
return severity;
}
/**
* Returns the notice text.
*
* @return the text
*/
public String getText() {
return text;
}
/**
* Returns where the notice came from.
*
* @return the source
*/
public String getSource() {
return source;
}
/**
* Replaces the text of a binding failure that is already in the list.
*
@@ -1,5 +1,8 @@
package de.neitzel.fx.view;
import lombok.Getter;
import lombok.Setter;
/**
* A repeat element declared in a {@link BindingList}.
* <p>
@@ -7,6 +10,8 @@ package de.neitzel.fx.view;
* Attribute. The library keeps one Component child in that pane for each Model instance, in
* list order.
*/
@Getter
@Setter
public class Repeat {
/**
@@ -24,57 +29,4 @@ public class Repeat {
*/
private String collection;
/**
* Sets the {@code fx:id} of the pane that holds the Component children.
*
* @param pane the pane id
*/
public void setPane(String pane) {
this.pane = pane;
}
/**
* Sets the Component class name. Each element gets a new instance of that class.
*
* @param component the class name
*/
public void setComponent(String component) {
this.component = component;
}
/**
* Sets the collection Attribute name. The list holds the Model instances.
*
* @param collection the attribute name
*/
public void setCollection(String collection) {
this.collection = collection;
}
/**
* Returns the {@code fx:id} of the pane.
*
* @return the pane id
*/
public String getPane() {
return pane;
}
/**
* Returns the Component class name.
*
* @return the class name
*/
public String getComponent() {
return component;
}
/**
* Returns the collection Attribute name.
*
* @return the attribute name
*/
public String getCollection() {
return collection;
}
}
+23 -46
View File
@@ -1,6 +1,24 @@
package de.neitzel.fx.view;
import de.neitzel.injection.ApplicationContext;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Comparator;
import java.util.Date;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import javafx.beans.DefaultProperty;
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.Property;
@@ -23,25 +41,8 @@ import javafx.scene.layout.Priority;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
import javafx.scene.text.Text;
import java.beans.PropertyDescriptor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeParseException;
import java.time.temporal.TemporalAccessor;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.Comparator;
import java.util.HashSet;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import lombok.Getter;
import lombok.Setter;
/**
* A collection shown with one Component for each element.
@@ -98,6 +99,8 @@ public class Table extends VBox {
/**
* The collection Attribute.
*/
@Getter
@Setter
private String collection;
/**
@@ -108,6 +111,7 @@ public class Table extends VBox {
/**
* The Columns, in declared order.
*/
@Getter
private final ObservableList<Column> columns = FXCollections.observableArrayList();
/**
@@ -258,24 +262,6 @@ public class Table extends VBox {
buildSortCommands();
}
/**
* Sets the collection Attribute.
*
* @param collection the collection Attribute
*/
public void setCollection(String collection) {
this.collection = collection;
}
/**
* Returns the collection Attribute.
*
* @return the collection Attribute
*/
public String getCollection() {
return collection;
}
/**
* Sets the Row class name.
*
@@ -294,15 +280,6 @@ public class Table extends VBox {
return rowClass;
}
/**
* Returns the Columns in declared order.
*
* @return the Columns
*/
public ObservableList<Column> getColumns() {
return columns;
}
/**
* Returns the selection property.
* <p>
@@ -1,25 +1,5 @@
package de.neitzel.fx.view;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
@@ -42,6 +22,24 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Consumer;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.FloatProperty;
import javafx.beans.property.IntegerProperty;
import javafx.beans.property.LongProperty;
import javafx.beans.property.Property;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleFloatProperty;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleLongProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.beans.property.StringProperty;
import javafx.beans.value.ChangeListener;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import lombok.extern.slf4j.Slf4j;
/**
* The object a View binds to, built at runtime for one Model instance.
@@ -75,13 +73,9 @@ import java.util.function.Consumer;
* status bar unless the developer asks. {@link MessagePopup#showNewMessages} shows each newly added
* Message in a dialog. An in-place update does not.
*/
@Slf4j
public class ViewModel {
/**
* Receives error and fatal notices. Info and warn are not logged.
*/
private static final Logger LOGGER = LoggerFactory.getLogger(ViewModel.class);
/**
* The Model instance this ViewModel was built for.
*/
@@ -770,7 +764,7 @@ public class ViewModel {
private static void logSevere(Message message) {
Message.Severity severity = message.getSeverity();
if (severity == Message.Severity.ERROR || severity == Message.Severity.FATAL) {
LOGGER.error(message.getText());
log.error(message.getText());
}
}