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

import javafx.beans.property.SimpleIntegerProperty;

public abstract class IntegerParameter extends Parameter {
	
	private SimpleIntegerProperty value;
	
	public IntegerParameter(int value, String name, boolean monitor, boolean critical) {
		super(name, monitor, critical);
		this.value = new SimpleIntegerProperty(value);
	}
	
	public IntegerParameter(int value, String name) {
		super(name, false, false);
		this.value = new SimpleIntegerProperty(value);
	}

	public int get() {
		return value.get();
	}
	
	public void set(int newValue) {
		if (!value.isBound()) {
			validate(newValue);
			value.set(newValue);
		}
	}
	
	@Override
	public SimpleIntegerProperty valueProperty() {
		return value;
	}
	
	public abstract void validate(int newValue);
	
}