/*
 * Copyright 2016 MovingBlocks
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.terasology.config.flexible.validators;

/**
 * Validates a {@link Number} within the specified range.
 * @param <T> The type of the {@link Number} to validate.
 */
public class RangedNumberValidator<T extends Number & Comparable<? super T>> implements SettingValueValidator<T> {
    private boolean inclusive;
    private T low;
    private T high;

    public RangedNumberValidator(T low, T high) {
        this(low, high, false);
    }

    public RangedNumberValidator(T low, T high, boolean inclusive) {
        this.low = low;
        this.high = high;
        this.inclusive = inclusive;
    }

    public boolean isInclusive() {
        return inclusive;
    }

    public void setInclusive(boolean inclusive) {
        this.inclusive = inclusive;
    }

    public T getLow() {
        return low;
    }

    public void setLow(T low) {
        this.low = low;
    }

    public T getHigh() {
        return high;
    }

    public void setHigh(T high) {
        this.high = high;
    }

    public void removeLowBound() {
        low = null;
    }

    public void removeHighBound() {
        high = null;
    }

    public void removeAllBounds() {
        removeHighBound();
        removeLowBound();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean validate(T value) {
        int lowComp = low != null ? low.compareTo(value) : -1;
        int highComp = high != null ? high.compareTo(value) : 1;

        boolean isValid = lowComp < 0 && highComp > 0;

        if(inclusive)
            isValid = isValid || lowComp == 0 || highComp == 0;

        return isValid;
    }
}

@@ -1286,545 +1286,99 @@
 lic 
-void setInclusive(boolean inclusive) %7B%0A        this.inclusive = inclusive;%0A    %7D%0A%0A    public T getLow() %7B%0A        return low;%0A    %7D%0A%0A    public void setLow(T low) %7B%0A        this.low = low;%0A    %7D%0A%0A    public T getHigh() %7B%0A        return high;%0A    %7D%0A%0A    public void setHigh(T high) %7B%0A        this.high = high;%0A    %7D%0A%0A    public void removeLowBound() %7B%0A        low = null;%0A    %7D%0A%0A    public void removeHighBound() %7B%0A        high = null;%0A    %7D%0A%0A    public void removeAllBounds() %7B%0A        removeHighBound();%0A        removeLowBound();%0A    %7D%0A
+T getLow() %7B%0A        return low;%0A    %7D%0A%0A    public T getHigh() %7B%0A        return high;%0A    %7D
 %0A   

Make RangedNumberValidator immutable