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