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