ValueBuilder builder = module.instance().newValueBuilderWithState( valueType.primaryType(), propertyFunction( valueType.module(), namedValues ),
private Object deserializeStatefulAssociationValue( ModuleDescriptor module, StatefulAssociationValueType<?> valueType, Node xml ) { Optional<String> typeInfo = getTypeInfo( xml ); if( typeInfo.isPresent() ) { StatefulAssociationCompositeDescriptor descriptor = statefulCompositeDescriptorFor( module, typeInfo.get() ); if( descriptor == null ) { String typeInfoName = settings.getTypeInfoTagName(); throw new SerializationException( typeInfoName + ": " + typeInfo.get() + " could not be resolved while deserializing " + xml ); } valueType = descriptor.valueType(); } ValueBuilder builder = module.instance().newValueBuilderWithState( valueType.primaryType(), propertyFunction( valueType.module(), xml ), associationFunction( valueType.module(), xml ), manyAssociationFunction( valueType.module(), xml ), namedAssociationFunction( valueType.module(), xml ) ); return builder.newInstance(); }
@Override public <T extends HasIdentity> T toValue( Class<T> primaryType, T entityComposite ) { Objects.requireNonNull( primaryType ); if( entityComposite == null ) { return null; } Function<PropertyDescriptor, Object> propertyFunction = new ToValuePropertyMappingFunction( entityComposite ); Function<AssociationDescriptor, EntityReference> assocationFunction = new ToValueAssociationMappingFunction<>( entityComposite ); Function<AssociationDescriptor, Stream<EntityReference>> manyAssocFunction = new ToValueManyAssociationMappingFunction<>( entityComposite ); Function<AssociationDescriptor, Stream<Map.Entry<String, EntityReference>>> namedAssocFunction = new ToValueNameAssociationMappingFunction<>( entityComposite ); ToValueConverter converter = getConverter( ToValueConverter.class ); if( converter != null ) { propertyFunction = converter.properties( entityComposite, propertyFunction ); assocationFunction = converter.associations( entityComposite, assocationFunction ); manyAssocFunction = converter.manyAssociations( entityComposite, manyAssocFunction ); namedAssocFunction = converter.namedAssociations( entityComposite, namedAssocFunction ); } @SuppressWarnings( "unchecked" ) ValueBuilder<T> builder = module().instance().newValueBuilderWithState( primaryType, propertyFunction, assocationFunction, manyAssocFunction, namedAssocFunction ); return builder.newInstance(); }
private Object deserializeStatefulAssociationValue( ModuleDescriptor module, StatefulAssociationValueType<?> valueType, JsonObject json ) { String typeInfoName = settings.getTypeInfoPropertyName(); String typeInfo = json.getString( typeInfoName, null ); if( typeInfo != null ) { StatefulAssociationCompositeDescriptor descriptor = statefulCompositeDescriptorFor( module, typeInfo ); if( descriptor == null ) { throw new SerializationException( typeInfoName + ": " + typeInfo + " could not be resolved while deserializing " + json ); } valueType = descriptor.valueType(); } ValueBuilder builder = module.instance().newValueBuilderWithState( valueType.primaryType(), propertyFunction( valueType.module(), json ), associationFunction( valueType.module(), json ), manyAssociationFunction( valueType.module(), json ), namedAssociationFunction( valueType.module(), json ) ); return builder.newInstance(); }
private Object deserializeStatefulAssociationValue( ModuleDescriptor module, StatefulAssociationValueType<?> valueType, JsonObject json ) { String typeInfoName = settings.getTypeInfoPropertyName(); String typeInfo = json.getString( typeInfoName, null ); if( typeInfo != null ) { StatefulAssociationCompositeDescriptor descriptor = statefulCompositeDescriptorFor( module, typeInfo ); if( descriptor == null ) { throw new SerializationException( typeInfoName + ": " + typeInfo + " could not be resolved while deserializing " + json ); } valueType = descriptor.valueType(); } ValueBuilder builder = module.instance().newValueBuilderWithState( valueType.primaryType(), propertyFunction( valueType.module(), json ), associationFunction( valueType.module(), json ), manyAssociationFunction( valueType.module(), json ), namedAssociationFunction( valueType.module(), json ) ); return builder.newInstance(); }