view src/treecms/tree/id/AbstractNodeID.java @ 6:12604eb6b615

added javadoc
author shoshi
date Mon, 14 Mar 2011 23:24:38 +0900
parents src/treecms/tree/id/RandomNodeID.java@bdde898e8ef9
children f3150b37f9be
line wrap: on
line source

package treecms.tree.id;

import treecms.api.NodeID;

public abstract class AbstractNodeID implements NodeID
{
	public abstract NodeID create();
	public abstract NodeID update();
	public abstract String getUUID();
	public abstract String getVersion();
	
	public abstract boolean isFamily(NodeID _id);
	
	@Override
	public String toString()
	{
		return (new StringBuffer(getUUID())).append('@').append(getVersion()).toString();
	}
	
	@Override
	public int hashCode()
	{
		int hash = 17;
		hash = 37*hash + getUUID().hashCode();
		hash = 37*hash + getVersion().hashCode();
		
		return hash;
	}
	
	@Override
	public boolean equals(Object _id)
	{
		if(_id instanceof NodeID){
			NodeID target = (NodeID)_id;
			if(isFamily(target) && getVersion().equals(target.getVersion())){
				return true;
			}
		}
		return false;
	}
}