blob: 39f767a79a61008717a23e72b8019fecbfa47f31 [file] [log] [blame]
Thomas Vachuska96d55b12015-05-11 08:52:03 -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 */
16package org.onosproject.incubator.net.config.basics;
17
18/**
19 * Basic configuration for network elements, e.g. devices, hosts. Such elements
20 * can have a friendly name, geo-coordinates, logical rack coordinates and
21 * an owner entity.
22 */
23public abstract class BasicElementConfig<S> extends AllowedEntityConfig<S> {
24
25 public static final String NAME = "name";
26
27 public static final String LATITUDE = "latitude";
28 public static final String LONGITUDE = "longitude";
29
30 public static final String RACK_ADDRESS = "rackAddress";
31 public static final String OWNER = "owner";
32
33 /**
34 * Returns friendly label for the element.
35 *
36 * @return friendly label or element id itself if not set
37 */
38 public String name() {
39 return get(NAME, subject.toString());
40 }
41
42 /**
43 * Sets friendly label for the element.
44 *
45 * @param name new friendly label; null to clear
46 * @return self
47 */
48 public BasicElementConfig name(String name) {
49 return (BasicElementConfig) setOrClear(NAME, name);
50 }
51
52 /**
53 * Returns element latitude.
54 *
55 * @return element latitude; -1 if not set
56 */
57 public double latitude() {
58 return get(LATITUDE, -1.0);
59 }
60
61 /**
62 * Sets the element latitude.
63 *
64 * @param latitude new latitude; null to clear
65 * @return self
66 */
67 public BasicElementConfig latitude(Double latitude) {
68 return (BasicElementConfig) setOrClear(LATITUDE, latitude);
69 }
70
71 /**
72 * Returns element latitude.
73 *
74 * @return element latitude; -1 if not set
75 */
76 public double longitude() {
77 return get(LONGITUDE, -1.0);
78 }
79
80 /**
81 * Sets the element longitude.
82 *
83 * @param longitude new longitude; null to clear
84 * @return self
85 */
86 public BasicElementConfig longitude(Double longitude) {
87 return (BasicElementConfig) setOrClear(LONGITUDE, longitude);
88 }
89
90 /**
91 * Returns the element rack address.
92 *
93 * @return rack address; null if not set
94 */
95 public String rackAddress() {
96 return get(RACK_ADDRESS, null);
97 }
98
99 /**
100 * Sets element rack address.
101 *
102 * @param address new rack address; null to clear
103 * @return self
104 */
105 public BasicElementConfig rackAddress(String address) {
106 return (BasicElementConfig) setOrClear(RACK_ADDRESS, address);
107 }
108
109 /**
110 * Returns owner of the element.
111 *
112 * @return owner or null if not set
113 */
114 public String owner() {
115 return get(OWNER, null);
116 }
117
118 /**
119 * Sets the owner of the element.
120 *
121 * @param owner new owner; null to clear
122 * @return self
123 */
124 public BasicElementConfig owner(String owner) {
125 return (BasicElementConfig) setOrClear(OWNER, owner);
126 }
127
128}