001/* 002 * (C) Copyright 2012 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 * ataillefer 016 */ 017package org.nuxeo.ecm.diff.model.impl; 018 019import org.nuxeo.ecm.diff.model.DiffFieldItemDefinition; 020 021/** 022 * Default implementation of a {@link DiffFieldItemDefinition}. 023 * 024 * @author <a href="mailto:ataillefer@nuxeo.com">Antoine Taillefer</a> 025 * @since 5.6 026 */ 027public class DiffFieldItemDefinitionImpl implements DiffFieldItemDefinition { 028 029 private static final long serialVersionUID = 1054205948632276597L; 030 031 protected String name; 032 033 protected boolean displayContentDiffLinks; 034 035 public DiffFieldItemDefinitionImpl(String name) { 036 this(name, false); 037 } 038 039 public DiffFieldItemDefinitionImpl(String name, boolean displayContentDiffLinks) { 040 this.name = name; 041 this.displayContentDiffLinks = displayContentDiffLinks; 042 } 043 044 public String getName() { 045 return name; 046 } 047 048 public boolean isDisplayContentDiffLinks() { 049 return displayContentDiffLinks; 050 } 051 052 @Override 053 public boolean equals(Object other) { 054 055 if (this == other) { 056 return true; 057 } 058 if (other == null || !(other instanceof DiffFieldItemDefinition)) { 059 return false; 060 } 061 062 String otherName = ((DiffFieldItemDefinition) other).getName(); 063 boolean otherDisplayContentDiffLinks = ((DiffFieldItemDefinition) other).isDisplayContentDiffLinks(); 064 if (name == null && otherName == null) { 065 return true; 066 } 067 if (name == null || otherName == null || !name.equals(otherName) 068 || displayContentDiffLinks != otherDisplayContentDiffLinks) { 069 return false; 070 } 071 return true; 072 } 073 074 @Override 075 public String toString() { 076 return name + " (displayContentDiffLinks: " + displayContentDiffLinks + ")"; 077 } 078}