protected String extractTypeLabel(Class<?> type) { // TODO: get rid of Jackson annotations dependency .. devise our own that reflect Bootique style of config factory // subclassing... JsonTypeName typeName = type.getAnnotation(JsonTypeName.class); return typeName != null ? typeName.value() : null; }
@Override public String findTypeName(AnnotatedClass ac) { JsonTypeName tn = _findAnnotation(ac, JsonTypeName.class); return (tn == null) ? null : tn.value(); }
@Test public void testStringResolve() throws IOException { LoadSpec loadSpec = mapper.readValue(value, LoadSpec.class); Assert.assertEquals(expectedId, loadSpec.getClass().getAnnotation(JsonTypeName.class).value()); } }
static String name(Class<?> type) { final JsonTypeName name = type.getAnnotation(JsonTypeName.class); if (name != null) { return name.value(); } return type.getSimpleName(); }
protected String extractTypeLabel(Class<?> type) { // TODO: get rid of Jackson annotations dependency .. devise our own that reflect Bootique style of config factory // subclassing... JsonTypeName typeName = type.getAnnotation(JsonTypeName.class); return typeName != null ? typeName.value() : null; }
/** * Use the JsonTypeName annotation to lookup the given message type name */ public static final String getMessageType(Class<? extends MessageObject> cls) { JsonTypeName typeName = cls.getAnnotation(JsonTypeName.class); if (typeName == null) throw new RuntimeException("The message " + cls + " is not annotated with it's type name!"); return typeName.value(); }
/** Return the name of type for appender. */ @JsonIgnore public String getType() { Class<? extends ModuleBase> clazz = this.getClass(); return (clazz.isAnnotationPresent(JsonTypeName.class) ? clazz.getAnnotation(JsonTypeName.class).value() : clazz.getName()); }
/** Return the name of type for appender. */ @JsonIgnore public String getType() { Class<? extends AppenderBase> clazz = this.getClass(); return (clazz.isAnnotationPresent(JsonTypeName.class) ? clazz.getAnnotation(JsonTypeName.class).value() : clazz.getName()); }
/** Return the name of type for appender. */ @JsonIgnore public String getType() { Class<? extends AppenderBase> clazz = this.getClass(); return (clazz.isAnnotationPresent(JsonTypeName.class) ? clazz.getAnnotation(JsonTypeName.class).value() : clazz.getName()); }
@Override public String findTypeName(AnnotatedClass ac) { JsonTypeName tn = _findAnnotation(ac, JsonTypeName.class); return (tn == null) ? null : tn.value(); }
@Override public String findTypeName(AnnotatedClass ac) { JsonTypeName tn = _findAnnotation(ac, JsonTypeName.class); return (tn == null) ? null : tn.value(); }
@Override public String findTypeName(AnnotatedClass ac) { JsonTypeName tn = ac.getAnnotation(JsonTypeName.class); return (tn == null) ? null : tn.value(); }
private String getTypeLabel(Class<? extends ManagedDataSourceFactory> factoryType) { // TODO: see TODO in ConfigMetadataCompiler ... at least maybe create a public API for this in Bootique to // avoid parsing annotations inside the modules... JsonTypeName typeName = factoryType.getAnnotation(JsonTypeName.class); if (typeName == null) { throw new BootiqueException(1, "Invalid ManagedDataSourceFactory: " + factoryType.getName() + ". Not annotated with @JsonTypeName."); } return typeName.value(); }
@Override public String findTypeName(AnnotatedClass ac) { JsonTypeName tn = _findAnnotation(ac, JsonTypeName.class); return (tn == null) ? null : tn.value(); }
@Override public String findTypeName(AnnotatedClass ac) { JsonTypeName tn = _findAnnotation(ac, JsonTypeName.class); return (tn == null) ? null : tn.value(); }
@Override public String findTypeName(AnnotatedClass ac) { JsonTypeName tn = ac.getAnnotation(JsonTypeName.class); return (tn == null) ? null : tn.value(); }
public String getName(JavaType type) { Class<?> rawClass = type.getRawClass(); JsonTypeName typeName = rawClass.getAnnotation(JsonTypeName.class); if (typeName != null) { return typeName.value(); } else { return getName(rawClass); } }
/** Create and return substitutions for names of modules. * @return * @throws InitializationException */ private static Map<String, String> findModules() throws InitializationException { List<Class<?>> modules = BillingUtils.getModuleClassList(); Map<String, String> substitute = new HashMap<>(); for (Class<?> module : modules) { ModuleType type = BillingUtils.getModuleType(module); JsonTypeName typeName = module.getAnnotation(JsonTypeName.class); if (typeName != null) { String typeNames = substitute.get(type.toString() + "s"); typeNames = (typeNames == null ? typeName.value() : typeNames + ", " + typeName.value()); substitute.put(type.toString() + "s", typeNames); } } return substitute; }
public String getTypeIdValue() { List<JsonSubTypes> subTypes = AnnotationUtils.getAnnotations(JsonSubTypes.class, this); if (!subTypes.isEmpty()) { final Types typeUtils = env.getTypeUtils(); for (JsonSubTypes.Type type : subTypes.get(0).value()) { DecoratedTypeMirror decoratedType = Annotations.mirrorOf(type::value, env); if (typeUtils.isSameType(asType(), decoratedType.getDelegate())) { if (!type.name().isEmpty()) { return type.name(); } } } } JsonTypeName typeName = getAnnotation(JsonTypeName.class); if (typeName != null && !typeName.value().isEmpty()) { return typeName.value(); } return isAbstract() ? "..." : getSimpleName().toString(); }