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

org.tools4j.groovytables.Suitability.groovy Maven / Gradle / Ivy

Go to download

A groovy API which allows you to create lists of objects using a table like grammar.

There is a newer version: 1.6
Show newest version
package org.tools4j.groovytables

/**
 * User: ben
 * Date: 12/02/2016
 * Time: 6:27 AM
 */
public enum Suitability {
    NOT_SUITABLE(0),
    SUITABLE_WITH_COERCION(1),
    SUITABLE_WITH_EXPECTED_COERCION(2),
    SUITABLE_BY_UP_CASTING(3),
    SUITABLE(4);

    private final int ranking;

    private Suitability(final int ranking) {
        this.ranking = ranking
    }

    public static Suitability leastSuitableOf(final Suitability arg1, final Suitability arg2){
        if(arg1.ranking <= arg2.ranking){
            return arg1;
        } else {
            return arg2;
        }
    }

    public Suitability worseOf(final Suitability other){
        return leastSuitableOf(this, other);
    }

    public boolean isMoreSuitableThan(final Suitability other) {
        return this.ranking > other.ranking
    }

    public boolean isLessSuitableThan(final Suitability other) {
        return this.ranking < other.ranking
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy