JavaGetterFilter extends Filter { @Override public Object apply(Object value, Object... params) { Map<String, Object> param = (Map<String, Object>) value; String name = (String) param.get("name"); String type = (String) param.get("type"); boolean compound = param.containsKey("compound") && (boolean) param.get("compound"); name = name.substring(0, 1).toUpperCase() + name.substring(1); if (!compound && (type.equals("boolean") || type.equals("flag"))) { value = "is" + name; } else { value = "get" + name; } if (Arrays.binarySearch(objectMethodNames, value) >= 0) { value += "_"; } return value; } JavaGetterFilter(); @Override Object apply(Object value, Object... params);  }
@Test public void testApply_prependsGetToParamName() { JavaGetterFilter filter = new JavaGetterFilter(); assertEquals("getFoobar", filter.apply(param("foobar", "int"))); }
@Test public void testApply_prependsIsForBooleanParam() { JavaGetterFilter filter = new JavaGetterFilter(); assertEquals("isFoobar", filter.apply(param("foobar", "boolean"))); }
@Test public void testApply_prependsIsForFlagParam() { JavaGetterFilter filter = new JavaGetterFilter(); assertEquals("isFoobar", filter.apply(param("foobar", "flag"))); }
@Test public void testApply_sanitizesMethodNameIfMethodExistsOnJavaObjectClass() { JavaGetterFilter filter = new JavaGetterFilter(); assertEquals("getClass_", filter.apply(param("class", "string"))); }