Package org.qi4j.api.type

Examples of org.qi4j.api.type.ValueCompositeType


                        final CompositeMethodsModel compositeMethodsModel
    )
    {
        super( compositeType, types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );

        valueType = new ValueCompositeType( this );
    }
View Full Code Here


                       final CompositeMethodsModel compositeMethodsModel
    )
    {
        super( types, visibility, metaInfo, mixinsModel, stateModel, compositeMethodsModel );

        valueType = new ValueCompositeType( this );
    }
View Full Code Here

    @Test
    public void givenListOfValueCompositesAndNullElementWhenSerializingAndDeserializingExpectEquals()
        throws Exception
    {
        String output = valueSerialization.serialize( valueCompositesList() );
        ValueCompositeType valueType = module.valueDescriptor( SomeValue.class.getName() ).valueType();
        CollectionType collectionType = new CollectionType( List.class, valueType );
        List<SomeValue> value = valueSerialization.deserialize( collectionType, output );
        assertEquals( valueCompositesList(), value );
    }
View Full Code Here

    }

    private <T> T deserializeNodeValueComposite( ValueType valueType, InputNodeType inputNode )
        throws Exception
    {
        ValueCompositeType valueCompositeType = (ValueCompositeType) valueType;
        Class<?> valueBuilderType = first( valueCompositeType.types() );
        String typeInfo = this.<String>getObjectFieldValue(
            inputNode,
            "_type",
            this.<String>buildDeserializeInputNodeFunction( new ValueType( String.class ) ) );
        TREE_PARSING_LOG.trace(
View Full Code Here

        throws Exception
    {
        if( isObjectValue( inputNode ) )
        {
            // Attempt ValueComposite deserialization
            ValueCompositeType valueCompositeType;
            if( objectHasField( inputNode, "_type" ) ) // with _type info
            {
                String typeInfo = this.<String>getObjectFieldValue(
                    inputNode,
                    "_type",
                    this.<String>buildDeserializeInputNodeFunction( new ValueType( String.class ) ) );
                TREE_PARSING_LOG.trace(
                    "In deserializeNodeGuessed(), getObjectFieldValue( {} ) returned '{}'",
                    inputNode, typeInfo );
                ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( typeInfo );
                if( valueDescriptor == null )
                {
                    throw new ValueSerializationException( "Specified value type could not be resolved: " + typeInfo );
                }
                valueCompositeType = valueDescriptor.valueType();
                TREE_PARSING_LOG.debug(
                    "Overriding {} with {} as defined in _type field.",
                    valueType, valueCompositeType );
            }
            else // without _type info
            {
                ValueDescriptor valueDescriptor = valuesModule().valueDescriptor( first( valueType.types() ).getName() );
                if( valueDescriptor == null )
                {
                    throw new ValueSerializationException( "Don't know how to deserialize " + inputNode );
                }
                valueCompositeType = valueDescriptor.valueType();
                TREE_PARSING_LOG.debug(
                    "Overriding {} with {} as found in available ValueComposites.",
                    valueType, valueCompositeType );
            }
            Class<?> valueBuilderType = first( valueCompositeType.types() );
            return deserializeValueComposite( valueCompositeType, valueBuilderType, inputNode );
        }
        // Last resort : base64 java deserialization
        return (T) deserializeBase64Serialized( inputNode );
    }
View Full Code Here

      if (response.getEntity().getMediaType().equals( MediaType.APPLICATION_JSON))
      {
         if (ValueComposite.class.isAssignableFrom( resultType ))
         {
            String jsonValue = response.getEntityAsText();
            ValueCompositeType valueType = module.valueDescriptor( resultType.getName() ).valueType();
            return valueDeserializer.deserialize( valueType, jsonValue );
         }
         else if (resultType.equals(Form.class))
         {
            try
View Full Code Here

TOP

Related Classes of org.qi4j.api.type.ValueCompositeType

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.