blob: d1c832b3e4e8460cb26a26eec042eb6f60811afb [file] [log] [blame]
Simon Hunt41b943e2015-05-21 13:52:01 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Simon Hunt41b943e2015-05-21 13:52:01 -07003 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17
18package org.onosproject.cord.gui.model;
19
Simon Hunt6c2555b2015-05-21 18:17:56 -070020import java.util.HashMap;
21import java.util.Map;
22
Simon Hunt41b943e2015-05-21 13:52:01 -070023/**
24 * Designates a user of a subscriber's account.
25 */
26public class SubscriberUser {
27 private final int id;
28 private final String name;
29 private final String mac;
30
Simon Hunt7d02c082015-05-29 12:17:09 -070031 // this is "duplicated" in the URL_FILTER memento, but, oh well...
32 // -- the level, as returned from XOS, when we create this user object.
33 private String level;
34
Simon Hunt6c2555b2015-05-21 18:17:56 -070035 private final Map<XosFunctionDescriptor, XosFunction.Memento> mementos =
36 new HashMap<XosFunctionDescriptor, XosFunction.Memento>();
37
Simon Hunt41b943e2015-05-21 13:52:01 -070038 /**
39 * Constructs a subscriber user from the given parameters.
40 *
41 * @param id internal identifier
42 * @param name display name
43 * @param mac MAC address of the associated device
Simon Hunt7d02c082015-05-29 12:17:09 -070044 * @param level URL filter level
Simon Hunt41b943e2015-05-21 13:52:01 -070045 */
Simon Hunt7d02c082015-05-29 12:17:09 -070046 public SubscriberUser(int id, String name, String mac, String level) {
Simon Hunt41b943e2015-05-21 13:52:01 -070047 this.id = id;
48 this.name = name;
49 this.mac = mac;
Simon Hunt7d02c082015-05-29 12:17:09 -070050 this.level = level;
Simon Hunt41b943e2015-05-21 13:52:01 -070051 }
52
53 /**
54 * Returns the internal identifier.
55 *
56 * @return the identifier
57 */
58 public int id() {
59 return id;
60 }
61
62 /**
63 * Returns the display name.
64 *
65 * @return display name
66 */
67 public String name() {
68 return name;
69 }
70
71 /**
72 * Returns the MAC address of the associated device.
73 *
74 * @return MAC address
75 */
76 public String mac() {
77 return mac;
78 }
Simon Hunt6c2555b2015-05-21 18:17:56 -070079
80 /**
Simon Hunt7d02c082015-05-29 12:17:09 -070081 * Returns the URL filter level.
82 *
83 * @return URL filter level
84 */
85 public String urlFilterLevel() {
86 return level;
87 }
88
89 /**
90 * Sets the URL filter level.
91 *
92 * @param level URL filter level
93 */
94 public void setUrlFilterLevel(String level) {
95 this.level = level;
96 }
97
98 /**
Simon Hunt6c2555b2015-05-21 18:17:56 -070099 * Stores a memento for the given XOS function.
100 *
101 * @param f XOS function
102 * @param m memento
103 */
104 public void setMemento(XosFunctionDescriptor f, XosFunction.Memento m) {
105 if (m != null) {
106 mementos.put(f, m);
107 }
108 }
109
110 /**
111 * Returns the memento stored on this user, for the given XOS function.
112 *
113 * @param f XOS function
114 * @return memento
115 */
116 public XosFunction.Memento getMemento(XosFunctionDescriptor f) {
117 return mementos.get(f);
118 }
119
120 /**
121 * Clears the memento map.
122 */
123 public void clearMementos() {
124 mementos.clear();
125 }
Simon Hunta00b0ce2015-05-22 15:57:11 -0700126
127 @Override
128 public String toString() {
129 return "{User: " + name + "}";
130 }
Simon Hunt41b943e2015-05-21 13:52:01 -0700131}