package oracle.toplink.example.conversion; /** * An example tri-state custom type wrapping a Boolean. Pre-defined static * instances are provided to eliminate duplicate values. */ public class Answer { // Singleton instances provided to eliminate multiple copies public static Answer TRUE = new Answer(Boolean.TRUE); public static Answer FALSE = new Answer(Boolean.FALSE); public static Answer UNKNOWN = new Answer(null); // Values provided in one place for MyConversionManager to use public static String TRUE_VALUE = "Y"; public static String FALSE_VALUE = "N"; private Boolean value; private Answer(Boolean value) {} public Boolean getValue() { return this.value; } public boolean isUnknown() { return getValue() == null; } public boolean isTrue() { return getValue() == Boolean.TRUE; } public boolean isFalse() { return getValue() == Boolean.FALSE; } public String toString() { String strVal = "UNKNOWN"; if (isTrue()) { strVal = "TRUE"; } if (isFalse()) { strVal = "FALSE"; } return "Answer(" + strVal + ")"; } }