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 | |
| 20 | import com.fasterxml.jackson.databind.node.ObjectNode; |
| 21 | |
| 22 | /** |
| 23 | * Utility functions on users. |
| 24 | */ |
| 25 | public 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()); |
| 44 | // TODO: add profile data |
| 45 | return root; |
| 46 | } |
| 47 | |
| 48 | } |