Implementation of an UniqueIdentifier class I have a requirement to implement a generic UniqueIdentifier which can cover identifiers like OrderId, TrackingID, scannableId and other Ids. The ids, as they are now, are either Long or String.
Below is my implementation of the UniqueIdentifier class --

public class UniqueIdentifier {
    String stringValue;
    Long longValue;
    boolean isLong;
    boolean isString;

    public UniqueIdentifier(String value) {
        setStringValue(value);
        try 
        {
            setLongValue(Long.parseLong(value));
        }
        catch(NumberFormatException nex) 
        {
            setLong(false);
        }
    }
    public UniqueIdentifier(Long value) {
        setLongValue(value);
        setStringValue(Long.toString(value));
    }
    public String getStringValue() {
        return stringValue;
    }
    private void setStringValue(String stringValue) {
        this.stringValue = stringValue;
    }
    public Long getLongValue() {
        return longValue;
    }
    private void setLongValue(Long longValue) {
        this.longValue = longValue;
    }
    public boolean isLong() {
        return isLong;
    }
    private void setLong(boolean isLong) {
        this.isLong = isLong;
    }
    public boolean isString() {
        return isString;
    }
    private void setString(boolean isString) {
        this.isString = isString;
    }       
}


Is there anything that i can do better here
I think this one screams for usage of generics.

ie. 

public class UniqueIdentifier&lt;T&gt; {
    T theValue;
    public UniqueIdentifier( T t ) {
        theValue = t;
    }
    public T getValue() {
        return theValue;
    }
}


Can even be extened with a nice factory method.