Refine search
@Override public ReferenceType withContentTypeHandler(Object h) { if (h == _referencedType.<Object>getTypeHandler()) { return this; } return new ReferenceType(_class, _bindings, _superClass, _superInterfaces, _referencedType.withTypeHandler(h), _anchorType, _valueHandler, _typeHandler, _asStatic); }
public ReferenceTypeSerializer(ReferenceType fullType, boolean staticTyping, TypeSerializer vts, JsonSerializer<Object> ser) { super(fullType); _referredType = fullType.getReferencedType(); _property = null; _valueTypeSerializer = vts; _valueSerializer = ser; _unwrapper = null; _suppressableValue = null; _suppressNulls = false; _dynamicSerializers = PropertySerializerMap.emptyForProperties(); }
@Override public StringBuilder getGenericSignature(StringBuilder sb) { _classSignature(_class, sb, false); sb.append('<'); sb = _referencedType.getGenericSignature(sb); sb.append(">;"); return sb; }
/** * @since 2.7 */ public JsonSerializer<?> findReferenceSerializer(SerializerProvider prov, ReferenceType refType, BeanDescription beanDesc, boolean staticTyping) throws JsonMappingException { JavaType contentType = refType.getContentType(); TypeSerializer contentTypeSerializer = contentType.getTypeHandler(); final SerializationConfig config = prov.getConfig(); if (contentTypeSerializer == null) { contentTypeSerializer = createTypeSerializer(config, contentType); } JsonSerializer<Object> contentSerializer = contentType.getValueHandler(); for (Serializers serializers : customSerializers()) { JsonSerializer<?> ser = serializers.findReferenceSerializer(config, refType, beanDesc, contentTypeSerializer, contentSerializer); if (ser != null) { return ser; } } if (refType.isTypeOrSubTypeOf(AtomicReference.class)) { return buildAtomicReferenceSerializer(prov, refType, beanDesc, staticTyping, contentTypeSerializer, contentSerializer); } return null; }
@Override public JavaType modifyType(JavaType type, Type jdkType, TypeBindings bindings, TypeFactory typeFactory) { if (type.isReferenceType() || type.isContainerType()) { return type; } final Class<?> raw = type.getRawClass(); // First: make Multimaps look more Map-like if (raw == Multimap.class) { return MapLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0), type.containedTypeOrUnknown(1)); } if (raw == Optional.class) { return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } return type; } }
@Override public JavaType modifyType(JavaType type, Type jdkType, TypeBindings bindings, TypeFactory typeFactory) { final Class<?> raw = type.getRawClass(); if (Seq.class.isAssignableFrom(raw) && CharSeq.class != raw) { return CollectionLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (Set.class.isAssignableFrom(raw)) { return CollectionLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (PriorityQueue.class.isAssignableFrom(raw)) { return CollectionLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (Map.class.isAssignableFrom(raw)) { return MapLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0), type.containedTypeOrUnknown(1)); } if (Multimap.class.isAssignableFrom(raw)) { return MapLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0), type.containedTypeOrUnknown(1)); } if (Lazy.class.isAssignableFrom(raw)) { return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } if (Option.class.isAssignableFrom(raw)) { return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } return type; } }
@Override public ReferenceType withContentValueHandler(Object h) { if (h == _referencedType.<Object>getValueHandler()) { return this; } JavaType refdType = _referencedType.withValueHandler(h); return new ReferenceType(_class, _bindings, _superClass, _superInterfaces, refdType, _anchorType, _valueHandler, _typeHandler, _asStatic); }
@Override public JavaType withContentType(JavaType contentType) { if (_referencedType == contentType) { return this; } return new ReferenceType(_class, _bindings, _superClass, _superInterfaces, contentType, _anchorType, _valueHandler, _typeHandler, _asStatic); }
@Override public ReferenceType withStaticTyping() { if (_asStatic) { return this; } return new ReferenceType(_class, _bindings, _superClass, _superInterfaces, _referencedType.withStaticTyping(), _anchorType, _valueHandler, _typeHandler, true); }
throws JsonMappingException final JavaType contentType = refType.getReferencedType(); JsonInclude.Value inclV = _findInclusionWithContent(prov, beanDesc, contentType, AtomicReference.class); valueToSuppress = contentType.isReferenceType() ? MapSerializer.MARKER_FOR_EMPTY : null; break;
@Override public JsonSerializer<?> findReferenceSerializer(SerializationConfig config, ReferenceType refType, BeanDescription beanDesc, TypeSerializer contentTypeSerializer, JsonSerializer<Object> contentValueSerializer) { final Class<?> raw = refType.getRawClass(); if (Optional.class.isAssignableFrom(raw)) { boolean staticTyping = (contentTypeSerializer == null) && config.isEnabled(MapperFeature.USE_STATIC_TYPING); return new GuavaOptionalSerializer(refType, staticTyping, contentTypeSerializer, contentValueSerializer); } return null; }
void createInvoice() { try { Invoice invoice = new Invoice(); ReferenceType customerReferenceType = new ReferenceType(); customerReferenceType.setName("abc"); customerReferenceType.setValue("2"); invoice.setCustomerRef(customerReferenceType); Line line = new Line(); line.setAmount(new BigDecimal(15)); line.setDetailType(LineDetailTypeEnum.SALES_ITEM_LINE_DETAIL); SalesItemLineDetail salesItemLineDetail = new SalesItemLineDetail(); ReferenceType referenceType = customerReferenceType; referenceType.setName("Hours"); referenceType.setValue("2"); salesItemLineDetail.setItemRef(referenceType); line.setSalesItemLineDetail(salesItemLineDetail); List linesList = new ArrayList<Line>(); linesList.add(line); invoice.setLine(linesList); this.service.add(invoice); } catch (FMSException e) { e.printStackTrace(); }
/** * @since 2.6 */ public JavaType constructReferenceType(Class<?> rawType, JavaType referredType) { return ReferenceType.construct(rawType, null, // no bindings null, null, // or super-class, interfaces? referredType); }
@Override public String toString() { return new StringBuilder(40) .append("[reference type, class ") .append(buildCanonicalName()) .append('<') .append(_referencedType) .append('>') .append(']') .toString(); }
@Override public StringBuilder getErasedSignature(StringBuilder sb) { return _classSignature(_class, sb, true); }
@Override public JavaType modifyType(JavaType type, Type jdkType, TypeBindings bindings, TypeFactory typeFactory) { if (type.isReferenceType() || type.isContainerType()) { return type; } final Class<?> raw = type.getRawClass(); // First: make Multimaps look more Map-like if (raw == Multimap.class) { return MapLikeType.upgradeFrom(type, type.containedTypeOrUnknown(0), type.containedTypeOrUnknown(1)); } if (raw == Optional.class) { return ReferenceType.upgradeFrom(type, type.containedTypeOrUnknown(0)); } return type; } }
throws JsonMappingException JavaType contentType = type.getContentType(); JsonDeserializer<Object> contentDeser = contentType.getValueHandler(); final DeserializationConfig config = ctxt.getConfig(); TypeDeserializer contentTypeDeser = contentType.getTypeHandler(); if (contentTypeDeser == null) { // or if not, may be able to find: contentTypeDeser = findTypeDeserializer(config, contentType); if (type.isTypeOrSubTypeOf(AtomicReference.class)) { Class<?> rawType = type.getRawClass(); ValueInstantiator inst; if (rawType == AtomicReference.class) {
@Override public ReferenceType withContentValueHandler(Object h) { if (h == _referencedType.<Object>getValueHandler()) { return this; } JavaType refdType = _referencedType.withValueHandler(h); return new ReferenceType(_class, _bindings, _superClass, _superInterfaces, refdType, _anchorType, _valueHandler, _typeHandler, _asStatic); }
@Override public ReferenceType withTypeHandler(Object h) { if (h == _typeHandler) { return this; } return new ReferenceType(_class, _bindings, _superClass, _superInterfaces, _referencedType, _anchorType, _valueHandler, h, _asStatic); }
@Override public ReferenceType withStaticTyping() { if (_asStatic) { return this; } return new ReferenceType(_class, _bindings, _superClass, _superInterfaces, _referencedType.withStaticTyping(), _anchorType, _valueHandler, _typeHandler, true); }