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:at@nuxeo.com">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 @Override 046 public String getId() { 047 return id; 048 } 049 050 @Override 051 public void setId(String id) { 052 this.id = id; 053 } 054 055 @Override 056 public NodeType getNodeType() { 057 return NodeType.BLANK; 058 } 059 060 @Override 061 public boolean isBlank() { 062 return true; 063 } 064 065 @Override 066 public String toString() { 067 String str; 068 if (id != null) { 069 str = String.format("%s('%s')", getClass().getSimpleName(), id); 070 } else { 071 str = String.format("%s()", getClass().getSimpleName()); 072 } 073 return str; 074 } 075 076 @Override 077 public boolean equals(Object other) { 078 if (this == other) { 079 return true; 080 } 081 if (!(other instanceof BlankImpl)) { 082 return false; 083 } 084 BlankImpl otherBlank = (BlankImpl) other; 085 return id == null ? otherBlank.id == null : id.equals(otherBlank.id); 086 } 087 088 @Override 089 public int hashCode() { 090 return id == null ? 0 : id.hashCode(); 091 } 092 093}