aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/resources/parameters/Parameter.java
blob: 3990ae65f26e0997caba2372f184db4f7c58dc76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package jcgp.backend.resources.parameters;

import javafx.beans.property.Property;
import javafx.beans.property.ReadOnlyProperty;

public abstract class Parameter<T> {
	
	protected boolean monitor, critical, reset = false;
	
	protected ParameterStatus status = ParameterStatus.VALID;
	
	protected String name;
	
	protected Property<T> valueProperty;
	
	public Parameter(String name, boolean monitor, boolean critical) {
		this.name = name;
		this.monitor = monitor;
		this.critical = critical;
	}
	
	public boolean isMonitor() {
		return monitor;
	}
	
	public boolean isCritical() {
		return critical;
	}
	
	public boolean requiresReset() {
		return critical || reset;
	}
	
	public String getName() {
		return name;
	}
	
	public ParameterStatus getStatus() {
		return status;
	}
	
	public ReadOnlyProperty<T> valueProperty() {
		return valueProperty;
	}
	
	public T get() {
		return valueProperty.getValue();
	}
	
	public void set(T newValue) {
		if (!valueProperty.isBound()) {
			valueProperty.setValue(newValue);
		}
	}
	
	public abstract void validate(T newValue);
}