/** * Emits {@code modifiers} in the standard order. Modifiers in {@code implicitModifiers} will not * be emitted. */ public void emitModifiers(Set<Modifier> modifiers, Set<Modifier> implicitModifiers) throws IOException { if (modifiers.isEmpty()) return; for (Modifier modifier : EnumSet.copyOf(modifiers)) { if (implicitModifiers.contains(modifier)) continue; emitAndIndent(modifier.name().toLowerCase(Locale.US)); emitAndIndent(" "); } }
/** * Returns this modifier's name in lowercase. */ public String toString() { return name().toLowerCase(java.util.Locale.US); } }
/** * Returns this modifier's name in lowercase. */ public String toString() { return name().toLowerCase(java.util.Locale.US); } }
/** * Returns this modifier's name in lowercase. */ public String toString() { if (lowercase == null) { lowercase = name().toLowerCase(java.util.Locale.US); } return lowercase; } }
/** * Returns this modifier's name in lowercase. */ public String toString() { if (lowercase == null) { lowercase = name().toLowerCase(java.util.Locale.US); } return lowercase; } }
private String modifier(Modifier m) { return m == null ? "package" : m.name().toLowerCase(); }
protected Object getAccessLevel(Element e) { Set<Modifier> mods = e.getModifiers(); for (Modifier mod : MODS) { if(mods.contains(mod)) return mod.name().toLowerCase(); } return "default"; }
protected int getModifiers(ExecutableElement methodObject) { Set<javax.lang.model.element.Modifier> mods = methodObject.getModifiers(); int modifierTmp = 0; try { // TODO: gross for (javax.lang.model.element.Modifier mod : mods) { modifierTmp |= (Integer) Modifier.class.getField(mod.name()).get(null); } } catch (NoSuchFieldException|IllegalAccessException e) { throw new RuntimeException(e); } return modifierTmp; }
public static String stringify(Set<Modifier> modifiers) { return modifiers.stream() .sorted(Comparator.comparingInt(ModifierChanged::score)) .map(m -> m.name().toLowerCase()) .collect(Collectors.joining(" ")); }
public static String stringify(Set<Modifier> modifiers) { return modifiers.stream() .sorted(Comparator.comparingInt(ModifierChanged::score)) .map(m -> m.name().toLowerCase()) .collect(Collectors.joining(" ")); }
protected int getModifiers(ExecutableElement methodObject) { Set<javax.lang.model.element.Modifier> mods = methodObject.getModifiers(); int modifierTmp = 0; try { // TODO: gross for (javax.lang.model.element.Modifier mod : mods) { modifierTmp |= (Integer) Modifier.class.getField(mod.name()).get(null); } } catch (NoSuchFieldException|IllegalAccessException e) { throw new RuntimeException(e); } return modifierTmp; }
@Override public Optional<AccessInfo> apply(Modifier input) { return Enums.getIfPresent(AccessInfo.class, input.name()); } }
@Override public Optional<ModifierInfo> apply(Modifier input) { return Enums.getIfPresent(ModifierInfo.class, input.name()); } }
public static Optional<AccessInfo> fromJdk(Set<Modifier> modifiers) { return modifiers.stream() .map(m -> { try { AccessInfo accessInfo = AccessInfo.valueOf(m.name()); return Optional.of(accessInfo); } catch (IllegalArgumentException e) { return Optional.<AccessInfo> empty(); } }) .filter(Optional::isPresent) .map(Optional::get) .findFirst(); }
/** * Emits {@code modifiers} in the standard order. Modifiers in {@code implicitModifiers} will not * be emitted. */ public void emitModifiers(Set<Modifier> modifiers, Set<Modifier> implicitModifiers) throws IOException { if (modifiers.isEmpty()) return; for (Modifier modifier : EnumSet.copyOf(modifiers)) { if (implicitModifiers.contains(modifier)) continue; emitAndIndent(modifier.name().toLowerCase(Locale.US)); emitAndIndent(" "); } }
/** * Emits {@code modifiers} in the standard order. Modifiers in {@code implicitModifiers} will not * be emitted. */ public void emitModifiers(Set<Modifier> modifiers, Set<Modifier> implicitModifiers) throws IOException { if (modifiers.isEmpty()) return; for (Modifier modifier : EnumSet.copyOf(modifiers)) { if (implicitModifiers.contains(modifier)) continue; emitAndIndent(modifier.name().toLowerCase(Locale.US)); emitAndIndent(" "); } }
@Override public MethodModifiers getModifiers() { Set<Modifier> modifiers = method.getModifiers(); final MethodModifierValue[] values = new MethodModifierValue[modifiers .size()]; int index = 0; for (Modifier modifier : modifiers) { values[index++] = MethodModifierValue.valueOf(modifier.name()); } return new MethodModifiersBean(values); }
@Override public ConstructorModifiers getModifiers() { Set<Modifier> modifiers = constructor.getModifiers(); final ConstructorModifierValue[] values = new ConstructorModifierValue[modifiers .size()]; int index = 0; for (Modifier modifier : modifiers) { values[index++] = ConstructorModifierValue.valueOf(modifier.name()); } return new ConstructorModifiersBean(values); }
public static void appendModifiers(Block block, Set<Modifier> modifiers) { for (Modifier modifier : modifiers) { final String name = modifier.name().toLowerCase(); block.append(name).append(" "); } }
@Override public FieldModifiers getModifiers() { Set<Modifier> modifiers = field.getModifiers(); final FieldModifierValue[] values = new FieldModifierValue[modifiers.size()]; int index = 0; for (Modifier modifier : modifiers) { values[index++] = FieldModifierValue.valueOf(modifier.name()); } return new FieldModifiersBean(values); }