public boolean contains()

in core/src/main/java/org/apache/commons/functor/range/CharacterRange.java [131:159]


    public boolean contains(Character obj) {
        if (obj == null) {
            return Boolean.FALSE;
        }
        char leftValue = this.getLeftEndpoint().getValue().charValue();
        char rightValue = this.getRightEndpoint().getValue().charValue();
        boolean includeLeft = this.getLeftEndpoint().getBoundType() == BoundType.CLOSED;
        boolean includeRight = this.getRightEndpoint().getBoundType() == BoundType.CLOSED;
        int step = this.getStep().intValue();
        int value = (int) obj.charValue();

        int firstValue = 0;
        int lastValue = 0;

        if (step < 0.0) {
            firstValue = includeLeft ? leftValue : leftValue + step;
            lastValue = includeRight ? rightValue : rightValue + 1;
            if (value > firstValue || value < lastValue) {
                return Boolean.FALSE;
            }
        } else {
            firstValue = includeLeft ? leftValue : leftValue + step;
            lastValue = includeRight ? rightValue : rightValue - 1;
            if (value < firstValue || value > lastValue) {
                return Boolean.FALSE;
            }
        }
        return ((double) (value - firstValue) / step + 1) % 1.0 == 0.0;
    }