- Timestamp:
- 09/10/13 21:11:41 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/params/PropertiesAccess.java
r101 r105 1 1 package com.framsticks.params; 2 3 import java.util.HashMap;4 import java.util.Map;5 2 6 3 import com.framsticks.params.types.EventParam; 7 4 import com.framsticks.params.types.ProcedureParam; 8 9 5 10 6 /** … … 18 14 public class PropertiesAccess extends SimpleAbstractAccess { 19 15 20 p ublic Map<String, Object>properties;16 protected PropertiesObject properties; 21 17 22 18 @Override 23 public Map<String, Object> createAccessee() { 24 return PropertiesAccess.createPropertiesMap(); 25 } 26 27 public static Map<String, Object> createPropertiesMap() { 28 return new HashMap<String, Object>(); 19 public PropertiesObject createAccessee() { 20 return new PropertiesObject(framsClass.getId()); 29 21 } 30 22 … … 43 35 assert properties != null; 44 36 assert param != null; 45 Object object = properties.get(param.getId()); 46 if (object != null) { 47 try { 48 return type.cast(object); 49 } catch (ClassCastException e) { 50 throw (ClassCastException) new ClassCastException("property " + param + " type is " + object.getClass().getName() + ", not " + type.getName()).initCause(e); 51 } 37 Object object = properties.get(param.getId(), Object.class); 38 if (object == null) { 39 return null; 52 40 } 53 41 try { 54 return param.getDef(type);42 return type.cast(object); 55 43 } catch (ClassCastException e) { 56 throw (ClassCastException) new ClassCastException(" default value of property " + param + " is not of type" + type.getName()).initCause(e);44 throw (ClassCastException) new ClassCastException("property " + param + " type is " + object.getClass().getName() + ", not " + type.getName()).initCause(e); 57 45 } 58 59 46 } 60 47 61 48 @Override 62 49 protected <T> void internalSet(ValueParam param, T value) { 63 properties. put(param.getId(), value);50 properties.set(param.getId(), value); 64 51 } 65 52 … … 73 60 * the properties with parameters values 74 61 */ 75 @SuppressWarnings("unchecked")76 62 @Override 77 63 public PropertiesAccess select(Object object) { 78 properties = ParamsUtil.selectObjectForAccess(this, object, Map.class);64 properties = ParamsUtil.selectObjectForAccess(this, object, PropertiesObject.class); 79 65 return this; 80 66 } … … 82 68 /** covariant */ 83 69 @Override 84 public Map<String, Object>getSelected() {70 public PropertiesObject getSelected() { 85 71 return properties; 86 72 } … … 97 83 98 84 @Override 99 public Object call(String id, Object []arguments) {85 public Object call(String id, Object... arguments) { 100 86 throw new InvalidOperationException().msg("properties access does not support calling methods").arg("id", id); 101 87 } 102 88 103 89 @Override 104 public Object call(ProcedureParam param, Object []arguments) {90 public Object call(ProcedureParam param, Object... arguments) { 105 91 throw new InvalidOperationException().msg("properties access does not support calling methods").arg("param", param); 106 92 }
Note: See TracChangeset
for help on using the changeset viewer.