Clover icon

sunshower-sdk

  1. Project Clover database Wed Apr 4 2018 21:39:43 UTC
  2. Package io.sunshower.sdk.v1.model.core.security

File PrincipalElement.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart9.png
12% of files have more coverage

Code metrics

2
4
2
1
62
47
3
0.75
2
2
1.5

Classes

Class Line # Actions
PrincipalElement 22 4 3
0.87587.5%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    package io.sunshower.sdk.v1.model.core.security;
2   
3    import io.sunshower.sdk.v1.model.core.element.AbstractElement;
4    import lombok.*;
5   
6    import javax.xml.bind.annotation.XmlAttribute;
7    import javax.xml.bind.annotation.XmlElement;
8    import javax.xml.bind.annotation.XmlElementWrapper;
9    import javax.xml.bind.annotation.XmlRootElement;
10    import java.util.ArrayList;
11    import java.util.Date;
12    import java.util.List;
13   
14    @Getter
15    @Setter
16    @ToString
17    @Builder(builderMethodName = "create", buildMethodName = "newPrincipal")
18    @NoArgsConstructor
19    @AllArgsConstructor
20    @XmlRootElement(name = "principal")
21    @EqualsAndHashCode(callSuper = false)
 
22    public class PrincipalElement extends AbstractElement<PrincipalElement> {
23   
24    @XmlAttribute(name = "username")
25    private String username;
26   
27    @XmlAttribute(name = "first-name")
28    private String firstName;
29   
30    @XmlElement(name = "last-name")
31    private String lastName;
32   
33    @XmlAttribute(name = "email-address")
34    private String emailAddress;
35   
36    @XmlAttribute(name = "phone-number")
37    private String phoneNumber;
38   
39    @XmlAttribute(name = "password")
40    private String password;
41   
42    @XmlElement(name = "role")
43    @XmlElementWrapper(name = "roles")
44    private List<RoleElement> roles;
45   
46    @XmlAttribute private boolean active;
47   
48    @XmlAttribute private Date registered;
49   
50    @XmlAttribute private Date lastActive;
51   
 
52  7 toggle {
53  7 setType(PrincipalElement.class);
54    }
55   
 
56  1 toggle public void addRole(RoleElement role) {
57  1 if (roles == null) {
58  1 roles = new ArrayList<>();
59    }
60  1 roles.add(role);
61    }
62    }