List of usage examples for com.fasterxml.jackson.databind.type TypeFactory unknownType
public static JavaType unknownType()
From source file:javaslang.jackson.datatype.deserialize.MaplikeDeserializer.java
private static MapLikeType mapLike(JavaType type, DeserializationContext ctxt) { JavaType keyType = type.containedTypeCount() > 0 ? type.containedType(0) : TypeFactory.unknownType(); JavaType valueType = type.containedTypeCount() > 1 ? type.containedType(1) : TypeFactory.unknownType(); return ctxt.getTypeFactory().constructMapLikeType(type.getRawClass(), keyType, valueType); }
From source file:com.kaaprotech.satu.jackson.SatuTypeModifier.java
@SuppressWarnings("unused") @Override//from www .ja va 2 s . co m public JavaType modifyType(JavaType type, Type jdkType, TypeBindings context, TypeFactory typeFactory) { final Class<?> raw = type.getRawClass(); if (ImmutableMap.class.isAssignableFrom(raw)) { JavaType keyType = type.containedType(0); JavaType contentType = type.containedType(1); if (keyType == null) { keyType = TypeFactory.unknownType(); } if (contentType == null) { contentType = TypeFactory.unknownType(); } return typeFactory.constructMapType(AbstractImmutableMap.class, keyType, contentType); } if (ImmutableSet.class.isAssignableFrom(raw)) { JavaType contentType = type.containedType(0); if (contentType == null) { contentType = TypeFactory.unknownType(); } return typeFactory.constructCollectionType(AbstractImmutableSet.class, contentType); } return type; }
From source file:javaslang.jackson.datatype.deserialize.CharSeqDeserializer.java
@Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { deserializer = ctxt.findContextualValueDeserializer(TypeFactory.unknownType(), null); }
From source file:javaslang.jackson.datatype.deserialize.ValueDeserializer.java
@Override public void resolve(DeserializationContext ctxt) throws JsonMappingException { for (int i = 0; i < typeCount; i++) { if (i < javaType.containedTypeCount()) { deserializers.add(ctxt.findRootValueDeserializer(javaType.containedType(i))); } else {//w ww .j av a2 s .c o m deserializers.add(ctxt.findContextualValueDeserializer(TypeFactory.unknownType(), null)); } } }
From source file:com.almende.eve.monitor.ResultMonitorFactory.java
@Access(AccessType.SELF) @Override//from ww w. ja va 2 s . c om public final void doPoll(@Name("monitorId") final String monitorId) throws JSONRPCException, IOException { final ResultMonitor monitor = getMonitorById(monitorId); if (monitor != null) { if (monitor.getUrl() == null || monitor.getMethod() == null) { LOG.warning("Monitor data invalid:" + monitor); } final Object result = myAgent.send(monitor.getUrl(), monitor.getMethod(), JOM.getInstance().readTree(monitor.getParams()), TypeFactory.unknownType()); if (monitor.getCallbackMethod() != null) { final ObjectNode params = JOM.createObjectNode(); params.put("result", JOM.getInstance().writeValueAsString(result)); myAgent.send(URI.create("local:" + myAgent.getId()), monitor.getCallbackMethod(), params); } if (monitor.hasCache()) { monitor.getCache().store(result); } } }
From source file:ch.ralscha.extdirectspring.util.ParametersResolver.java
private Object convertValue(Object value, ParameterInfo methodParameter) { if (value != null) { Class<?> rawType = methodParameter.getType(); if (rawType.equals(value.getClass())) { return value; } else if (this.conversionService.canConvert(TypeDescriptor.forObject(value), methodParameter.getTypeDescriptor())) { try { return this.conversionService.convert(value, TypeDescriptor.forObject(value), methodParameter.getTypeDescriptor()); } catch (ConversionFailedException e) { // ignore this exception for collections and arrays. // try to convert the value with jackson TypeFactory typeFactory = this.jsonHandler.getMapper().getTypeFactory(); if (methodParameter.getTypeDescriptor().isCollection()) { JavaType elemType = typeFactory.constructType( methodParameter.getTypeDescriptor().getElementTypeDescriptor().getType()); TypeVariable<?>[] vars = rawType.getTypeParameters(); TypeBindings bindings; if ((vars == null) || (vars.length != 1)) { bindings = TypeBindings.emptyBindings(); } else { bindings = TypeBindings.create(rawType, elemType); }// w w w. ja va 2 s .c o m JavaType superClass = null; Class<?> parent = rawType.getSuperclass(); if (parent != null) { superClass = TypeFactory.unknownType(); } JavaType type = CollectionType.construct(rawType, bindings, superClass, null, elemType); return this.jsonHandler.convertValue(value, type); } else if (methodParameter.getTypeDescriptor().isArray()) { JavaType type = typeFactory.constructArrayType( methodParameter.getTypeDescriptor().getElementTypeDescriptor().getType()); return this.jsonHandler.convertValue(value, type); } throw e; } } else { return this.jsonHandler.convertValue(value, rawType); } } else if (methodParameter.isJavaUtilOptional()) { return javaUtilOptionalEmpty; } return null; }