001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl-2.1.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     Anahide Tchertchian
016 */
017package org.nuxeo.ecm.platform.forms.layout.api.impl;
018
019import java.util.List;
020import java.util.Map;
021
022import org.nuxeo.ecm.platform.forms.layout.api.LayoutTypeConfiguration;
023import org.nuxeo.ecm.platform.forms.layout.api.LayoutTypeDefinition;
024
025/**
026 * @since 6.0
027 */
028public class LayoutTypeDefinitionImpl implements LayoutTypeDefinition {
029
030    private static final long serialVersionUID = 1L;
031
032    protected String name;
033
034    protected List<String> aliases;
035
036    protected Map<String, String> templates;
037
038    protected LayoutTypeConfiguration configuration;
039
040    // needed by GWT serialization
041    public LayoutTypeDefinitionImpl() {
042        super();
043    }
044
045    public LayoutTypeDefinitionImpl(String name, Map<String, String> templates, LayoutTypeConfiguration configuration) {
046        super();
047        this.name = name;
048        this.templates = templates;
049        this.configuration = configuration;
050    }
051
052    @Override
053    public String getName() {
054        return name;
055    }
056
057    public Map<String, String> getTemplates() {
058        return templates;
059    }
060
061    @Override
062    public String getTemplate(String mode) {
063        return LayoutDefinitionImpl.getTemplate(templates, mode);
064    }
065
066    @Override
067    public LayoutTypeConfiguration getConfiguration() {
068        return configuration;
069    }
070
071    @Override
072    public List<String> getAliases() {
073        return aliases;
074    }
075
076    public void setAliases(List<String> aliases) {
077        this.aliases = aliases;
078    }
079
080    /**
081     * @since 7.2
082     */
083    @Override
084    public boolean equals(Object obj) {
085        if (!(obj instanceof LayoutTypeDefinitionImpl)) {
086            return false;
087        }
088        if (obj == this) {
089            return true;
090        }
091        LayoutTypeDefinitionImpl lt = (LayoutTypeDefinitionImpl) obj;
092        return new EqualsBuilder().append(name, lt.name).append(aliases, lt.aliases).append(templates, lt.templates).append(
093                configuration, lt.configuration).isEquals();
094    }
095
096}