Beispiel #1
0
  public static List<Property> getProperties(dObject object) {
    List<Property> props = new ArrayList<Property>();

    try {
      if (properties.containsKey(object.getClass())) {
        for (Class property : properties.get(object.getClass())) {
          if ((Boolean) describes.get(property).invoke(null, object))
            props.add((Property) getFrom.get(property).invoke(null, object));
        }
      }

    } catch (IllegalAccessException e) {
      dB.echoError(e);
    } catch (InvocationTargetException e) {
      dB.echoError(e);
    }

    return props;
  }
Beispiel #2
0
  public void registerProperty(Class property, Class<? extends dObject> object) {
    // Add property to the dObject's Properties list
    List<Class> prop_list;

    // Get current properties list, or make a new one
    if (properties.containsKey(object)) prop_list = properties.get(object);
    else prop_list = new ArrayList<Class>();

    // Add this property to the list
    prop_list.add(property);

    // Put the list back into the Map
    properties.put(object, prop_list);

    // Cache methods used for fetching new properties
    try {
      describes.put(property, property.getMethod("describes", dObject.class));
      getFrom.put(property, property.getMethod("getFrom", dObject.class));

    } catch (NoSuchMethodException e) {
      dB.echoError("Unable to register property '" + property.getSimpleName() + "'!");
    }
  }