Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.model.core.auth

File Permission.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
14% of files have more coverage

Code metrics

2
6
4
1
41
32
5
0.83
1.5
4
1.25

Classes

Class Line # Actions
Permission 13 6 5
0.7575%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    package io.sunshower.model.core.auth;
2   
3    import io.sunshower.model.core.Schemata;
4    import io.sunshower.persistence.core.DistributableEntity;
5    import java.util.LinkedHashSet;
6    import java.util.Set;
7    import javax.persistence.*;
8    import javax.xml.bind.annotation.XmlRootElement;
9   
10    @Entity
11    @XmlRootElement
12    @Table(name = "PERMISSION", schema = Schemata.SUNSHOWER)
 
13    public class Permission extends DistributableEntity {
14   
15    @Basic @Column private String name;
16   
17    @Basic private String description;
18   
19    @ManyToMany(mappedBy = "permissions")
20    private Set<Role> roles;
21   
 
22  1 toggle public Permission() {
23  1 super();
24    }
25   
 
26  1 toggle public Permission(final String name) {
27  1 this();
28    }
29   
 
30  1 toggle public void addRole(Role role) {
31  1 if (this.roles == null) {
32  1 this.roles = new LinkedHashSet<>();
33    }
34  1 this.roles.add(role);
35    }
36   
 
37  0 toggle @Override
38    public String toString() {
39  0 return "Permission{" + "name='" + name + '\'' + ", description='" + description + '\'' + '}';
40    }
41    }