Пример #1
0
 public static String getConstruct(Result result) {
   String construct = result.getConstruct();
   if (construct == null) {
     construct = "item";
     result.setConstruct(construct);
   }
   return construct;
 }
Пример #2
0
 public static Result createResult(Class<?> resultType) {
   Result result = new Result();
   String resultName = resultType.getCanonicalName();
   String simpleName = NameUtil.getSimpleName(resultName);
   result.setName(NameUtil.uncapName(simpleName));
   String typeName = TypeUtil.getTypeFromClass(resultType);
   // Assert.notNull(typeName, "TypeName not found for: "+resultName);
   if (typeName == null) typeName = resultName;
   result.setType(typeName);
   return result;
 }
Пример #3
0
 public static boolean validate(Result result) {
   if (result == null) return false;
   Validator validator = Validator.getValidator();
   validator.notEmpty(result.getType(), "\"Type\" must be specified");
   boolean isValid = validator.isValid();
   return isValid;
 }
Пример #4
0
 public static boolean equals(Result result1, Result result2) {
   Assert.notNull(result1, "Result1 must be specified");
   Assert.notNull(result2, "Result2 must be specified");
   Assert.notNull(result1.getName(), "Result1 name must be specified");
   Assert.notNull(result2.getName(), "Result2 name must be specified");
   Assert.notNull(result1.getType(), "Result1 type must be specified");
   Assert.notNull(result2.getType(), "Result2 type must be specified");
   if (!result1.getName().equals(result2.getName())) return false;
   if (!result1.getType().equals(result2.getType())) return false;
   return true;
 }
Пример #5
0
 public static void initialize(Result result) {
   if (result.getRequired() == null) result.setRequired(false);
 }
Пример #6
0
 public static String toString(Result result) {
   if (isEmpty(result)) return "Result: [uninitialized] " + result.toString();
   String text = result.toString();
   return text;
 }
Пример #7
0
 public static boolean isEmpty(Result result) {
   if (result == null) return true;
   boolean status = false;
   status |= StringUtils.isEmpty(result.getType());
   return status;
 }
Пример #8
0
 public static String getLabel(Result result) {
   return result.getType();
 }
Пример #9
0
 public static Object getKey(Result result) {
   return result.getType();
 }
Пример #10
0
 public static Class<?> getResultType(Result result) {
   if (result != null && result.getType() != null)
     return TypeMap.INSTANCE.getTypeClassByTypeName(result.getType());
   // TODO get this outta here
   return null;
 }
Пример #11
0
 public static Result clone(Result result) {
   if (result == null) return null;
   Result clone = create();
   clone.setType(ObjectUtil.clone(result.getType()));
   clone.setName(ObjectUtil.clone(result.getName()));
   clone.setKey(ObjectUtil.clone(result.getKey()));
   clone.setConstruct(ObjectUtil.clone(result.getConstruct()));
   clone.setRequired(ObjectUtil.clone(result.getRequired()));
   return clone;
 }