1 3 package jodd.typeconverter; 4 5 import jodd.mutable.MutableShort; 6 7 8 12 public class MutableShortConverter implements TypeConverter { 13 14 15 public static MutableShort valueOf(Object value) { 16 17 if (value == null) { 18 return null; 19 } 20 if (value instanceof MutableShort) { 21 return (MutableShort) value; 22 } 23 if (value instanceof Number ) { 24 return new MutableShort(((Number )value).byteValue()); 25 } 26 try { 27 return new MutableShort(value.toString()); 28 } catch (NumberFormatException nfex) { 29 throw new TypeConversionException(nfex); 30 } 31 } 32 33 public Object convert(Object value) { 34 return valueOf(value); 35 } 36 37 } 38 | Popular Tags |