package com.tandbergtv.workflow.comm;

/**
 * A network endpoint that communicates using HTTP
 * 
 * @author Sahil Verma
 */
public class HTTPDevice implements ISource, IDestination {

	private String name;
	
	private String url;
	
	/**
	 * Creates a HTTPDevice
	 * @param url
	 * @param name
	 */
	public HTTPDevice(String url, String name) {
		this.url = url;
		this.name = name;
	}
	
	/**
	 * Creates a HTTPDevice
	 * @param url
	 */
	public HTTPDevice(String url) {
		this.url = url;
	}
	
	/**
	 * Returns the url
	 * @return the url
	 */
	public String getUrl() {
		return url;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return this.url;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof HTTPDevice) {
			HTTPDevice destination = (HTTPDevice)obj;
			return this.url != null && this.url.equals(destination.url);
		}
		
		return false;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		return url.hashCode();
	}

	/* (non-Javadoc)
	 * @see com.tandbergtv.workflow.comm.IDevice#getName()
	 */
	public String getName() {
		return name;
	}
}
