Java Code Examples for com.fasterxml.jackson.databind.DatabindContext#constructSpecializedType()

The following examples show how to use com.fasterxml.jackson.databind.DatabindContext#constructSpecializedType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ParameterTypeIdResolver.java    From eventeum with Apache License 2.0 5 votes vote down vote up
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    Class<?> subType = null;

    if (id.endsWith("[]")) {
        subType = ArrayParameter.class;
    } else if (id.startsWith("byte") || id.equals("string") || id.equals("address")) {
        subType = StringParameter.class;
    } else if (id.startsWith("uint") || id.startsWith("int") || id.startsWith("bool")) {
        subType = NumberParameter.class;
    }
    return context.constructSpecializedType(superType, subType);
}
 
Example 2
Source File: CredentialTypeResolver.java    From hono with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public JavaType typeFromId(final DatabindContext context, final String id) {
    switch (id) {
    case PasswordCredential.TYPE:
        return context.constructSpecializedType(this.baseType, PasswordCredential.class);
    case PskCredential.TYPE:
        return context.constructSpecializedType(this.baseType, PskCredential.class);
    case X509CertificateCredential.TYPE:
        return context.constructSpecializedType(this.baseType, X509CertificateCredential.class);
    default:
        return context.constructSpecializedType(this.baseType, GenericCredential.class);
    }
}
 
Example 3
Source File: TypeIdResolverStructure.java    From tutorials with MIT License 5 votes vote down vote up
@Override
public JavaType typeFromId(DatabindContext context, String id) {
    Class<?> subType = null;
    switch (id) {
    case "bean1":
        subType = FirstBean.class;
        break;
    case "bean2":
        subType = LastBean.class;
    }
    return context.constructSpecializedType(superType, subType);
}