Java Code Examples for com.fasterxml.jackson.databind.JavaType#hasRawClass()

The following examples show how to use com.fasterxml.jackson.databind.JavaType#hasRawClass() . 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: UnknownPluginHandler.java    From milkman with MIT License 6 votes vote down vote up
@Override
public JavaType handleUnknownTypeId(DeserializationContext ctxt, JavaType baseType, String subTypeId,
		TypeIdResolver idResolver, String failureMsg) throws IOException {
	if (baseType.hasRawClass(RequestAspect.class)) {
		log.error("Unknown AspectType found: " + subTypeId + ".");
		return ReferenceType.construct(UnknownRequestAspect.class);
	}
	if (baseType.hasRawClass(OptionsObject.class)) {
		log.error("Unknown OptionsObject found: " + subTypeId + ".");
		return ReferenceType.construct(UnknownOptionsObject.class);
	}
	if (baseType.hasRawClass(RequestContainer.class)) {
		log.error("Unknown RequestContainer found: " + subTypeId + ".");
		return ReferenceType.construct(UnknownRequestContainer.class);
	}
	return null;
}
 
Example 2
Source File: JavaUtilCollectionsDeserializers.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static JsonDeserializer<?> findForCollection(DeserializationContext ctxt,
        JavaType type)
    throws JsonMappingException
{
    JavaUtilCollectionsConverter conv;

    // 10-Jan-2017, tatu: Some types from `java.util.Collections`/`java.util.Arrays` need bit of help...
    if (type.hasRawClass(CLASS_AS_ARRAYS_LIST)) {
        conv = converter(TYPE_AS_LIST, type, List.class);
    } else if (type.hasRawClass(CLASS_SINGLETON_LIST)) {
        conv = converter(TYPE_SINGLETON_LIST, type, List.class);
    } else if (type.hasRawClass(CLASS_SINGLETON_SET)) {
        conv = converter(TYPE_SINGLETON_SET, type, Set.class);
    } else if (type.hasRawClass(CLASS_UNMODIFIABLE_LIST)) {
        conv = converter(TYPE_UNMODIFIABLE_LIST, type, List.class);
    } else if (type.hasRawClass(CLASS_UNMODIFIABLE_SET)) {
        conv = converter(TYPE_UNMODIFIABLE_SET, type, Set.class);
    } else {
        return null;
    }
    return new StdDelegatingDeserializer<Object>(conv);
}
 
Example 3
Source File: JavaUtilCollectionsDeserializers.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
public static JsonDeserializer<?> findForMap(DeserializationContext ctxt,
        JavaType type)
    throws JsonMappingException
{
    JavaUtilCollectionsConverter conv;

    // 10-Jan-2017, tatu: Some types from `java.util.Collections`/`java.util.Arrays` need bit of help...
    if (type.hasRawClass(CLASS_SINGLETON_MAP)) {
        conv = converter(TYPE_SINGLETON_MAP, type, Map.class);
    } else if (type.hasRawClass(CLASS_UNMODIFIABLE_MAP)) {
        conv = converter(TYPE_UNMODIFIABLE_MAP, type, Map.class);
    } else {
        return null;
    }
    return new StdDelegatingDeserializer<Object>(conv);
}
 
Example 4
Source File: BeanUtil.java    From jackson-modules-base with Apache License 2.0 6 votes vote down vote up
private static void _addSuperTypes(JavaType type, Class<?> endBefore,
        List<JavaType> result, boolean addClassItself)
{
    if ((type == null) || type.isJavaLangObject() || type.hasRawClass(endBefore)) {
        return;
    }
    if (addClassItself) {
        // 28-Nov-2015, tatu: Should we check for differently parameterized generic types?
        //   For now, assume it's not a significant problem
        if (result.contains(type)) { // already added, no need to check supers
            return;
        }
        result.add(type);
    }
    for (JavaType intCls : type.getInterfaces()) {
        _addSuperTypes(intCls, endBefore, result, true);
    }
    _addSuperTypes(type.getSuperClass(), endBefore, result, true);
}
 
Example 5
Source File: InterledgerDeserializers.java    From quilt with Apache License 2.0 5 votes vote down vote up
@Override
public JsonDeserializer<?> findBeanDeserializer(
    JavaType type, DeserializationConfig config, BeanDescription beanDesc
) {
  if (type.hasRawClass(InterledgerAddress.class)) {
    return new InterledgerAddressDeserializer();
  }

  if (type.hasRawClass(InterledgerAddressPrefix.class)) {
    return new InterledgerAddressPrefixDeserializer();
  }

  if (type.hasRawClass(InterledgerCondition.class)) {
    return new ConditionDeserializer(cryptoConditionEncoding);
  }

  if (type.hasRawClass(InterledgerFulfillment.class)) {
    return new FulfillmentDeserializer(cryptoConditionEncoding);
  }

  if (type.hasRawClass(SharedSecret.class)) {
    return new SharedSecretDeserializer();
  }

  if (type.hasRawClass(LinkId.class)) {
    return new LinkIdDeserializer();
  }

  if (type.hasRawClass(LinkType.class)) {
    return new LinkTypeDeserializer();
  }

  return null;
}
 
Example 6
Source File: BatfishThirdPartyDeserializers.java    From batfish with Apache License 2.0 5 votes vote down vote up
@Override
public @Nullable JsonDeserializer<?> findBeanDeserializer(
    JavaType type, DeserializationConfig config, BeanDescription beanDesc) {
  if (type.hasRawClass(RangeSet.class)) {
    return new RangeSetDeserializer(type);
  }
  return null;
}
 
Example 7
Source File: ClassUtil.java    From lams with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Method that will find all sub-classes and implemented interfaces
 * of a given class or interface. Classes are listed in order of
 * precedence, starting with the immediate super-class, followed by
 * interfaces class directly declares to implemented, and then recursively
 * followed by parent of super-class and so forth.
 * Note that <code>Object.class</code> is not included in the list
 * regardless of whether <code>endBefore</code> argument is defined or not.
 *
 * @param endBefore Super-type to NOT include in results, if any; when
 *    encountered, will be ignored (and no super types are checked).
 *
 * @since 2.7
 */
public static List<JavaType> findSuperTypes(JavaType type, Class<?> endBefore,
        boolean addClassItself) {
    if ((type == null) || type.hasRawClass(endBefore) || type.hasRawClass(Object.class)) {
        return Collections.emptyList();
    }
    List<JavaType> result = new ArrayList<JavaType>(8);
    _addSuperTypes(type, endBefore, result, addClassItself);
    return result;
}