Skip to content

Saar25/JProperty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JProperty

Java utility library that provides observable values, bindings with lazy evaluation and more. like JavaFX but simplified

Using JProperty with maven

<dependency>
    <groupId>com.github.saar25</groupId>
    <artifactId>JProperty</artifactId>
    <version>1.1.5</version>
</dependency>

Examples

Wrapping java primitives and objects.

final IntProperty intProperty = new SimpleIntProperty(8);
final FloatProperty floatProperty = new SimpleFloatProperty(1.7f);
final ObjectProperty<Object> objectProperty = new SimpleObjectProperty<>(new Object());

final ReadOnlyIntProperty readOnlyIntProperty = new SimpleIntProperty();
final ReadOnlyFloatProperty readOnlyFloatProperty = new SimpleFloatProperty();

Listening to value changes

intProperty.addListener(e -> {
    System.out.println("Changed" +
            " from " + e.getOldValue() +
            " to " + intProperty.get());
});
intProperty.set(5); // Prints output
intProperty.set(5); // Does not print output
intProperty.set(1); // Prints output

Building up expressions

final IntProperty aProperty = new SimpleIntProperty(8);
final IntProperty bProperty = new SimpleIntProperty(3);

final IntBinding expression = Bindings.add(aProperty, bProperty);

System.out.println(a.get()) // Prints 11

About

Java library to create properties

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published