Mohammad Shahid | 0cf9c0e | 2017-08-09 15:58:19 +0530 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2017-present Open Networking Foundation |
| 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 | package org.onosproject.gluon.rsc; |
| 17 | |
| 18 | import com.fasterxml.jackson.databind.JsonNode; |
| 19 | import org.onosproject.net.config.Config; |
| 20 | |
| 21 | /** |
| 22 | * Representation of a Etcd response. |
| 23 | */ |
| 24 | public class GluonConfig extends Config<String> { |
| 25 | public String action; |
| 26 | public String key; |
| 27 | public JsonNode value; |
| 28 | long modifiedIndex; |
| 29 | long createdIndex; |
| 30 | |
| 31 | public GluonConfig() { |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * Gluon configuration data model. |
| 36 | * |
| 37 | * @param action operation type |
| 38 | * @param key proton key |
| 39 | * @param value proton value |
| 40 | * @param mIndex modified time |
| 41 | * @param cIndex created time |
| 42 | */ |
| 43 | public GluonConfig(String action, String key, JsonNode value, long mIndex, |
| 44 | long cIndex) { |
| 45 | this.action = action; |
| 46 | this.key = key; |
| 47 | this.value = value; |
| 48 | this.modifiedIndex = mIndex; |
| 49 | this.createdIndex = cIndex; |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * Sets the etcdresponse used by network config. |
| 54 | * |
| 55 | * @param gluonConfig Etcdresponse data after parsing |
| 56 | */ |
| 57 | public void setEtcdResponse(GluonConfig gluonConfig) { |
| 58 | object.put(gluonConfig.key, gluonConfig.value); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public String toString() { |
| 63 | return "GluonConfig{" + |
| 64 | "action='" + action + '\'' + |
| 65 | ", key='" + key + '\'' + |
| 66 | ", value=" + value + |
| 67 | ", modifiedIndex=" + modifiedIndex + |
| 68 | ", createdIndex=" + createdIndex + |
| 69 | '}'; |
| 70 | } |
| 71 | } |