001/* 002 * (C) Copyright 2011 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.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 org.nuxeo.ecm.platform.forms.layout.api.WidgetReference; 020 021/** 022 * @since 5.5 023 */ 024public class WidgetReferenceImpl implements WidgetReference { 025 026 private static final long serialVersionUID = 1L; 027 028 protected String category; 029 030 protected String name; 031 032 // needed by GWT serialization 033 protected WidgetReferenceImpl() { 034 super(); 035 } 036 037 public WidgetReferenceImpl(String widget) { 038 this(null, widget); 039 } 040 041 public WidgetReferenceImpl(String category, String name) { 042 super(); 043 this.category = category; 044 this.name = name; 045 } 046 047 @Override 048 public String getCategory() { 049 return category; 050 } 051 052 @Override 053 public String getName() { 054 return name; 055 } 056 057 @Override 058 public WidgetReference clone() { 059 return new WidgetReferenceImpl(category, name); 060 } 061 062 /** 063 * @since 7.2 064 */ 065 @Override 066 public boolean equals(Object obj) { 067 if (!(obj instanceof WidgetReferenceImpl)) { 068 return false; 069 } 070 if (obj == this) { 071 return true; 072 } 073 WidgetReferenceImpl w = (WidgetReferenceImpl) obj; 074 return new EqualsBuilder().append(name, w.name).append(category, w.category).isEquals(); 075 } 076 077}