Created
August 15, 2011 01:52
-
-
Save magmax/1145589 to your computer and use it in GitHub Desktop.
Enumerados con relación doble en Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum NaveInterestelar { | |
PATRULLERA(-1), | |
ESCOLTA(0), | |
RESERVA(1000), | |
; | |
private int value; | |
private static final Map<Integer,NaveInterestelar> lookup | |
= new HashMap<Integer,NaveInterestelar>(); | |
static { | |
for (NaveInterestelar each : EnumSet.allOf(NaveInterestelar.class)) { | |
lookup.put(each.value, each); | |
} | |
} | |
NaveInterestelar(int value) { | |
this.value = value; | |
} | |
public static NaveInterestelar get(int v) { | |
return lookup.get(v); | |
} | |
public int getCode() { | |
return value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment