001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS (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 * Nuxeo - initial API and implementation 016 * 017 * $Id: BlankImpl.java 19155 2007-05-22 16:19:48Z sfermigier $ 018 */ 019 020package org.nuxeo.ecm.platform.relations.api.impl; 021 022import org.nuxeo.ecm.platform.relations.api.Blank; 023import org.nuxeo.ecm.platform.relations.api.NodeType; 024 025/** 026 * Blank node. 027 * 028 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 029 */ 030public class BlankImpl extends AbstractNode implements Blank { 031 032 private static final long serialVersionUID = 1L; 033 034 private String id; 035 036 public BlankImpl() { 037 } 038 039 public BlankImpl(String id) { 040 this.id = id; 041 } 042 043 public String getId() { 044 return id; 045 } 046 047 public void setId(String id) { 048 this.id = id; 049 } 050 051 public NodeType getNodeType() { 052 return NodeType.BLANK; 053 } 054 055 @Override 056 public boolean isBlank() { 057 return true; 058 } 059 060 @Override 061 public String toString() { 062 String str; 063 if (id != null) { 064 str = String.format("%s('%s')", getClass().getSimpleName(), id); 065 } else { 066 str = String.format("%s()", getClass().getSimpleName()); 067 } 068 return str; 069 } 070 071 @Override 072 public boolean equals(Object other) { 073 if (this == other) { 074 return true; 075 } 076 if (!(other instanceof BlankImpl)) { 077 return false; 078 } 079 BlankImpl otherBlank = (BlankImpl) other; 080 return id == null ? otherBlank.id == null : id.equals(otherBlank.id); 081 } 082 083 @Override 084 public int hashCode() { 085 return id == null ? 0 : id.hashCode(); 086 } 087 088}