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: ResourceImpl.java 20796 2007-06-19 09:52:03Z sfermigier $ 018 */ 019 020package org.nuxeo.ecm.platform.relations.api.impl; 021 022import org.nuxeo.ecm.platform.relations.api.NodeType; 023import org.nuxeo.ecm.platform.relations.api.Resource; 024 025/** 026 * Resource. 027 * 028 * @author <a href="mailto:at@nuxeo.com">Anahide Tchertchian</a> 029 */ 030public class ResourceImpl extends AbstractNode implements Resource { 031 032 private static final long serialVersionUID = 1L; 033 034 protected String uri; 035 036 public ResourceImpl() { 037 } 038 039 public ResourceImpl(String uri) { 040 this.uri = uri; 041 } 042 043 public String getUri() { 044 return uri; 045 } 046 047 public void setUri(String uri) { 048 this.uri = uri; 049 } 050 051 public NodeType getNodeType() { 052 return NodeType.RESOURCE; 053 } 054 055 @Override 056 public boolean isResource() { 057 return true; 058 } 059 060 @Override 061 public String toString() { 062 return String.format("%s('%s')", getClass().getSimpleName(), uri); 063 } 064 065 @Override 066 public boolean equals(Object other) { 067 if (this == other) { 068 return true; 069 } 070 if (!(other instanceof ResourceImpl)) { 071 return false; 072 } 073 ResourceImpl otherResource = (ResourceImpl) other; 074 return uri == null ? otherResource.uri == null : uri.equals(otherResource.uri); 075 } 076 077 @Override 078 public int hashCode() { 079 return uri.hashCode(); 080 } 081 082}