/** * @param name modifier name to parse * @param kinds if not empty, returns only a modifier that matches all of the kinds * @return Modifier that matches any of the kinds constraints */ public static Modifier parseModifier(String name, ModifierKind... kinds) { try { // Modifier modifier = Modifier.valueOf(name); Modifier modifier = mods.get(name); if (kinds.length == 0 || modifier == null) return modifier; for (ModifierKind kind : kinds) if (modifier.isA(kind)) return modifier; return kinds.length > 0 ? null : modifier; } catch (IllegalArgumentException ex) { return null; } }
public boolean isContainedBy(Collection<Modifier> modifiers) { Modifier alias = resolveAlias(); for (Modifier modifier : modifiers) if (modifier.resolveAlias().equals(alias)) return true; return false; }
public int countIn(Collection<Modifier> modifiers) { Modifier alias = resolveAlias(); int c = 0; for (Modifier modifier : modifiers) if (modifier.resolveAlias().equals(alias)) c++; return c; }
public Modifier resolveAlias() { if (alias == null) return this; return alias.resolveAlias(); }