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    @Override
060    public Map<String, String> getTemplates() {
061        return templates;
062    }
063
064    @Override
065    public String getTemplate(String mode) {
066        return LayoutDefinitionImpl.getTemplate(templates, mode);
067    }
068
069    @Override
070    public LayoutTypeConfiguration getConfiguration() {
071        return configuration;
072    }
073
074    @Override
075    public List<String> getAliases() {
076        return aliases;
077    }
078
079    public void setAliases(List<String> aliases) {
080        this.aliases = aliases;
081    }
082
083    /**
084     * @since 7.2
085     */
086    @Override
087    public boolean equals(Object obj) {
088        if (!(obj instanceof LayoutTypeDefinitionImpl)) {
089            return false;
090        }
091        if (obj == this) {
092            return true;
093        }
094        LayoutTypeDefinitionImpl lt = (LayoutTypeDefinitionImpl) obj;
095        return new EqualsBuilder().append(name, lt.name).append(aliases, lt.aliases).append(templates, lt.templates).append(
096                configuration, lt.configuration).isEquals();
097    }
098
099}