/** * Stuck here for now ... don't want to introduce dependency on ProfilesMatcher into * AnnotatedProperties ... */ public static AnnotatedProperties applyProfiles( AnnotatedProperties properties, Set activeProfiles) { AnnotatedProperties applied = new AnnotatedProperties(); for (Iterator i = properties.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry) i.next(); String key = (String) entry.getKey(); String value = (String) entry.getValue(); Annotations annotations = properties.getAnnotation(key); if (key.startsWith("[")) { int index = key.indexOf("]"); if (index != -1) { Set profiles = new HashSet(Strings.commaSepList(key.substring(1, index))); ProfilesMatcher profilesMatcher = new ProfilesMatcher(); if (profilesMatcher.matches(profiles, activeProfiles)) { applied.setProperty(key.substring(index + 1), value, annotations); } } } else { applied.setProperty(key, value, annotations); } } return applied; }