Пример #1
0
  @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");
  }
Пример #2
0
  @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");
    }
  }
Пример #3
0
 @Override
 public String getIdentifier() {
   return propertyAccessor.getXmlName();
 }
Пример #4
0
 @Override
 public String getName() {
   return propertyAccessor.getName();
 }
Пример #5
0
  protected Object getParamObject(Agent a) {
    AgentState state = ((ComplexAgent) a).getState(type);
    if (state == null) return null;

    return stateParamAccessor.get(state);
  }