All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.enonic.xp.lib.content.mapper.DuplicateContentsResultMapper Maven / Gradle / Ivy

The newest version!
package com.enonic.xp.lib.content.mapper;

import com.enonic.xp.content.ContentId;
import com.enonic.xp.content.DuplicateContentsResult;
import com.enonic.xp.script.serializer.MapGenerator;
import com.enonic.xp.script.serializer.MapSerializable;

public class DuplicateContentsResultMapper
    implements MapSerializable
{
    private final DuplicateContentsResult duplicateContentsResult;

    public DuplicateContentsResultMapper( final DuplicateContentsResult duplicateContentsResult )
    {
        this.duplicateContentsResult = duplicateContentsResult;
    }

    @Override
    public void serialize( final MapGenerator gen )
    {
        gen.value( "contentName", duplicateContentsResult.getContentName() );
        gen.value( "sourceContentPath", duplicateContentsResult.getSourceContentPath() );
        serializeDuplicatedContents( gen );
    }

    private void serializeDuplicatedContents( final MapGenerator gen )
    {
        gen.array( "duplicatedContents" );
        for ( ContentId contentId : duplicateContentsResult.getDuplicatedContents() )
        {
            gen.value( contentId.toString() );
        }
        gen.end();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy