Simon Hunt | 41b943e | 2015-05-21 13:52:01 -0700 | [diff] [blame] | 1 | /* |
| 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 | |
| 18 | package org.onosproject.cord.gui.model; |
| 19 | |
Simon Hunt | 6c2555b | 2015-05-21 18:17:56 -0700 | [diff] [blame] | 20 | import java.util.HashMap; |
| 21 | import java.util.Map; |
| 22 | |
Simon Hunt | 41b943e | 2015-05-21 13:52:01 -0700 | [diff] [blame] | 23 | /** |
| 24 | * Designates a user of a subscriber's account. |
| 25 | */ |
| 26 | public class SubscriberUser { |
| 27 | private final int id; |
| 28 | private final String name; |
| 29 | private final String mac; |
| 30 | |
Simon Hunt | 6c2555b | 2015-05-21 18:17:56 -0700 | [diff] [blame] | 31 | private final Map<XosFunctionDescriptor, XosFunction.Memento> mementos = |
| 32 | new HashMap<XosFunctionDescriptor, XosFunction.Memento>(); |
| 33 | |
Simon Hunt | 41b943e | 2015-05-21 13:52:01 -0700 | [diff] [blame] | 34 | /** |
| 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 Hunt | 6c2555b | 2015-05-21 18:17:56 -0700 | [diff] [blame] | 73 | |
| 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 Hunt | 41b943e | 2015-05-21 13:52:01 -0700 | [diff] [blame] | 102 | } |