Skip to content

Commit

Permalink
Merge pull request #28 from sbxcloud/annotationlib
Browse files Browse the repository at this point in the history
savedefaultvalue
  • Loading branch information
lgguzman committed Jun 23, 2017
2 parents fdb9477 + 3b956de commit 542fff1
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 19 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Agregamos la librería como dependencia

dependencies {
//...otras dependencias de tu proyeco aquí.....
compile 'com.github.sbxcloud:androidlib:v2.3.4'
compile 'com.github.sbxcloud:androidlib:v2.3.6'
}
Esta librería se basa en annotaciones. Para crear tu propia Clase usuario puedes hacerla así:
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {

minSdkVersion 15
targetSdkVersion 25
versionCode 4
versionName "2.2.1"
versionCode 9
versionName "2.3.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,50 @@ public static <T>SbxUrlComposer getUrlInsertOrUpdateRows(List<T> objects)throws
}
case "int": {
int data = variable.getInt(o);
queryBuilder.insertFieldLastRow(name, data);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "class java.lang.Integer": {
int data = variable.getInt(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "long": {
long data = variable.getLong(o);
queryBuilder.insertFieldLastRow(name, data);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "class java.lang.Long": {
long data = variable.getLong(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "double": {
double data = variable.getDouble(o);
queryBuilder.insertFieldLastRow(name, data);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "class java.lang.Double": {
double data = variable.getDouble(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "float": {
float data = variable.getFloat(o);
queryBuilder.insertFieldLastRow(name, data);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "class java.lang.Float": {
float data = variable.getFloat(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "class java.util.Date": {
Expand All @@ -111,7 +139,8 @@ public static <T>SbxUrlComposer getUrlInsertOrUpdateRows(List<T> objects)throws
}
case "boolean": {
boolean data = variable.getBoolean(o);
queryBuilder.insertFieldLastRow(name, data);
if(SbxDataValidator.saveDefaultValue(annotation) || data)
queryBuilder.insertFieldLastRow(name, data);
break;
}
default: {
Expand Down Expand Up @@ -197,22 +226,50 @@ public static SbxUrlComposer getUrlInsertOrUpdateRow(Object o)throws Exception {
}
case "int":{
int data=variable.getInt(o);
queryBuilder.insertFieldLastRow(name,data);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name,data);
break;
}
case "class java.lang.Integer": {
int data = variable.getInt(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "long": {
long data = variable.getLong(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "class java.lang.Long": {
long data = variable.getLong(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "double": {
double data = variable.getDouble(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "long":{
long data=variable.getLong(o);
queryBuilder.insertFieldLastRow(name,data);
case "class java.lang.Double": {
double data = variable.getDouble(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "double":{
double data=variable.getDouble(o);
queryBuilder.insertFieldLastRow(name,data);
case "float": {
float data = variable.getFloat(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "float":{
float data=variable.getFloat(o);
queryBuilder.insertFieldLastRow(name,data);
case "class java.lang.Float": {
float data = variable.getFloat(o);
if(SbxDataValidator.saveDefaultValue(annotation) || data!=0)
queryBuilder.insertFieldLastRow(name, data);
break;
}
case "class java.util.Date":{
Expand All @@ -225,7 +282,8 @@ public static SbxUrlComposer getUrlInsertOrUpdateRow(Object o)throws Exception {
}
case "boolean":{
boolean data=variable.getBoolean(o);
queryBuilder.insertFieldLastRow(name,data);
if(SbxDataValidator.saveDefaultValue(annotation) || data)
queryBuilder.insertFieldLastRow(name,data);
break;
}
default:{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
public @interface SbxParamField {

String name() default "";
boolean saveDefaultValue() default true;

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public static String getAnnotationName(Field variable, Annotation annotation ) t

}

public static Boolean saveDefaultValue( Annotation annotation ) throws Exception{
boolean data=((SbxParamField)annotation).saveDefaultValue();
return data;

}

public static boolean hasKeyAnnotation(Class<?> myClass){
final Field[] variables = myClass.getDeclaredFields();

Expand Down

0 comments on commit 542fff1

Please sign in to comment.