public void marshall()

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


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

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

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

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

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