All Downloads are FREE. Search and download functionalities are using the official Maven repository.

br.com.jhonsapp.bootstrap.object.model.permission.Permission Maven / Gradle / Ivy

The newest version!
package br.com.jhonsapp.bootstrap.object.model.permission;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import org.hibernate.validator.constraints.NotBlank;

import br.com.jhonsapp.bootstrap.object.model.domainObject.DomainObject;

@Entity
@Table(name = "permission")
@SequenceGenerator(name = "permission_seq_generator", sequenceName = "permission_seq", allocationSize = 1, initialValue = 1)
public class Permission implements Serializable, DomainObject {

	/**
	 * Generated serial version id created at 13 October 2017.
	 */
	private static final long serialVersionUID = -6687657431718897880L;

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "permission_seq_generator")
	private long id;
	
	@Column(unique=true)
	private String name;

	public Permission() { }
	
	@Override
	public long getId() {
		return id;
	}

	@NotBlank
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name.toUpperCase();
	}


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

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Permission other = (Permission) obj;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy