package gr.uoa.di.web.utils.ep;

import gr.uoa.di.web.utils.webdocument.WebDocument;

public class RelatedObject {

	public String relation = null;
	public WebDocument object = null;
	
	public RelatedObject(String relation, WebDocument object) {
		super();
		this.relation = relation;
		this.object = object;
	}

	public String getRelation() {
		return relation;
	}

	public WebDocument getobject() {
		return object;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		
		result = prime * result
				+ ((object == null) ? 0 : object.getId().hashCode());
		
		result = prime * result + ((relation == null) ? 0 : relation.hashCode());
		
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		RelatedObject other = (RelatedObject) obj;
		
		if (object == null) {
			if (other.object != null)
				return false;
		} else if (!object.getId().equals(other.object.getId()))
			return false;
		
		if (relation == null) {
			if (other.relation != null)
				return false;
		} else if (!relation.equals(other.relation))
			return false;
		return true;
	}
}
