001/*
002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 *
016 * Contributors:
017 *     Anahide Tchertchian
018 */
019package org.nuxeo.ecm.platform.forms.layout.api.impl;
020
021import java.util.List;
022import java.util.Map;
023
024import org.nuxeo.ecm.platform.forms.layout.api.LayoutTypeConfiguration;
025import org.nuxeo.ecm.platform.forms.layout.api.LayoutTypeDefinition;
026
027/**
028 * @since 6.0
029 */
030public class LayoutTypeDefinitionImpl implements LayoutTypeDefinition {
031
032    private static final long serialVersionUID = 1L;
033
034    protected String name;
035
036    protected List<String> aliases;
037
038    protected Map<String, String> templates;
039
040    protected LayoutTypeConfiguration configuration;
041
042    // needed by GWT serialization
043    public LayoutTypeDefinitionImpl() {
044        super();
045    }
046
047    public LayoutTypeDefinitionImpl(String name, Map<String, String> templates, LayoutTypeConfiguration configuration) {
048        super();
049        this.name = name;
050        this.templates = templates;
051        this.configuration = configuration;
052    }
053
054    @Override
055    public String getName() {
056        return name;
057    }
058
059    public Map<String, String> getTemplates() {
060        return templates;
061    }
062
063    @Override
064    public String getTemplate(String mode) {
065        return LayoutDefinitionImpl.getTemplate(templates, mode);
066    }
067
068    @Override
069    public LayoutTypeConfiguration getConfiguration() {
070        return configuration;
071    }
072
073    @Override
074    public List<String> getAliases() {
075        return aliases;
076    }
077
078    public void setAliases(List<String> aliases) {
079        this.aliases = aliases;
080    }
081
082    /**
083     * @since 7.2
084     */
085    @Override
086    public boolean equals(Object obj) {
087        if (!(obj instanceof LayoutTypeDefinitionImpl)) {
088            return false;
089        }
090        if (obj == this) {
091            return true;
092        }
093        LayoutTypeDefinitionImpl lt = (LayoutTypeDefinitionImpl) obj;
094        return new EqualsBuilder().append(name, lt.name).append(aliases, lt.aliases).append(templates, lt.templates).append(
095                configuration, lt.configuration).isEquals();
096    }
097
098}