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.theme.styling.service.descriptors; 018 019import java.util.ArrayList; 020import java.util.List; 021 022import org.apache.commons.lang.builder.EqualsBuilder; 023import org.nuxeo.common.xmap.annotation.XNodeList; 024import org.nuxeo.common.xmap.annotation.XObject; 025 026/** 027 * @since 5.5 028 */ 029@XObject("palettePreview") 030public class PalettePreview { 031 032 @XNodeList(value = "colors/color", type = ArrayList.class, componentType = String.class) 033 List<String> colors; 034 035 public List<String> getColors() { 036 return colors; 037 } 038 039 public void setColors(List<String> colors) { 040 this.colors = colors; 041 } 042 043 public PalettePreview clone() { 044 PalettePreview clone = new PalettePreview(); 045 if (colors != null) { 046 List<String> newColors = new ArrayList<String>(); 047 newColors.addAll(colors); 048 clone.setColors(newColors); 049 } 050 return clone; 051 } 052 053 @Override 054 public boolean equals(Object obj) { 055 if (!(obj instanceof PalettePreview)) { 056 return false; 057 } 058 if (obj == this) { 059 return true; 060 } 061 PalettePreview p = (PalettePreview) obj; 062 return new EqualsBuilder().append(colors, p.colors).isEquals(); 063 } 064 065}