blob: 7f00ae70ff4160d7a6140befc018b2cf505135e6 [file] [log] [blame]
Srikanth Vavilapalli717361f2015-03-16 12:06:04 -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.net.group;
17
18import static com.google.common.base.Preconditions.checkNotNull;
19
20import java.util.Arrays;
21
22/**
23 * Default implementation of group key interface.
24 */
25public class DefaultGroupKey implements GroupKey {
26
27 private final byte[] key;
28
29 public DefaultGroupKey(byte[] key) {
30 this.key = checkNotNull(key);
31 }
32
33 @Override
34 public byte[] key() {
35 return key;
36 }
37
38 @Override
39 public boolean equals(Object o) {
40 if (this == o) {
41 return true;
42 }
43 if (!(o instanceof DefaultGroupKey)) {
44 return false;
45 }
46 DefaultGroupKey that = (DefaultGroupKey) o;
47 return (Arrays.equals(this.key, that.key));
48 }
49
50 @Override
51 public int hashCode() {
52 return Arrays.hashCode(this.key);
53 }
54
55}