/** * Finds any Facebook JSON fields that are mapped to more than 1 Java field. * * @param fieldsWithAnnotation * Java fields annotated with the {@code Facebook} annotation. * @return Any Facebook JSON fields that are mapped to more than 1 Java field. */ protected Set<String> facebookFieldNamesWithMultipleMappings(List<FieldWithAnnotation<Facebook>> fieldsWithAnnotation) { Map<String, Integer> facebookFieldsNamesWithOccurrenceCount = new HashMap<String, Integer>(); Set<String> facebookFieldNamesWithMultipleMappings = new HashSet<String>(); // Get a count of Facebook field name occurrences for each // @Facebook-annotated field for (FieldWithAnnotation<Facebook> fieldWithAnnotation : fieldsWithAnnotation) { String fieldName = getFacebookFieldName(fieldWithAnnotation); int occurrenceCount = facebookFieldsNamesWithOccurrenceCount.containsKey(fieldName) ? facebookFieldsNamesWithOccurrenceCount .get(fieldName) : 0; facebookFieldsNamesWithOccurrenceCount.put(fieldName, occurrenceCount + 1); } // Pull out only those field names with multiple mappings for (Entry<String, Integer> entry : facebookFieldsNamesWithOccurrenceCount.entrySet()) if (entry.getValue() > 1) facebookFieldNamesWithMultipleMappings.add(entry.getKey()); return unmodifiableSet(facebookFieldNamesWithMultipleMappings); }
/** * Finds any Facebook JSON fields that are mapped to more than 1 Java field. * * @param fieldsWithAnnotation * Java fields annotated with the {@code Facebook} annotation. * @return Any Facebook JSON fields that are mapped to more than 1 Java field. */ protected Set<String> facebookFieldNamesWithMultipleMappings( List<FieldWithAnnotation<Facebook>> fieldsWithAnnotation) { Map<String, Integer> facebookFieldsNamesWithOccurrenceCount = new HashMap<>(); Set<String> facebookFieldNamesWithMultipleMappings = new HashSet<>(); // Get a count of Facebook field name occurrences for each // @Facebook-annotated field for (FieldWithAnnotation<Facebook> fieldWithAnnotation : fieldsWithAnnotation) { String fieldName = getFacebookFieldName(fieldWithAnnotation); int occurrenceCount = facebookFieldsNamesWithOccurrenceCount.containsKey(fieldName) ? facebookFieldsNamesWithOccurrenceCount.get(fieldName) : 0; facebookFieldsNamesWithOccurrenceCount.put(fieldName, occurrenceCount + 1); } // Pull out only those field names with multiple mappings for (Entry<String, Integer> entry : facebookFieldsNamesWithOccurrenceCount.entrySet()) { if (entry.getValue() > 1) { facebookFieldNamesWithMultipleMappings.add(entry.getKey()); } } return unmodifiableSet(facebookFieldNamesWithMultipleMappings); }
String facebookFieldName = getFacebookFieldName(fieldWithAnnotation); fieldWithAnnotation.getField().setAccessible(true);
String facebookFieldName = getFacebookFieldName(fieldWithAnnotation);
String facebookFieldName = getFacebookFieldName(fieldWithAnnotation); fieldWithAnnotation.getField().setAccessible(true);
String facebookFieldName = getFacebookFieldName(fieldWithAnnotation);