/** * In GSS, constant names are defined in upper case but a method name to access a constant in * a CssResource interface can be written in lower camel case. * <p> * This method converts all constant names in a lower camel case identifier. */ private Collection<String> renameDefs(Iterable<String> constantsNames) { return Lists.newArrayList(Iterables.transform(constantsNames, new Function<String, String>() { @Override public String apply(String constantName) { String lowerCase = CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, constantName); // If we cannot revert the method name to the original constant name, use the // original constant name. // This case happens when number are used after an underscore: // CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.LOWER_CAMEL, "DEF_1") returns def1 // but CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, "def1") returns DEF1 and the // GssResourceGenerator is not able to match the name of the method with the name of the // constant . if (!constantName.equals(CaseFormat.LOWER_CAMEL.to(CaseFormat.UPPER_UNDERSCORE, lowerCase))) { return constantName; } return lowerCase; } })); }
@Override public boolean apply(T input) { Class<?> inputClass = toClass.apply(input); for (Class<?> match : Iterables.transform(source, toClass)) { if (!inputClass.equals(match) && inputClass.isAssignableFrom(match)) { return false; } } return true; } };
@Override public boolean apply(T input) { Class<?> inputClass = toClass.apply(input); for (Class<?> match : Iterables.transform(source, toClass)) { if (!inputClass.equals(match) && inputClass.isAssignableFrom(match)) { return false; } } return true; } };
/** * Creates a Predicate that returns false if source contains an associated class that is a super * type of the class associated with the tested T. * * @param <T> the type to test * @param source the set of <T> to look for class matches. * @param toClass Function from T to Class * @return newly create predicate. */ static <T> Predicate<T> createMostSpecificMatchPredicate(final Iterable<T> source, final Function<T, Class<?>> toClass) { return input -> { final Class<?> inputClass = toClass.apply(input); for (final Class<?> match : Iterables.transform(source, toClass)) { if (!inputClass.equals(match) && inputClass.isAssignableFrom(match)) { return false; } } return true; }; }
Iterables.transform( ImmutableList.copyOf(beanInfo.getPropertyDescriptors()), Functions.compose(TO_LITERAL, PROPERTY_DESCRIPTOR_TO_NAME))));
Iterables.transform( ImmutableList.copyOf(beanInfo.getPropertyDescriptors()), Functions.compose(TO_LITERAL, PROPERTY_DESCRIPTOR_TO_NAME))));
.join(Iterables.transform(ImmutableList.copyOf(beanInfo.getPropertyDescriptors()), Functions.compose(TO_LITERAL, PROPERTY_DESCRIPTOR_TO_NAME)))); sw.println("));");