*/
public abstract class AbstractController<V extends Comparable<V>> implements Controller<V> {
+ /** The name of this controller. */
+ private final String name;
+
/** The minimum value of this controller. */
private final V minimum;
/**
* Creates a new abstract controller.
*
+ * @param name
+ * The name of the controller
* @param minimum
* The minimum value of the controller
* @param maximum
* {@code true} if this controller has a “center” position, {@code false}
* otherwise
* @param currentValue
- * The current value of this controller
*/
- public AbstractController(V minimum, V maximum, boolean centered, V currentValue) {
+ public AbstractController(String name, V minimum, V maximum, boolean centered, V currentValue) {
+ this.name = name;
this.minimum = minimum;
this.maximum = maximum;
this.centered = centered;
//
@Override
+ public String name() {
+ return name;
+ }
+
+ @Override
public V minimum() {
return minimum;
}
* Adjusts the controller. This method is called from {@link
* #value(Comparable)} if the new value is different from the current value.
* Also, the value is clamped to fit within the range of this controller.
+ * <p/>
+ * This implementation does nothing.
*
* @param value
* The new value
*/
- protected abstract void valueSet(V value);
+ protected void valueSet(V value) {
+ /* do nothing. */
+ }
}