Advertisement
Guest User

Untitled

a guest
May 27th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.82 KB | None | 0 0
  1. public class SocialUserMapDot extends SocialUser {
  2.  
  3.     private int id;
  4.     private String userName;
  5.     private String firstName;
  6.     private String lastName;
  7.     private String role;
  8.     private SocialNetwork socialNetwork;
  9.  
  10.     public SocialUserMapDot(String username, String password, Collection<? extends GrantedAuthority> authorities) {
  11.         super(username, password, authorities);
  12.     }
  13.  
  14.     public static Builder getBuilder() {
  15.         return new Builder();
  16.     }
  17.  
  18.     public int getId() {
  19.         return id;
  20.     }
  21.  
  22.     public String getUserName() {
  23.         return userName;
  24.     }
  25.  
  26.     public String getFirstName() {
  27.         return firstName;
  28.     }
  29.  
  30.     public String getLastName() {
  31.         return lastName;
  32.     }
  33.  
  34.     public String getRole() {
  35.         return role;
  36.     }
  37.  
  38.     public SocialNetwork getSocialNetwork() {
  39.         return socialNetwork;
  40.     }
  41.  
  42.     public static class Builder {
  43.  
  44.         private int id;
  45.         private String userName;
  46.         private String firstName;
  47.         private String lastName;
  48.         private String password;
  49.         private String role;
  50.         private SocialNetwork socialNetwork;
  51.         private Set<GrantedAuthority> authorities;
  52.  
  53.         public Builder() {
  54.             this.authorities = new HashSet<>();
  55.         }
  56.  
  57.         public Builder id(int id) {
  58.             this.id = id;
  59.             return this;
  60.         }
  61.  
  62.         public Builder userName(String userName) {
  63.             this.userName = userName;
  64.             return this;
  65.         }
  66.  
  67.         public Builder firstName(String firstName) {
  68.             this.firstName = firstName;
  69.             return this;
  70.         }
  71.  
  72.         public Builder lastName(String lastName) {
  73.             this.lastName = lastName;
  74.             return this;
  75.         }
  76.  
  77.         public Builder password(String password) {
  78.             if (password == null) {
  79.                 password = "SocialUser";
  80.             }
  81.  
  82.             this.password = password;
  83.             return this;
  84.         }
  85.  
  86.         public Builder role(String role) {
  87.             this.role = role;
  88.  
  89.             SimpleGrantedAuthority authority = new SimpleGrantedAuthority(role);
  90.             this.authorities.add(authority);
  91.  
  92.             return this;
  93.         }
  94.  
  95.         public Builder socialNetwork(SocialNetwork socialNetwork) {
  96.             this.socialNetwork = socialNetwork;
  97.             return this;
  98.         }
  99.  
  100.         public SocialUserMapDot build() {
  101.             SocialUserMapDot socialUserMapDot = new SocialUserMapDot(userName, password, authorities);
  102.  
  103.             this.id = id;
  104.             this.firstName = firstName;
  105.             this.lastName = lastName;
  106.             this.password = password;
  107.             this.role = role;
  108.             this.socialNetwork = socialNetwork;
  109.  
  110.             return socialUserMapDot;
  111.         }
  112.     }
  113. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement