/**
 * JobParameter.java
 * Created on May 13, 2008
 * (C) Copyright TANDBERG Television Ltd.
 */
package com.tandbergtv.watchpoint.pmm.entities;

import java.io.Serializable;

/**
 * @author spuranik
 * 
 * This class represents the parameters that will be supplied when the job kicks off.
 */
public class JobParameter implements Serializable {
	
	private static final long serialVersionUID = 1L;
	public static final int DEFAULT_ID = 0;
	private static final int HASHCODE_MULTIPLICATION_FACTOR = 6;
	private static final int HASHCODE_ADDITION_FACTOR = 102;	

	// id in db
	private long id;

	// corresponding jobId
	private Job job;

	// corresponds to a template variable name
	private String name;

	// corresponds to a template variable's value
	private String value;

	/**
	 * default ctor
	 */
	public JobParameter() {
	}

	/**
	 * @return the id
	 */
	public long getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(long id) {
		this.id = id;
	}

	/**
	 * @return the jobId
	 */
	public Job getJob() {
		return job;
	}

	/**
	 * @param jobId
	 *            the jobId to set
	 */
	public void setJob(Job job) {
		this.job = job;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name
	 *            the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the value
	 */
	public String getValue() {
		return value;
	}

	/**
	 * @param value
	 *            the value to set
	 */
	public void setValue(String value) {
		this.value = value;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof JobParameter)
		{
			JobParameter jobParameterObj = (JobParameter) obj;

			if (jobParameterObj.getId() != DEFAULT_ID && this.getId() != DEFAULT_ID)
			{
				return (jobParameterObj.getId() == this.getId());
			}
			else
			{
				return super.equals(obj);
			}
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		long hash = this.id * HASHCODE_MULTIPLICATION_FACTOR + HASHCODE_ADDITION_FACTOR;
		int hashCode = new Long(hash).hashCode();
		if (this.id == DEFAULT_ID)
		{
			hashCode = super.hashCode();
		}
		return hashCode;
	}
	
}
