Remove generateProperties

pull/618/head
Alex Baker 7 years ago
parent c1bf0b3b4f
commit ce93e339b4

@ -16,10 +16,6 @@ import com.todoroo.andlib.data.Property.PropertyVisitor;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import java.lang.reflect.Array; import java.lang.reflect.Array;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
@ -402,39 +398,6 @@ public abstract class AbstractModel implements Parcelable, Cloneable {
return trans != null; return trans != null;
} }
// --- property management
/**
* Looks inside the given class and finds all declared properties
*/
protected static Property<?>[] generateProperties(Class<? extends AbstractModel> cls) {
ArrayList<Property<?>> properties = new ArrayList<>();
if(cls.getSuperclass() != AbstractModel.class) {
properties.addAll(Arrays.asList(generateProperties(
(Class<? extends AbstractModel>) cls.getSuperclass())));
}
// a property is public, static & extends Property
for(Field field : cls.getFields()) {
if((field.getModifiers() & Modifier.STATIC) == 0) {
continue;
}
if(!Property.class.isAssignableFrom(field.getType())) {
continue;
}
try {
if(((Property<?>) field.get(null)).table == null) {
continue;
}
properties.add((Property<?>) field.get(null));
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new RuntimeException(e);
}
}
return properties.toArray(new Property<?>[properties.size()]);
}
/** /**
* Visitor that saves a value into a content values store * Visitor that saves a value into a content values store
* *

@ -175,7 +175,29 @@ public class Task extends AbstractModel {
TABLE, "remoteId"); TABLE, "remoteId");
/** List of all properties for this model */ /** List of all properties for this model */
public static final Property<?>[] PROPERTIES = generateProperties(Task.class); public static final Property<?>[] PROPERTIES = new Property<?>[] {
CALENDAR_URI,
COMPLETION_DATE,
CREATION_DATE,
DELETION_DATE,
DUE_DATE,
ELAPSED_SECONDS,
ESTIMATED_SECONDS,
HIDE_UNTIL,
ID,
IMPORTANCE,
MODIFICATION_DATE,
NOTES,
RECURRENCE,
REMINDER_FLAGS,
REMINDER_LAST,
REMINDER_PERIOD,
REMINDER_SNOOZE,
REPEAT_UNTIL,
TIMER_START,
TITLE,
UUID
};
// --- notification flags // --- notification flags
@ -198,10 +220,6 @@ public class Task extends AbstractModel {
public static final int IMPORTANCE_SHOULD_DO = 2; public static final int IMPORTANCE_SHOULD_DO = 2;
public static final int IMPORTANCE_NONE = 3; public static final int IMPORTANCE_NONE = 3;
/**
* @return colors that correspond to importance values
*/
// --- defaults // --- defaults
/** Default values container */ /** Default values container */

Loading…
Cancel
Save