Skip to content

Instantly share code, notes, and snippets.

@meierjan
Created October 28, 2015 11:44
Show Gist options
  • Save meierjan/bd0973dfd709e077779c to your computer and use it in GitHub Desktop.
Save meierjan/bd0973dfd709e077779c to your computer and use it in GitHub Desktop.
A helper class that helps you speed up creating greenDAO classes.
import java.util.HashMap;
import java.util.Map;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Property;
/**
* Created by jmeier on 28.10.15.
*/
enum PropertyType {
IntProperties, StringProperties, FloatProperties, BooleanProperties
}
public class GeneratorHelper {
public static Map<String, Property.PropertyBuilder> generateProperties(Entity entity, String[] propertyArray, PropertyType type, String codeBeforeProperties) {
Map<String, Property.PropertyBuilder> map = new HashMap<String, Property.PropertyBuilder>();
for (int i = 0; i < propertyArray.length; i++) {
Property.PropertyBuilder property = null;
switch (type) {
case IntProperties:
property = entity.addIntProperty(propertyArray[i]);
break;
case BooleanProperties:
property = entity.addBooleanProperty(propertyArray[i]);
break;
case StringProperties:
property = entity.addStringProperty(propertyArray[i]);
break;
case FloatProperties:
property = entity.addFloatProperty(propertyArray[i]);
break;
}
property.codeBeforeField(codeBeforeProperties);
map.put(propertyArray[i], property);
}
return map;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment