1 16 17 package org.springframework.core.enums; 18 19 45 public abstract class StaticLabeledEnum extends AbstractLabeledEnum { 46 47 50 private final Short code; 51 52 55 private final transient String label; 56 57 58 63 protected StaticLabeledEnum(int code, String label) { 64 this.code = new Short ((short) code); 65 if (label != null) { 66 this.label = label; 67 } 68 else { 69 this.label = this.code.toString(); 70 } 71 } 72 73 public Comparable getCode() { 74 return code; 75 } 76 77 public String getLabel() { 78 return label; 79 } 80 81 84 public short shortValue() { 85 return ((Number ) getCode()).shortValue(); 86 } 87 88 89 93 96 protected Object readResolve() { 97 return StaticLabeledEnumResolver.instance().getLabeledEnumByCode(getType(), getCode()); 98 } 99 100 } 101 | Popular Tags |