Preference.java

package com.tradecloud.domain.configuration.clearing.za;

public enum Preference {

    NONE("None", "100"),
    PREFERENTIAL_RATE("Preferential rate", "200"),
    NATIONAL_QUOTA("National Quota", "300"),
    PREFERENTIAL_QUOTA("Preferential Quota ", "400");

    private final String value;
    private final String sarsCode;

    Preference(String v, String sarsCode) {
        value = v;
        this.sarsCode = sarsCode;
    }

    public String value() {
        return value;
    }

    public static Preference fromValue(String v) {
        for (Preference c : Preference.values()) {
            if (c.value.equals(v)) {
                return c;
            }
        }
        throw new IllegalArgumentException(v);
    }

    public String getSarsCode() {
        return sarsCode;
    }

    public String getLabel() {
        return sarsCode + " - " + value;
    }
}