rimus_cx

Builder Example

Dec 20th, 2021
971
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class UserBuilder {
  2.   constructor() {
  3.     this.user = {};
  4.   }
  5.  
  6.   setLogin(login) {
  7.     this.user.login = login;
  8.     return this;
  9.   }
  10.  
  11.   setPassword(password) {
  12.     this.user.password = password;
  13.     return this;
  14.   }
  15.  
  16.   setFirstName(firstName) {
  17.     this.user.firstName = firstName;
  18.     return this;
  19.   }
  20.  
  21.   setLastName(lastName) {
  22.     this.user.lastName = lastName;
  23.     return this;
  24.   }
  25.  
  26.   setEmail(email) {
  27.     this.user.email = email;
  28.     return this;
  29.   }
  30.  
  31.   setTelephone(telephone) {
  32.     this.user.telephone = telephone;
  33.     return this;
  34.   }
  35.  
  36.   setAddress(address) {
  37.     this.user.address = address;
  38.     return this;
  39.   }
  40.  
  41.   setCity(city) {
  42.     this.user.city = city;
  43.     return this;
  44.   }
  45.  
  46.   setPostCode(postCode) {
  47.     this.user.postCode = postCode;
  48.     return this;
  49.   }
  50.  
  51.   setCountry(country) {
  52.     this.user.country = country;
  53.     return this;
  54.   }
  55.  
  56.  
  57.   setRegion(region) {
  58.     this.user.region = region;
  59.     return this;
  60.   }
  61.  
  62.   build() {
  63.     return this.user;
  64.   }
  65. }
  66.  
  67. module.exports = UserBuilder;
Advertisement
Add Comment
Please, Sign In to add comment