blob: 81eadb7da9ca732701699b582a0eef2c4becd486 [file] [log] [blame]
/*
* Copyright 2017-present Open Networking Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.dhcprelay.store;
import org.onlab.packet.IpAddress;
import org.onlab.packet.IpPrefix;
import java.util.Objects;
import com.google.common.base.MoreObjects;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* A class to define a Dhcp Fpm record.
*/
public class DhcpFpmRecord {
private IpPrefix prefix;
private IpAddress nextHop;
public DhcpFpmRecord(IpPrefix prefix, IpAddress nextHop) {
checkNotNull(prefix, "prefix cannot be null");
checkNotNull(nextHop, "ipAddress cannot be null");
this.prefix = prefix;
this.nextHop = nextHop;
}
/**
* Gets IP prefix of record.
*
* @return the IP prefix
*/
public IpPrefix ipPrefix() {
return prefix;
}
/**
* Gets IP address of record.
*
* @return the IP address
*/
public IpAddress nextHop() {
return nextHop;
}
@Override
public int hashCode() {
return Objects.hash(prefix, nextHop);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (!(obj instanceof DhcpFpmRecord)) {
return false;
}
DhcpFpmRecord that = (DhcpFpmRecord) obj;
return Objects.equals(prefix, that.prefix) &&
Objects.equals(nextHop, that.nextHop);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("prefix", prefix)
.add("ipAddress", nextHop)
.toString();
}
}