blob: 5193f4baf5ee594ea997aa341b2a9550815ea88b [file] [log] [blame]
Jonathan Hartf5829202015-02-12 09:37:02 -08001/*
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.bgprouter;
17
18import com.google.common.base.MoreObjects;
19import org.onlab.packet.IpAddress;
20import org.onosproject.net.group.GroupKey;
21
22import java.util.Objects;
23
24import static com.google.common.base.Preconditions.checkNotNull;
25
26/**
27 * Created by jono on 2/16/15.
28 */
29public class NextHopGroupKey implements GroupKey {
30
31 private final IpAddress address;
32
33 public NextHopGroupKey(IpAddress address) {
34 this.address = checkNotNull(address);
35 }
36
37 public IpAddress address() {
38 return address;
39 }
40
41 @Override
42 public boolean equals(Object o) {
43 if (!(o instanceof NextHopGroupKey)) {
44 return false;
45 }
46
47 NextHopGroupKey that = (NextHopGroupKey) o;
48
49 return Objects.equals(this.address, that.address);
50 }
51
52 @Override
53 public int hashCode() {
54 return Objects.hash(address);
55 }
56
57 @Override
58 public String toString() {
59 return MoreObjects.toStringHelper(getClass())
60 .add("address", address)
61 .toString();
62 }
63}