blob: f377ad0fc5468922fba12ff8a87a7b4474bdfee8 [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
20import com.fasterxml.jackson.databind.node.ObjectNode;
21
22/**
23 * Utility functions on users.
24 */
25public class UserFactory extends JsonFactory {
26
27 private static final String MAC = "mac";
28 private static final String PROFILE = "profile";
29
30 // no instantiation
31 private UserFactory() {}
32
33 /**
34 * Returns an object node representation of the given user.
35 *
36 * @param user the user
37 * @return object node
38 */
39 public static ObjectNode toObjectNode(SubscriberUser user) {
40 ObjectNode root = objectNode()
41 .put(ID, user.id())
42 .put(NAME, user.name())
43 .put(MAC, user.mac());
Simon Hunt6c2555b2015-05-21 18:17:56 -070044 root.set(PROFILE, XosFunctionFactory.profileForUser(user));
Simon Hunt41b943e2015-05-21 13:52:01 -070045 return root;
46 }
47
48}