IdentifiableObjectUtils { public static Map<String, String> getUidPropertyMap( Collection<? extends IdentifiableObject> objects, IdentifiableProperty property ) { Map<String, String> map = Maps.newHashMap(); objects.forEach( obj -> map.put( obj.getUid(), obj.getPropertyValue( IdScheme.from( property ) ) ) ); return map; }  static String join( Collection<? extends IdentifiableObject> objects ); static List<String> getUids( Collection<T> objects ); static List<String> getCodes( Collection<T> objects ); static List<Long> getIdentifiers( Collection<T> objects ); static Map<Long, T> getIdentifierMap( Collection<T> objects ); static List<String> getLocalPeriodIdentifiers( Collection<T> periods, Calendar calendar ); static String getLocalPeriodIdentifier( Period period, Calendar calendar ); static Period getPeriodByPeriodType( Period period, PeriodType periodType, Calendar calendar ); static List<T> filterNameByKey( List<T> identifiableObjects, String key,
        boolean ignoreCase ); static List<T> removeDuplicates( List<T> list ); static String getLastUpdatedTag( Collection<T> objects ); static String getLastUpdatedTag( IdentifiableObject object ); static Map<String, String> getUidNameMap( Collection<? extends IdentifiableObject> objects ); static Map<String, String> getUidPropertyMap( Collection<? extends IdentifiableObject> objects, IdentifiableProperty property ); static Map<String, T> getUidObjectMap( Collection<T> objects ); static Map<String, T> getIdMap( List<T> objects, IdScheme idScheme ); static String getDisplayName( Object object ); static String getIdentifierBasedOnIdScheme( T object, IdScheme idScheme ); static final String SEPARATOR; static final String SEPARATOR_JOIN; static final DateTimeFormatter LONG_DATE_FORMAT; static final DateTimeFormatter MEDIUM_DATE_FORMAT; static final Map<String, String> CLASS_ALIAS; }
@Test public void testGetUidMapIdentifiableProperty() { DataElement deA = new DataElement( "NameA" ); DataElement deB = new DataElement( "NameB" ); DataElement deC = new DataElement( "NameC" ); deA.setUid( "A123456789A" ); deB.setUid( "A123456789B" ); deC.setUid( "A123456789C" ); deA.setCode( "CodeA" ); deB.setCode( "CodeB" ); deC.setCode( null ); List<DataElement> elements = Lists.newArrayList( deA, deB, deC ); Map<String, String> map = IdentifiableObjectUtils.getUidPropertyMap( elements, IdentifiableProperty.CODE ); assertEquals( 3, map.size() ); assertEquals( "CodeA", map.get( "A123456789A" ) ); assertEquals( "CodeB", map.get( "A123456789B" ) ); assertEquals( null, map.get( "A123456789C" ) ); }