2 * Copyright © 2017 Red Hat, Inc. and others.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.genius.mdsalutil.matches;
10 import org.opendaylight.genius.mdsalutil.NWUtil;
11 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatch;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
17 * ARP target transport address match.
19 public class MatchArpTpa extends MatchInfoHelper<ArpMatch, ArpMatchBuilder> {
21 private final Ipv4Prefix address;
23 public MatchArpTpa(Ipv4Prefix address) {
24 this.address = address;
27 public MatchArpTpa(long ip, long mask) {
28 this(new Ipv4Prefix(NWUtil.longToIpv4(ip, mask)));
31 public MatchArpTpa(String ip, String mask) {
32 this(new Ipv4Prefix(ip + "/" + mask));
36 protected void applyValue(MatchBuilder matchBuilder, ArpMatch value) {
37 matchBuilder.setLayer3Match(value);
41 protected void populateBuilder(ArpMatchBuilder builder) {
42 builder.setArpTargetTransportAddress(address);
45 public Ipv4Prefix getAddress() {
50 public boolean equals(Object other) {
54 if (other == null || getClass() != other.getClass()) {
57 if (!super.equals(other)) {
61 MatchArpTpa that = (MatchArpTpa) other;
63 return address != null ? address.equals(that.address) : that.address == null;
67 public int hashCode() {
68 int result = super.hashCode();
69 result = 31 * result + (address != null ? address.hashCode() : 0);
74 public String toString() {
75 return "MatchArpTpa[" + address + "]";