public void marshall()

in lightning-core/src/main/java/org/apache/directmemory/lightning/internal/marshaller/ListMarshaller.java [65:112]


    public void marshall( Object value, PropertyDescriptor propertyDescriptor, Target target,
                          SerializationContext serializationContext )
        throws IOException
    {

        if ( writePossibleNull( value, target ) )
        {
            List<?> list = (List<?>) value;
            target.writeInt( list.size() );

            Marshaller marshaller = null;
            ClassDefinition classDefinition = null;
            PropertyDescriptor pd = null;
            if ( listType != null )
            {
                ensureMarshallerInitialized( serializationContext );
                marshaller = listTypeMarshaller;
                Class<?> baseType = TypeUtil.getBaseType( listType );
                classDefinition =
                    serializationContext.getClassDefinitionContainer().getClassDefinitionByType( baseType );
                pd = new CheatPropertyDescriptor( propertyDescriptor.getPropertyName() + "List", baseType, marshaller );
            }

            for ( Object entry : list )
            {
                if ( writePossibleNull( entry, target ) )
                {
                    if ( listType == null )
                    {
                        marshaller = serializationContext.findMarshaller( entry.getClass() );
                        classDefinition =
                            serializationContext.getClassDefinitionContainer().getClassDefinitionByType( entry.getClass() );
                        pd =
                            new CheatPropertyDescriptor( propertyDescriptor.getPropertyName() + "List",
                                                         entry.getClass(), marshaller );
                    }

                    if ( classDefinition == null )
                    {
                        throw new SerializerExecutionException( "No ClassDefinition found for type " + entry.getClass() );
                    }

                    target.writeLong( classDefinition.getId() );
                    marshaller.marshall( entry, pd, target, serializationContext );
                }
            }
        }
    }