AttributeSourceGenerator { public static String generateSeparateAttributesClass(final Class<?> targetClass, String packageOfAttributesClass) { return generateAttributesForClass(targetClass, true, packageOfAttributesClass, ALL_MEMBERS); } 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 testGenerateSeparateAttributesClass() { String expected = "" + "package com.googlecode.cqengine.codegen;\n" + "\n" + "import com.googlecode.cqengine.attribute.*;\n" + "import com.googlecode.cqengine.query.option.QueryOptions;\n" + "import java.util.*;\n" + "import com.googlecode.cqengine.codegen.AttributeSourceGeneratorTest.Car;\n" + "\n" + "\n" + "public class CQCar {\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> 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, Double> GET_PRICES = new MultiValueNullableAttribute<Car, Double>(\"GET_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.getPrices()[i]; }\n" + " public int size() { return car.getPrices().length; }\n" + " };\n" + " }\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" + " };\n" + "}\n"; assertEquals(expected, generateSeparateAttributesClass(Car.class, Car.class.getPackage())); }