blob: 31ac794a2914ce05b0fdd68ac129ad3ab3b030e4 [file] [log] [blame]
Simon Hunt41b943e2015-05-21 13:52:01 -07001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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 Hunt6c2555b2015-05-21 18:17:56 -070031 private final Map<XosFunctionDescriptor, XosFunction.Memento> mementos =
32 new HashMap<XosFunctionDescriptor, XosFunction.Memento>();
33
Simon Hunt41b943e2015-05-21 13:52:01 -070034 /**
35 * Constructs a subscriber user from the given parameters.
36 *
37 * @param id internal identifier
38 * @param name display name
39 * @param mac MAC address of the associated device
40 */
41 public SubscriberUser(int id, String name, String mac) {
42 this.id = id;
43 this.name = name;
44 this.mac = mac;
45 }
46
47 /**
48 * Returns the internal identifier.
49 *
50 * @return the identifier
51 */
52 public int id() {
53 return id;
54 }
55
56 /**
57 * Returns the display name.
58 *
59 * @return display name
60 */
61 public String name() {
62 return name;
63 }
64
65 /**
66 * Returns the MAC address of the associated device.
67 *
68 * @return MAC address
69 */
70 public String mac() {
71 return mac;
72 }
Simon Hunt6c2555b2015-05-21 18:17:56 -070073
74 /**
75 * Stores a memento for the given XOS function.
76 *
77 * @param f XOS function
78 * @param m memento
79 */
80 public void setMemento(XosFunctionDescriptor f, XosFunction.Memento m) {
81 if (m != null) {
82 mementos.put(f, m);
83 }
84 }
85
86 /**
87 * Returns the memento stored on this user, for the given XOS function.
88 *
89 * @param f XOS function
90 * @return memento
91 */
92 public XosFunction.Memento getMemento(XosFunctionDescriptor f) {
93 return mementos.get(f);
94 }
95
96 /**
97 * Clears the memento map.
98 */
99 public void clearMementos() {
100 mementos.clear();
101 }
Simon Hunta00b0ce2015-05-22 15:57:11 -0700102
103 @Override
104 public String toString() {
105 return "{User: " + name + "}";
106 }
Simon Hunt41b943e2015-05-21 13:52:01 -0700107}