private Vaidataton validate;
public String getValidate() throws IllegalArgumentException, IllegalAccessException {
Field[] fields = validate.getClass().getDeclaredFields();
StringBuilder sb = new StringBuilder();
for (Field f : fields) {
Class<?> t = f.getType();
if (f.get(validation) == null) {
continue;// if validation value is not then skip
}
if (t == String.class) {
sb.append(" data-parsley-" + f.getName() + "=\"" + f.get(validation) + "\"");
} else if (t == Integer.class) {
sb.append(" data-parsley-" + f.getName() + "=" + f.get(validation));
} else if (t == List.class) {
List<Integer> x = new ArrayList<Integer>();
x = (ArrayList<Integer>) f.get(validation);
if (x != null) {
sb.append(" data-parsley-" + f.getName() + "=\"[" + x.get(0) + "," + x.get(1) + "]\"");
}
}
}
No comments:
Post a Comment