@Test public void testIncludeOneField() { List<Field> fields = new FieldReferenceFilter(true, Collections.singleton("Phone")).filter(dsr); verifyFilteredFields(fields, Arrays.asList(new String[] {"Id", "Name", "Phone"})); }
@Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> fieldList = Lists.newArrayList(dsr.getFields()); Iterator<Field> fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { Field field = fieldIter.next(); if (field.getType() == FieldType.reference) { for (String referenceTo : field.getReferenceTo()) { if (include != referenceObjectNames.contains(referenceTo)) { fieldIter.remove(); break; } } } } return fieldList; }
FieldReferenceFilter implements FieldFilter { @Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> fieldList = Lists.newArrayList(dsr.getFields()); Iterator<Field> fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { Field field = fieldIter.next(); if (field.getType() == FieldType.reference) { for (String referenceTo : field.getReferenceTo()) { if (include != referenceObjectNames.contains(referenceTo)) { fieldIter.remove(); break; } } } } return fieldList; } }
FieldReferenceFilter implements FieldFilter { @Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> fieldList = Lists.newArrayList(dsr.getFields()); Iterator<Field> fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { Field field = fieldIter.next(); if (field.getType() == FieldType.reference) { for (String referenceTo : field.getReferenceTo()) { if (include != referenceObjectNames.contains(referenceTo)) { fieldIter.remove(); break; } } } } return fieldList; } FieldReferenceFilter(boolean include, Set<String> referenceObjectNames);  FieldReferenceFilter(boolean include, String... referenceObjectNames); }
FieldReferenceFilter implements FieldFilter { @Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> fieldList = Lists.newArrayList(dsr.getFields()); Iterator<Field> fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { Field field = fieldIter.next(); if (field.getType() == FieldType.reference) { for (String referenceTo : field.getReferenceTo()) { if (include != referenceObjectNames.contains(referenceTo)) { fieldIter.remove(); break; } } } } return fieldList; } FieldReferenceFilter(boolean include, Set<String> referenceObjectNames);  FieldReferenceFilter(boolean include, String... referenceObjectNames); @Override List<Field> filter(DescribeSObjectResult dsr); Set<String> getReferenceObjectNames(); boolean isInclude(); }
FieldReferenceFilter implements FieldFilter { @Override public List<Field> filter(DescribeSObjectResult dsr) { List<Field> fieldList = Lists.newArrayList(dsr.getFields()); Iterator<Field> fieldIter = fieldList.iterator(); while (fieldIter.hasNext()) { Field field = fieldIter.next(); if (field.getType() == FieldType.reference) { for (String referenceTo : field.getReferenceTo()) { if (include != referenceObjectNames.contains(referenceTo)) { fieldIter.remove(); break; } } } } return fieldList; } FieldReferenceFilter(boolean include, Set<String> referenceObjectNames);  FieldReferenceFilter(boolean include, String... referenceObjectNames); @Override List<Field> filter(DescribeSObjectResult dsr); Set<String> getReferenceObjectNames(); boolean isInclude();  }