com.liferay.amfregistration.service.persistence.RegistrationPK.java Source code

Java tutorial

Introduction

Here is the source code for com.liferay.amfregistration.service.persistence.RegistrationPK.java

Source

/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * The contents of this file are subject to the terms of the Liferay Enterprise
 * Subscription 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.amfregistration.service.persistence;

import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;

import java.io.Serializable;

/**
 * @author Kevin Cruz
 * @generated
 */
public class RegistrationPK implements Comparable<RegistrationPK>, Serializable {
    public String username;
    public long userID;

    public RegistrationPK() {
    }

    public RegistrationPK(String username, long userID) {
        this.username = username;
        this.userID = userID;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public long getUserID() {
        return userID;
    }

    public void setUserID(long userID) {
        this.userID = userID;
    }

    @Override
    public int compareTo(RegistrationPK pk) {
        if (pk == null) {
            return -1;
        }

        int value = 0;

        value = username.compareTo(pk.username);

        if (value != 0) {
            return value;
        }

        if (userID < pk.userID) {
            value = -1;
        } else if (userID > pk.userID) {
            value = 1;
        } else {
            value = 0;
        }

        if (value != 0) {
            return value;
        }

        return 0;
    }

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

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

        RegistrationPK pk = (RegistrationPK) obj;

        if ((username.equals(pk.username)) && (userID == pk.userID)) {
            return true;
        } else {
            return false;
        }
    }

    @Override
    public int hashCode() {
        return (String.valueOf(username) + String.valueOf(userID)).hashCode();
    }

    @Override
    public String toString() {
        StringBundler sb = new StringBundler(10);

        sb.append(StringPool.OPEN_CURLY_BRACE);

        sb.append("username");
        sb.append(StringPool.EQUAL);
        sb.append(username);

        sb.append(StringPool.COMMA);
        sb.append(StringPool.SPACE);
        sb.append("userID");
        sb.append(StringPool.EQUAL);
        sb.append(userID);

        sb.append(StringPool.CLOSE_CURLY_BRACE);

        return sb.toString();
    }
}