public static Map < String , String > extractFromPropertiesAsMap ( String prefix , Properties properties ) { Map < String , String > ret = new HashMap <> ( ) ; Enumeration names = properties . propertyNames ( ) ; String prefixP = prefix + "." ; while ( names . hasMoreElements ( ) ) { String propName = ( String ) names . nextElement ( ) ; if ( propMatchesPrefix ( prefixP , propName ) ) { String mapKey = propName . substring ( prefixP . length ( ) ) ; if ( PROPERTY_COMBINE_POLICY_SUFFIX . equals ( mapKey ) ) { continue ; } ret . put ( mapKey , properties . getProperty ( propName ) ) ; } } return ret . size ( ) > 0 ? ret : null ; }
Extract part of given properties as a map . The given prefix is used to find the properties the rest of the property name is used as key for the map .