aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/resources/parameters/BooleanParameter.java
blob: cd1764925fa6bf0af1c95aab79a8e20d7f043bfe (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
package jcgp.backend.resources.parameters;

import javafx.beans.property.SimpleBooleanProperty;

public abstract class BooleanParameter extends Parameter {
	
	private SimpleBooleanProperty value;
	
	public BooleanParameter(boolean value, String name, boolean monitor, boolean critical) {
		super(name, monitor, critical);
		this.value = new SimpleBooleanProperty(value);
	}
	
	/**
	 * Simple BooleanParameter constructor, 
	 * 
	 * 
	 * @param value
	 * @param name
	 */
	public BooleanParameter(boolean value, String name) {
		super(name, false, false);
		this.value = new SimpleBooleanProperty(value);
	}
	
	public boolean get() {
		return value.get();
	}
	
	public void set(boolean newValue) {
		if (!value.isBound()) {
			value.set(newValue);
		}
	}
	
	public abstract void validate(boolean newValue);
	
	@Override
	public SimpleBooleanProperty valueProperty() {
		return value;
	}
}