private String resolveName(Descriptor descriptor) { return Optional.ofNullable(descriptor.getClass().getAnnotation(Symbol.class)) .map(s -> s.value()[0]) .orElseGet(() -> { /* TODO: extract Descriptor parameter type such that DescriptorImpl extends Descriptor<XX> returns XX. * Then, if `baseClass == fooXX` we get natural name `foo`. */ return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, descriptor.getKlass().toJavaClass().getSimpleName()); }); } }
@Override public String getName() { final Class c = category.getClass(); final Symbol symbol = (Symbol) c.getAnnotation(Symbol.class); if (symbol != null) return symbol.value()[0]; String name = c.getSimpleName(); name = StringUtils.remove(name, "Global"); name = StringUtils.remove(name, "Configuration"); name = StringUtils.remove(name, "Category"); return name.toLowerCase(); }
/** * Get a configurator name. * @return short name for this component when used in a configuration.yaml file */ @Nonnull default String getName() { final Symbol annotation = getTarget().getAnnotation(Symbol.class); if (annotation != null) return annotation.value()[0]; return normalize(getTarget().getSimpleName()); }
symbols.addAll(Arrays.asList(s.value()));
/** * Returns the {@link Symbol} name of this tool. * * @return the name of this tool, or "undefined" if no symbol has been defined */ public String getSymbolName() { Symbol annotation = getClass().getAnnotation(Symbol.class); if (annotation != null) { String[] symbols = annotation.value(); if (symbols.length > 0) { return symbols[0]; } } return "unknownSymbol"; }
private String resolveName(Descriptor descriptor) { return Optional.ofNullable(descriptor.getClass().getAnnotation(Symbol.class)) .map(s -> s.value()[0]) .orElseGet(() -> { /* TODO: extract Descriptor parameter type such that DescriptorImpl extends Descriptor<XX> returns XX. * Then, if `baseClass == fooXX` we get natural name `foo`. */ return CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_CAMEL, descriptor.getKlass().toJavaClass().getSimpleName()); }); } }
@Override public String getName() { final Class c = category.getClass(); final Symbol symbol = (Symbol) c.getAnnotation(Symbol.class); if (symbol != null) return symbol.value()[0]; String name = c.getSimpleName(); name = StringUtils.remove(name, "Global"); name = StringUtils.remove(name, "Configuration"); name = StringUtils.remove(name, "Category"); return name.toLowerCase(); }
/** * Get a configurator name. * @return short name for this component when used in a configuration.yaml file */ @Nonnull default String getName() { final Symbol annotation = getTarget().getAnnotation(Symbol.class); if (annotation != null) return annotation.value()[0]; return normalize(getTarget().getSimpleName()); }
private static String symbolFromDescriptor(Descriptor d) { Symbol s = d.getClass().getAnnotation(Symbol.class); if (s != null) { return s.value()[0]; } return null; }
symbols.addAll(Arrays.asList(s.value()));