private static List < Policy > createPolicies ( final String property ) { if ( property == null || property . isEmpty ( ) ) { return Collections . < Policy > singletonList ( new StartupPolicy ( null ) ) ; } else { ServiceLoader < Policy > loader = new ServiceLoader < Policy > ( Policy . class , String . class ) ; List < Policy > policies = new ArrayList < Policy > ( ) ; for ( String entry : property . split ( "," ) ) { int separator = entry . indexOf ( ' ' ) ; if ( separator == - 1 ) { policies . add ( loader . create ( entry , ( String ) null ) ) ; } else { String name = entry . substring ( 0 , separator ) . trim ( ) ; String argument = entry . substring ( separator + 1 ) . trim ( ) ; policies . add ( loader . create ( name , argument ) ) ; } } return policies ; } }
Creates policies from a nullable string .