All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.nls.util.ReadableComparable Maven / Gradle / Ivy

There is a newer version: 1.0.14
Show newest version
package com.nls.util;

public class ReadableComparable> implements Comparable> {
    private final T comparable;

    public ReadableComparable(T comparable) {
        this.comparable = comparable;
    }

    public T get() {
        return comparable;
    }

    public boolean isEqual(T other) {
        return comparable.compareTo(other) == 0;
    }

    public boolean isLessThan(T other) {
        return comparable.compareTo(other) < 0;
    }

    public boolean isLessThanOrEqual(T other) {
        return comparable.compareTo(other) <= 0;
    }

    public boolean isBefore(T other) {
        return isLessThan(other);
    }

    public boolean isGreaterThan(T other) {
        return comparable.compareTo(other) > 0;
    }

    public boolean isGreaterThanOrEqual(T other) {
        return comparable.compareTo(other) >= 0;
    }

    public boolean isAfter(T other) {
        return isGreaterThan(other);
    }

    public boolean isEqual(ReadableComparable other) {
        return compareTo(other) == 0;
    }

    public boolean isLessThan(ReadableComparable other) {
        return compareTo(other) < 0;
    }

    public boolean isLessThanOrEqual(ReadableComparable other) {
        return compareTo(other) <= 0;
    }

    public boolean isBefore(ReadableComparable other) {
        return isLessThan(other);
    }

    public boolean isGreaterThan(ReadableComparable other) {
        return compareTo(other) > 0;
    }

    public boolean isGreaterThanOrEqual(ReadableComparable other) {
        return compareTo(other) >= 0;
    }

    public boolean isAfter(ReadableComparable other) {
        return isGreaterThan(other);
    }

    @Override
    public int compareTo(ReadableComparable o) {
        return comparable.compareTo(o.comparable);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy