@Override public float getValue(Agent a) { Object state = getParamObject(a); if (state == null) return 0; Object v = propertyAccessor.get(state); if (propertyAccessor.getType().equals(float.class)) return (float) v; if (propertyAccessor.getType().equals(int.class)) return (int) v; else throw new IllegalArgumentException("Field is not one of the acceptible types"); }
@Override public void setValue(Agent a, float value) { Object state = getParamObject(a); if (state == null) return; if (propertyAccessor.getType().equals(float.class)) { propertyAccessor.set(state, value); } else if (propertyAccessor.getType().equals(int.class)) { propertyAccessor.set(state, Math.round(value)); } else { throw new IllegalArgumentException("Field is not one of the acceptible types"); } }
@Override public String getIdentifier() { return propertyAccessor.getXmlName(); }
@Override public String getName() { return propertyAccessor.getName(); }
protected Object getParamObject(Agent a) { AgentState state = ((ComplexAgent) a).getState(type); if (state == null) return null; return stateParamAccessor.get(state); }