- Timestamp:
- 09/23/13 18:54:07 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/params/PrimitiveParam.java
r105 r107 3 3 import com.framsticks.util.FramsticksException; 4 4 import com.framsticks.util.Misc; 5 import com.framsticks.util.lang.Casting;6 5 import com.framsticks.util.lang.Numbers; 7 6 import com.framsticks.util.lang.Strings; … … 51 50 return type.cast(value); 52 51 } 53 // if (Number.class.isAssignableFrom(type)) {54 52 return Numbers.parse((String) value, type); 55 // }56 // return null;53 } if ((value instanceof Integer) && (type.equals(Double.class))) { 54 return type.cast(new Double((Integer) value)); 57 55 } else { 58 56 return type.cast(value); 59 57 } 60 58 } catch (ClassCastException e) { 61 throw new FramsticksException().msg("failed to cast").cause(e).arg("param", this).arg("actual", value.getClass()).arg("requested", type) ;59 throw new FramsticksException().msg("failed to cast").cause(e).arg("param", this).arg("actual", value.getClass()).arg("requested", type).arg("value", value); 62 60 } 63 61 } … … 99 97 } 100 98 101 @Override102 99 public <T> String serialize(T value) { 103 100 return Strings.toStringNullProof(value); 104 101 } 105 102 106 @Override107 public <T> T deserialize(String text, T currentValue, Class<T> type) {108 try {109 return Casting.nullOrThrowCast(type, reassign(text, currentValue).getValue());110 } catch (CastFailure e) {111 return null;112 }113 }114 103 }
Note: See TracChangeset
for help on using the changeset viewer.