class FieldQueryMapEncoder implements QueryMapEncoder {

  @Override
  public Map<String, Object> encode(Object object) throws EncodeException {
    try {
      ObjectParamMetadata metadata = getMetadata(object.getClass());
      Map<String, Object> fieldNameToValue = new HashMap<String, Object>();
      for (Field field : metadata.objectFields) {
        Object value = field.get(object);
        if (value != null && value != object) {
          Param alias = field.getAnnotation(Param.class);
          String name = alias != null ? alias.value() : field.getName();
          fieldNameToValue.put(name, value);
        }
      }
      return fieldNameToValue;
    } catch (IllegalAccessException e) {
      throw new EncodeException("Failure encoding object into query map", e);
    }
  }

}