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

com.enonic.xp.lib.schema.mapper.SchemaConverter Maven / Gradle / Ivy

package com.enonic.xp.lib.schema.mapper;

import com.enonic.xp.resource.DynamicSchemaResult;
import com.enonic.xp.schema.BaseSchema;
import com.enonic.xp.schema.content.ContentType;
import com.enonic.xp.schema.mixin.Mixin;
import com.enonic.xp.schema.xdata.XData;

public class SchemaConverter
{
    private SchemaConverter()
    {

    }

    public static SchemaMapper convert( final DynamicSchemaResult> result )
    {
        final Object dynamicSchema = result.getSchema();
        if ( dynamicSchema instanceof ContentType )
        {
            return new ContentTypeMapper( (DynamicSchemaResult) result );
        }
        if ( dynamicSchema instanceof Mixin )
        {
            return new MixinMapper( (DynamicSchemaResult) result );
        }
        if ( dynamicSchema instanceof XData )
        {
            return new XDataMapper( (DynamicSchemaResult) result );
        }

        throw new IllegalArgumentException( "invalid component type: " + result.getClass() );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy