
package io.orber.site.domain;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * Authority entity.
 * 
 * @author Jeremy Raymond
 */
@Entity
@Table(name = "authorities")
public class Authority implements Serializable {

    private static final long serialVersionUID = 1L;

    private String username;

    private String authority;

    /**
     * Gets the username.
     * 
     * @return the username
     */
    @Id
    @Column(name = "USERNAME")
    public String getUsername() {
        return username;
    }

    /**
     * Sets the username.
     * 
     * @param username the username
     */
    public void setUsername(String username) {
        this.username = username;
    }

    /**
     * Gets the authority.
     * 
     * @return the authority
     */
    @Id
    @Column(name = "AUTHORITY")
    public String getAuthority() {
        return authority;
    }

    /**
     * Sets the authority.
     * 
     * @param authority the authority
     */
    public void setAuthority(String authority) {
        this.authority = authority;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((authority == null) ? 0 : authority.hashCode());
        result = prime * result
                + ((username == null) ? 0 : username.hashCode());
        return result;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (!(obj instanceof Authority)) {
            return false;
        }
        Authority other = (Authority) obj;
        if (authority == null) {
            if (other.authority != null) {
                return false;
            }
        } else if (!authority.equals(other.authority)) {
            return false;
        }
        if (username == null) {
            if (other.username != null) {
                return false;
            }
        } else if (!username.equals(other.username)) {
            return false;
        }
        return true;
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public String toString() {
        return "Authority [username=" + username + ", authority=" + authority
                + "]";
    }

}
