Created
October 28, 2015 11:44
-
-
Save meierjan/bd0973dfd709e077779c to your computer and use it in GitHub Desktop.
A helper class that helps you speed up creating greenDAO classes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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