@Test public void testGetPropertyNamesStartingWith() { Properties props1 = new Properties(); PropertiesPropertySource pps1 = new PropertiesPropertySource( "Props1", props1 ); props1.put( "sdi.collect.comment.2", " props1.put( "sdi.collect.comment.1", "#" ); props1.put( "key", "value" ); Properties props2 = new Properties(); PropertiesPropertySource pps2 = new PropertiesPropertySource( "Props2", props2 ); props1.put( "sdi.collect.comment.2", ";" ); props1.put( "sdi.collect.comment.1", "?" ); MutablePropertySources mps = myEnv.getPropertySources(); mps.addFirst( pps1 ); mps.addLast( pps2 ); Collection<String> received = ConfigUtils.getPropertyNamesStartingWith( myEnv, "sdi.collect.comment." ); Assert.assertNotNull( received ); myLog.debug( "received: " + received ); Assert.assertEquals( 2, received.size() ); int i = 1; for ( Iterator<String> iterator = received.iterator(); iterator.hasNext(); ) { String key = iterator.next(); Assert.assertEquals( "sdi.collect.comment." + i, key ); i++; } myLog.debug( "testing composite property source" ); CompositePropertySource cps = new CompositePropertySource( "CompositeTest" ); cps.addPropertySource( pps1 ); cps.addPropertySource( pps2 ); TestUtils.removeAllFromEnvironment( myEnv ); mps = myEnv.getPropertySources(); mps.addFirst( pps1 ); received = ConfigUtils.getPropertyNamesStartingWith( myEnv, "sdi.collect.comment." ); Assert.assertNotNull( received ); myLog.debug( "received: " + received ); Assert.assertEquals( 2, received.size() ); for ( Iterator<String> iterator = received.iterator(); iterator.hasNext(); ) { String key = iterator.next(); Assert.assertTrue( key.startsWith( "sdi.collect.comment." ) ); } }
public static Collection<String> getPropertyNamesStartingWith( ConfigurableEnvironment aEnv, String aKeyPrefix ) { return getAllPropertyNames( aEnv ).stream() .filter( key -> key.startsWith( aKeyPrefix ) ) .collect( Collectors.toCollection( (Supplier<Set<String>>) TreeSet::new ) ); }
ConfigUtils { public static Collection<String> getPropertyNamesStartingWith( ConfigurableEnvironment aEnv, String aKeyPrefix ) { return getAllPropertyNames( aEnv ).stream() .filter( key -> key.startsWith( aKeyPrefix ) ) .collect( Collectors.toCollection( (Supplier<Set<String>>) TreeSet::new ) ); } }
ConfigUtils { public static Collection<String> getPropertyNamesStartingWith( ConfigurableEnvironment aEnv, String aKeyPrefix ) { return getAllPropertyNames( aEnv ).stream() .filter( key -> key.startsWith( aKeyPrefix ) ) .collect( Collectors.toCollection( (Supplier<Set<String>>) TreeSet::new ) ); }  }
ConfigUtils { public static Collection<String> getPropertyNamesStartingWith( ConfigurableEnvironment aEnv, String aKeyPrefix ) { return getAllPropertyNames( aEnv ).stream() .filter( key -> key.startsWith( aKeyPrefix ) ) .collect( Collectors.toCollection( (Supplier<Set<String>>) TreeSet::new ) ); }  static String makePropertyResourceName( Class<?> aClass ); static int getIntProperty( Environment aEnv, String aKey ); static int getIntProperty( Environment aEnv, String aKey, int aDefault ); static String getStringProperty( Environment aEnv,
                                            String aKey ); static boolean getBooleanProperty( Environment aEnv,
                                              String aKey ); static boolean getBooleanProperty( Environment aEnv,
                                              String aKey,
                                              boolean aDefault ); static void addToEnvironment( ConfigurableEnvironment aEnv,
                                         String aKey,
                                         Object aValue ); static void removeFromEnvironment( ConfigurableEnvironment aEnv,
                                              String aKey ); static Map<String, Object> getOrCreatePropertySource( ConfigurableEnvironment aEnv,
                                                                 String aPropertySourceName ); static void setConversionService( ConversionService aConversionService ); static Collection<String> getPropertyNamesStartingWith( ConfigurableEnvironment aEnv,
                                                                   String aKeyPrefix ); static Collection<String> getAllPropertyNames( ConfigurableEnvironment aEnv ); static Collection<String> getAllPropertyNames( PropertySource<?> aPropSource ); }
ConfigUtils { public static Collection<String> getPropertyNamesStartingWith( ConfigurableEnvironment aEnv, String aKeyPrefix ) { return getAllPropertyNames( aEnv ).stream() .filter( key -> key.startsWith( aKeyPrefix ) ) .collect( Collectors.toCollection( (Supplier<Set<String>>) TreeSet::new ) ); }  static String makePropertyResourceName( Class<?> aClass ); static int getIntProperty( Environment aEnv, String aKey ); static int getIntProperty( Environment aEnv, String aKey, int aDefault ); static String getStringProperty( Environment aEnv,
                                            String aKey ); static boolean getBooleanProperty( Environment aEnv,
                                              String aKey ); static boolean getBooleanProperty( Environment aEnv,
                                              String aKey,
                                              boolean aDefault ); static void addToEnvironment( ConfigurableEnvironment aEnv,
                                         String aKey,
                                         Object aValue ); static void removeFromEnvironment( ConfigurableEnvironment aEnv,
                                              String aKey ); static Map<String, Object> getOrCreatePropertySource( ConfigurableEnvironment aEnv,
                                                                 String aPropertySourceName ); static void setConversionService( ConversionService aConversionService ); static Collection<String> getPropertyNamesStartingWith( ConfigurableEnvironment aEnv,
                                                                   String aKeyPrefix ); static Collection<String> getAllPropertyNames( ConfigurableEnvironment aEnv ); static Collection<String> getAllPropertyNames( PropertySource<?> aPropSource ); static final String PROP_SOURCE_NAME_CMD_LINE; static final String KEY_PROP_OUTPUT_DIR; }