1 /* 2 * Copyright (c) 2012, 2014, Oracle and/or its affiliates. 3 * All rights reserved. Use is subject to license terms. 4 * 5 * This file is available and licensed under the following license: 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * - Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * - Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in 15 * the documentation and/or other materials provided with the distribution. 16 * - Neither the name of Oracle Corporation nor the names of its 17 * contributors may be used to endorse or promote products derived 18 * from this software without specific prior written permission. 19 * 20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 31 */ 32 package login.model; 33 34 import java.util.HashMap; 35 import java.util.Map; 36 37 public class User { 38 39 private static final Map<String, User> USERS = new HashMap<String, User>(); 40 41 public static User of(String id) { 42 User user = USERS.get(id); 43 if (user == null) { 44 user = new User(id); 45 USERS.put(id, user); 46 } 47 return user; 48 } 49 50 private User(String id) { 51 this.id = id; 52 } 53 private String id; 54 55 public String getId() { 56 return id; 57 } 58 private String email = ""; 59 private String phone = ""; 60 private boolean subscribed; 61 private String address = ""; 62 63 /** 64 * @return the email 65 */ 66 public String getEmail() { 67 return email; 68 } 69 70 /** 71 * @param email the email to set 72 */ 73 public void setEmail(String email) { 74 this.email = email; 75 } 76 77 /** 78 * @return the phone 79 */ 80 public String getPhone() { 81 return phone; 82 } 83 84 /** 85 * @param phone the phone to set 86 */ 87 public void setPhone(String phone) { 88 this.phone = phone; 89 } 90 91 /** 92 * @return the subscribed 93 */ 94 public boolean isSubscribed() { 95 return subscribed; 96 } 97 98 /** 99 * @param subscribed the subscribed to set 100 */ 101 public void setSubscribed(boolean subscribed) { 102 this.subscribed = subscribed; 103 } 104 105 /** 106 * @return the address 107 */ 108 public String getAddress() { 109 return address; 110 } 111 112 /** 113 * @param address the address to set 114 */ 115 public void setAddress(String address) { 116 this.address = address; 117 } 118 }