Package org.qi4j.api.type

Examples of org.qi4j.api.type.ValueType


    private ValueType underTest;

    @Before
    public void setup()
    {
        underTest = new ValueType( LocalDate.class );
    }
View Full Code Here


    private ValueType underTest;

    @Before
    public void setup()
    {
        underTest = new ValueType( LocalDateTime.class );
    }
View Full Code Here

    private ValueType underTest;

    @Before
    public void setup()
    {
        underTest = new ValueType( DateTime.class );
    }
View Full Code Here

                                   Class compositeType,
                                   LayerModel layer,
                                   ModuleModel module
    )
    {
        ValueType valueType = null;
        if( CollectionType.isCollection( type ) )
        {
            if( type instanceof ParameterizedType )
            {
                ParameterizedType pt = (ParameterizedType) type;
                Type collectionType = pt.getActualTypeArguments()[ 0 ];
                if( collectionType instanceof TypeVariable )
                {
                    TypeVariable collectionTypeVariable = (TypeVariable) collectionType;
                    collectionType = Classes.resolveTypeVariable( collectionTypeVariable, declaringClass, compositeType );
                }
                ValueType collectedType = newValueType( collectionType, declaringClass, compositeType, layer, module );
                valueType = new CollectionType( Classes.RAW_CLASS.map( type ), collectedType );
            }
            else
            {
                valueType = new CollectionType( Classes.RAW_CLASS
                                                    .map( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ) );
            }
        }
        else if( MapType.isMap( type ) )
        {
            if( type instanceof ParameterizedType )
            {
                ParameterizedType pt = (ParameterizedType) type;
                Type keyType = pt.getActualTypeArguments()[ 0 ];
                if( keyType instanceof TypeVariable )
                {
                    TypeVariable keyTypeVariable = (TypeVariable) keyType;
                    keyType = Classes.resolveTypeVariable( keyTypeVariable, declaringClass, compositeType );
                }
                ValueType keyedType = newValueType( keyType, declaringClass, compositeType, layer, module );

                Type valType = pt.getActualTypeArguments()[ 1 ];
                if( valType instanceof TypeVariable )
                {
                    TypeVariable valueTypeVariable = (TypeVariable) valType;
                    valType = Classes.resolveTypeVariable( valueTypeVariable, declaringClass, compositeType );
                }
                ValueType valuedType = newValueType( valType, declaringClass, compositeType, layer, module );

                valueType = new MapType( Classes.RAW_CLASS.map( type ), keyedType, valuedType );
            }
            else
            {
                valueType = new MapType( Classes.RAW_CLASS
                                             .map( type ), newValueType( Object.class, declaringClass, compositeType, layer, module ), newValueType( Object.class, declaringClass, compositeType, layer, module ) );
            }
        }
        else if( ValueCompositeType.isValueComposite( type ) )
        {
            // Find ValueModel in module/layer/used layers
            ValueModel model = new ValueFinder( layer, module, Classes.RAW_CLASS.map( type ) ).getFoundModel();

            if( model == null )
            {
                if( type.equals( ValueComposite.class ) )
                {
                    // Create default model
                    MixinsModel mixinsModel = new MixinsModel();
                    Iterable valueComposite = (Iterable) Iterables.iterable( ValueComposite.class );
                    ValueStateModel valueStateModel = new ValueStateModel( new PropertiesModel(),
                                                                           new AssociationsModel(),
                                                                           new ManyAssociationsModel(),
                                                                           new NamedAssociationsModel() );
                    model = new ValueModel( valueComposite, Visibility.application, new MetaInfo(),
                                            mixinsModel, valueStateModel, new CompositeMethodsModel( mixinsModel ) );
                }
                else
                {
                    throw new InvalidApplicationException( "[" + module.name() + "] Could not find ValueComposite of type " + type );
                }
            }

            return model.valueType();
        }
        else if( EnumType.isEnum( type ) )
        {
            valueType = new EnumType( Classes.RAW_CLASS.map( type ) );
        }
        else
        {
            valueType = new ValueType( Classes.RAW_CLASS.map( type ) );
        }

        return valueType;
    }
View Full Code Here

    @Test
    public void givenIterableTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals()
        throws Exception
    {
        String output = valueSerialization.serialize( Iterables.iterable( byteCollection().toArray() ) );
        CollectionType collectionType = new CollectionType( List.class, new ValueType( Byte.class ) );
        List<Byte> list = valueSerialization.deserialize( collectionType, output );
        assertEquals( byteCollection(), list );
    }
View Full Code Here

    @Test
    public void givenCollectionTypeWithByteAndNullElementWhenSerializingAndDeserializingExpectEquals()
        throws Exception
    {
        String output = valueSerialization.serialize( byteCollection() );
        CollectionType collectionType = new CollectionType( Set.class, new ValueType( Byte.class ) );
        Set<Byte> list = valueSerialization.deserialize( collectionType, output );
        assertEquals( new LinkedHashSet<Byte>( byteCollection() ), list );
    }
View Full Code Here

    @Test
    public void givenCollectionTypeWithCharacterAndNullElementWhenSerializingAndDeserializingExpectEquals()
        throws Exception
    {
        String output = valueSerialization.serialize( characterCollection() );
        CollectionType collectionType = new CollectionType( List.class, new ValueType( Character.class ) );
        List<Character> list = valueSerialization.deserialize( collectionType, output );
        assertEquals( characterCollection(), list );
    }
View Full Code Here

    @Test
    public void givenCollectionTypeWithShortAndNullElementWhenSerializingAndDeserializingExpectEquals()
        throws Exception
    {
        String output = valueSerialization.serialize( shortCollection() );
        CollectionType collectionType = new CollectionType( List.class, new ValueType( Short.class ) );
        List<Short> list = valueSerialization.deserialize( collectionType, output );
        assertEquals( shortCollection(), list );
    }
View Full Code Here

    @Test
    public void givenCollectionTypeWithIntegerAndNullElementWhenSerializingAndDeserializingExpectEquals()
        throws Exception
    {
        String output = valueSerialization.serialize( integerCollection() );
        CollectionType collectionType = new CollectionType( List.class, new ValueType( Integer.class ) );
        List<Integer> list = valueSerialization.deserialize( collectionType, output );
        assertEquals( integerCollection(), list );
    }
View Full Code Here

    @Test
    public void givenCollectionTypeWithLongAndNullElementWhenSerializingAndDeserializingExpectEquals()
        throws Exception
    {
        String output = valueSerialization.serialize( longCollection() );
        CollectionType collectionType = new CollectionType( List.class, new ValueType( Long.class ) );
        List<Long> list = valueSerialization.deserialize( collectionType, output );
        assertEquals( longCollection(), list );
    }
View Full Code Here

TOP

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

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.