blob: 4806113e6b121e7d30c5613064974034a7ed2dcb [file] [log] [blame]
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2014-present Open Networking Laboratory
Thomas Vachuska4f1a60c2014-10-28 13:39:07 -07003 *
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 */
Brian O'Connorabafb502014-12-02 22:26:20 -080016package org.onosproject.net;
Yuta HIGUCHI39ede6a2014-10-03 15:23:33 -070017
Thomas Vachuska442d26a2014-10-31 08:45:14 -070018/**
19 * Utility for processing annotations.
20 */
Yuta HIGUCHI39ede6a2014-10-03 15:23:33 -070021public final class AnnotationsUtil {
22
23 public static boolean isEqual(Annotations lhs, Annotations rhs) {
24 if (lhs == rhs) {
25 return true;
26 }
27 if (lhs == null || rhs == null) {
28 return false;
29 }
30
31 if (!lhs.keys().equals(rhs.keys())) {
32 return false;
33 }
34
35 for (String key : lhs.keys()) {
Marc De Leenheer81df6082016-03-05 11:02:51 -080036 if (lhs.value(key) == null && rhs.value(key) != null) {
37 return false;
38 }
39
40 if (lhs.value(key) != null && !lhs.value(key).equals(rhs.value(key))) {
Yuta HIGUCHI39ede6a2014-10-03 15:23:33 -070041 return false;
42 }
43 }
44 return true;
45 }
46
47 // not to be instantiated
48 private AnnotationsUtil() {}
49}