com.qaprosoft.zafira.models.db.Group Maven / Gradle / Ivy
/*******************************************************************************
* Copyright 2013-2018 QaProSoft (http://www.qaprosoft.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package com.qaprosoft.zafira.models.db;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
public class Group extends AbstractEntity
{
private static final long serialVersionUID = -1122566583572312653L;
private String name;
private Role role;
private List users;
private Set permissions;
public Group()
{
}
public Group(String name, Role role, Set permissions)
{
this.name = name;
this.role = role;
this.permissions = permissions;
}
public enum Role
{
ROLE_USER, ROLE_ADMIN
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public Role getRole()
{
return role;
}
public void setRole(Role role)
{
this.role = role;
}
public List getUsers()
{
return users;
}
public void setUsers(List users)
{
this.users = users;
}
public Set getPermissions()
{
return permissions;
}
public Set getPermissionNames()
{
return this.permissions.stream().map(permission -> permission.getName().name())
.collect(Collectors.toSet());
}
public void setPermissions(Set permissions)
{
this.permissions = permissions;
}
public boolean hasPermissions()
{
return this.permissions != null && this.permissions.size() > 0;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy