blob: 9e39c451bce15b64a95da7d2348283db9f0dc668 [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.onlab.packet.MacAddress;
21
22import java.util.Objects;
23
24/**
25 * Created by jono on 2/12/15.
26 */
27public class NextHop {
28
29 private final IpAddress ip;
30 private final MacAddress mac;
31
32 public NextHop(IpAddress ip, MacAddress mac) {
33 this.ip = ip;
34 this.mac = mac;
35 }
36
37 public IpAddress ip() {
38 return ip;
39 }
40
41 public MacAddress mac() {
42 return mac;
43 }
44
45 @Override
46 public boolean equals(Object o) {
47 if (!(o instanceof NextHop)) {
48 return false;
49 }
50
51 NextHop that = (NextHop) o;
52
53 return Objects.equals(this.ip, that.ip) &&
54 Objects.equals(this.mac, that.mac);
55 }
56
57 @Override
58 public int hashCode() {
59 return Objects.hash(ip, mac);
60 }
61
62 @Override
63 public String toString() {
64 return MoreObjects.toStringHelper(getClass())
65 .add("ip", ip)
66 .add("mac", mac)
67 .toString();
68 }
69}