/**
 * Copyright (c) 2000-2017 Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * pSubscription License ("License"). You may not use this file except in
 * compliance with the License. You can obtain a copy of the License by
 * contacting Liferay, Inc. See the License for the specific language governing
 * permissions and limitations under the License, including but not limited to
 * distribution rights of the Software.
 *
 *
 *
 */

package com.liferay.portal.kernel.scheduler.messaging;

import com.liferay.portal.kernel.util.Validator;

import java.io.Serializable;

/**
 * @author László Csontos
 */
public class ReceiverKey implements Serializable {

	/**
	 * The empty constructor is required by
	 * {@link com.liferay.portal.json.jabsorb.serializer.LiferaySerializer}. Do
	 * not use this for any other purpose.
	 */
	public ReceiverKey() {
	}

	public ReceiverKey(String jobName, String groupName) {
		_jobName = jobName;
		_groupName = groupName;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof ReceiverKey)) {
			return false;
		}

		ReceiverKey receiverKey = (ReceiverKey)obj;

		if (Validator.equals(_jobName, receiverKey._jobName) &&
			Validator.equals(_groupName, receiverKey._groupName)) {

			return true;
		}

		return false;
	}

	public String getGroupName() {
		return _groupName;
	}

	public String getJobName() {
		return _jobName;
	}

	@Override
	public int hashCode() {
		return _jobName.hashCode() + (_groupName.hashCode() * 11);
	}

	private String _groupName;
	private String _jobName;

}