001/*
002 * (C) Copyright 2006-2007 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 *     <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
018 *
019 * $Id: WidgetTypeImpl.java 28478 2008-01-04 12:53:58Z sfermigier $
020 */
021
022package org.nuxeo.ecm.platform.forms.layout.api.impl;
023
024import java.util.List;
025import java.util.Map;
026
027import org.nuxeo.ecm.platform.forms.layout.api.WidgetType;
028
029/**
030 * Implementation for widget types.
031 *
032 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a>
033 */
034public class WidgetTypeImpl implements WidgetType {
035
036    private static final long serialVersionUID = -6449946287266106594L;
037
038    protected String name;
039
040    protected List<String> aliases;
041
042    protected Class<?> typeClass;
043
044    protected Map<String, String> properties;
045
046    // needed by GWT serialization
047    protected WidgetTypeImpl() {
048        super();
049    }
050
051    public WidgetTypeImpl(String name, Class<?> typeClass, Map<String, String> properties) {
052        this.name = name;
053        this.typeClass = typeClass;
054        this.properties = properties;
055    }
056
057    public String getName() {
058        return name;
059    }
060
061    public Class<?> getWidgetTypeClass() {
062        return typeClass;
063    }
064
065    public Map<String, String> getProperties() {
066        return properties;
067    }
068
069    public List<String> getAliases() {
070        return aliases;
071    }
072
073    public void setAliases(List<String> aliases) {
074        this.aliases = aliases;
075    }
076
077    /**
078     * @since 7.2
079     */
080    @Override
081    public boolean equals(Object obj) {
082        if (!(obj instanceof WidgetTypeImpl)) {
083            return false;
084        }
085        if (obj == this) {
086            return true;
087        }
088        WidgetTypeImpl w = (WidgetTypeImpl) obj;
089        return new EqualsBuilder().append(name, w.name).append(aliases, w.aliases).append(typeClass, w.typeClass).append(
090                properties, w.properties).isEquals();
091    }
092
093}