Esempio n. 1
0
 /**
  * Convert the error arguments.
  *
  * @param arguments The arguments to convert.
  * @return The converted arguments.
  */
 private List<Object> convertErrorArguments(Object[] arguments) {
   List<Object> converted = new ArrayList<>(arguments.length);
   for (Object arg : arguments) {
     if (!(arg instanceof org.springframework.context.support.DefaultMessageSourceResolvable)) {
       converted.add(arg);
     }
   }
   return Collections.unmodifiableList(converted);
 }
Esempio n. 2
0
 static List<Class> all() {
   List<String> names = Boot.getClasses();
   names.remove("water.Boot"); // In case called from Boot loader
   names.remove("water.Weaver");
   Collections.sort(names); // For deterministic runs
   List<Class> tests = new ArrayList<Class>();
   Log._dontDie = true;
   for( String name : names ) {
     try {
       Class c = Class.forName(name);
       if( isTest(c) )
         tests.add(c);
     } catch( Throwable _ ) {
     }
   }
   if( tests.size() == 0 )
     throw new RuntimeException("Failed to find tests");
   filter(tests);
   return tests;
 }
Esempio n. 3
0
    /** Return the indexes available for this field (for repeated fields ad List) */
    @SuppressWarnings("rawtypes")
    public List<Integer> indexes() {
      if (form.value().isPresent()) {
        BeanWrapper beanWrapper = new BeanWrapperImpl(form.value().get());
        beanWrapper.setAutoGrowNestedPaths(true);
        String objectKey = name;
        if (form.name() != null && name.startsWith(form.name() + ".")) {
          objectKey = name.substring(form.name().length() + 1);
        }

        List<Integer> result = new ArrayList<>();
        if (beanWrapper.isReadableProperty(objectKey)) {
          Object value = beanWrapper.getPropertyValue(objectKey);
          if (value instanceof Collection) {
            for (int i = 0; i < ((Collection) value).size(); i++) {
              result.add(i);
            }
          }
        }

        return result;

      } else {
        Set<Integer> result = new HashSet<>();
        Pattern pattern = Pattern.compile("^" + Pattern.quote(name) + "\\[(\\d+)\\].*$");

        for (String key : form.data().keySet()) {
          java.util.regex.Matcher matcher = pattern.matcher(key);
          if (matcher.matches()) {
            result.add(Integer.parseInt(matcher.group(1)));
          }
        }

        List<Integer> sortedResult = new ArrayList<>(result);
        Collections.sort(sortedResult);
        return sortedResult;
      }
    }