勉强能用的依赖加载系统做好了

This commit is contained in:
Izzel_Aliz
2018-04-04 20:00:39 +08:00
parent 946adbb3eb
commit add76a30cb
24 changed files with 665 additions and 57 deletions

View File

@@ -1,17 +0,0 @@
package com.ilummc.tlib.bean;
import java.util.function.BiConsumer;
public class BooleanProperty {
private boolean property;
public BooleanProperty(boolean property) {
this.property = property;
}
public void addListener(BiConsumer<Boolean, Boolean> consumer) {
}
}

View File

@@ -1,4 +1,41 @@
package com.ilummc.tlib.bean;
public class Property {
import java.util.ArrayList;
import java.util.List;
import java.util.function.BiConsumer;
public class Property<T> {
private Property(T value) {
this.value = value;
}
private List<BiConsumer<T, T>> consumers;
private T value;
public void set(T value) {
if (value != this.value) {
if (consumers != null)
for (BiConsumer<T, T> consumer : consumers) {
consumer.accept(this.value, value);
}
this.value = value;
}
}
public T get() {
return value;
}
public void addListener(BiConsumer<T, T> consumer) {
if (consumers == null)
consumers = new ArrayList<>();
consumers.add(consumer);
}
public static <T> Property<T> of(T value) {
return new Property<>(value);
}
}