com.github.iintelligas.persist.dto.Role Maven / Gradle / Ivy
The newest version!
package com.github.iintelligas.persist.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.github.iintelligas.persist.entity.RoleEntity;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Role implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private String name;
private String description;
private List permissions;
@JsonIgnore
private boolean selected;
public Role() {
}
public Role(String name) {
this.name = name;
}
public Role(final RoleEntity role) {
if (role != null) {
this.id = role.getId();
this.name = role.getName();
this.description = role.getDescription();
}
}
public Role(Long id, String name, String description) {
this.id = id;
this.name = name;
this.description = description;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List getPermissions() {
return permissions;
}
public void addPermission(Permission permission) {
if(permissions == null) {
permissions = new ArrayList<>();
}
permissions.add(permission);
}
public void setPermissions(List permissions) {
this.permissions = permissions;
}
public boolean isSelected() {
return selected;
}
public void setSelected(boolean selected) {
this.selected = selected;
}
@Override
public String toString() {
return "Role{" +
"id=" + id +
", name='" + name + '\'' +
", description='" + description + '\'' +
", permissions=" + permissions +
'}';
}
}