/** * Get the content of the requires attribute as a set of strings. * * @param model the model to query for required policy * @return set of policy requirements; empty set if nothing found */ public static Set<String> getRequires(Model model) { Set<String> requiredSet = new HashSet<String>(); String requires = model.getModelConfiguration().getAttribute(REQUIRES); if (requires != null) { for (String policy : requires.split(" ")) { requiredSet.add(policy); } } return requiredSet; }
/** * Set the content of the requires attribute for a given config model. * * @param model the model to set policy requirements on. * @param requiredSet the set of policy requirements. */ public static void setRequires(Model model, Set<String> requiredSet) { if (requiredSet == null || requiredSet.isEmpty()) { return; } Iterator<String> it = requiredSet.iterator(); String requires = it.next(); while (it.hasNext()) { requires += " " + it.next(); } model.getModelConfiguration().setAttribute(REQUIRES, requires); }