AttributeSourceGenerator { public static String generateAttributesForPastingIntoTargetClass(final Class<?> targetClass) { return generateAttributesForClass(targetClass, false, "", FIELDS_ONLY); } AttributeSourceGenerator(); static String generateAttributesForPastingIntoTargetClass(final Class<?> targetClass); static String generateAttributesForPastingIntoTargetClass(final Class<?> targetClass, MemberFilter memberFilter); static String generateSeparateAttributesClass(final Class<?> targetClass, String packageOfAttributesClass); static String generateSeparateAttributesClass(final Class<?> targetClass, String packageOfAttributesClass, MemberFilter memberFilter); static String generateSeparateAttributesClass(final Class<?> targetClass, Package packageOfAttributesClass); static String generateSeparateAttributesClass(final Class<?> targetClass, Package packageOfAttributesClass, MemberFilter memberFilter);  }
@Test public void testGenerateAttributesForPastingIntoTargetClass() { String expected = "" + "\n" + "\n" + " \n" + " " " public static final Attribute<Car, String> NAME = new SimpleNullableAttribute<Car, String>(\"NAME\") {\n" + " public String getValue(Car car, QueryOptions queryOptions) { return car.name; }\n" + " };\n" + "\n" + " \n" + " " " public static final Attribute<Car, String> DESCRIPTION = new SimpleNullableAttribute<Car, String>(\"DESCRIPTION\") {\n" + " public String getValue(Car car, QueryOptions queryOptions) { return car.description; }\n" + " };\n" + "\n" + " \n" + " " " " " public static final Attribute<Car, String> FEATURES = new MultiValueNullableAttribute<Car, String>(\"FEATURES\", true) {\n" + " public Iterable<String> getNullableValues(Car car, QueryOptions queryOptions) { return car.features; }\n" + " };\n" + "\n" + " \n" + " " " " public static final Attribute<Car, Double> PRICES = new MultiValueNullableAttribute<Car, Double>(\"PRICES\", false) {\n" + " public Iterable<Double> getNullableValues(final Car car, QueryOptions queryOptions) {\n" + " return new AbstractList<Double>() {\n" + " public Double get(int i) { return car.prices[i]; }\n" + " public int size() { return car.prices.length; }\n" + " };\n" + " }\n" + " };\n" + "\n" + " \n" + " " " " " public static final Attribute<Car, String> EXTRAS = new MultiValueNullableAttribute<Car, String>(\"EXTRAS\", true) {\n" + " public Iterable<String> getNullableValues(Car car, QueryOptions queryOptions) { return Arrays.asList(car.extras); }\n" + " };\n" + "\n" + " \n" + " public static final Attribute<Car, Integer> INHERITED_CAR_ID = new SimpleAttribute<Car, Integer>(\"INHERITED_CAR_ID\") {\n" + " public Integer getValue(Car car, QueryOptions queryOptions) { return car.inheritedCarId; }\n" + " };"; assertEquals(expected, generateAttributesForPastingIntoTargetClass(Car.class)); }