/**
 * PitchFrequency.java
 * Created on Jun 2, 2008
 * (C) Copyright TANDBERG Television Ltd.
 */
package com.tandbergtv.watchpoint.pmm.entities;

/**
 * @author Vlada Jakobac
 * 
 */
public class PitchFrequency {

	public static final int DEFAULT_ID = 0;
	private static final int HASHCODE_MULTIPLICATION_FACTOR = 8;
	private static final int HASHCODE_ADDITION_FACTOR = 104;

	private int id = DEFAULT_ID;

	private int pitchDay;

	private int weeksBetweenPitch;

	// partner to which this object refers to
	private Partner distributionPartner;

	private Partner sourcePartner;

	public PitchFrequency() {

	}

	/**
	 * @return the id
	 */
	public int getId() {
		return id;
	}

	/**
	 * @param id
	 *            the id to set
	 */
	public void setId(int id) {
		this.id = id;
	}

	/**
	 * @return the pitchDay
	 */
	public int getPitchDay() {
		return pitchDay;
	}

	/**
	 * @param pitchDay
	 *            the pitchDay to set
	 */
	public void setPitchDay(int pitchDay) {
		this.pitchDay = pitchDay;
	}

	/**
	 * @return the weeksBetweenPitch
	 */
	public int getWeeksBetweenPitch() {
		return weeksBetweenPitch;
	}

	/**
	 * @param weeksBetweenPitch
	 *            the weeksBetweenPitch to set
	 */
	public void setWeeksBetweenPitch(int weeksBetweenPitch) {
		this.weeksBetweenPitch = weeksBetweenPitch;
	}

	/**
	 * @return the distributionPartner
	 */
	public Partner getDistributionPartner() {
		return distributionPartner;
	}

	/**
	 * @param distributionPartner
	 *            the distributionPartner to set
	 */
	public void setDistributionPartner(Partner distributionPartner) {
		this.distributionPartner = distributionPartner;
	}

	/**
	 * @return the sourcePartnerId
	 */
	public Partner getSourcePartner() {
		return sourcePartner;
	}

	/**
	 * @param sourcePartnerId
	 *            the sourcePartnerId to set
	 */
	public void setSourcePartner(Partner sourcePartner) {
		this.sourcePartner = sourcePartner;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (obj instanceof PitchFrequency) {
			PitchFrequency PitchFrequencyObj = (PitchFrequency) obj;

			if (PitchFrequencyObj.getId() != DEFAULT_ID
					&& this.getId() != DEFAULT_ID) {
				return (PitchFrequencyObj.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;
	}

}
