mdsalutil-api clean up Checkstyle violations (not enforced yet)
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / matches / MatchArpTha.java
1 /*
2  * Copyright © 2017 Red Hat, Inc. and others.
3  *
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
7  */
8 package org.opendaylight.genius.mdsalutil.matches;
9
10 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.arp.match.fields.ArpTargetHardwareAddressBuilder;
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;
15
16 /**
17  * ARP target hardware address match.
18  */
19 public class MatchArpTha extends MatchInfoHelper<ArpMatch, ArpMatchBuilder> {
20     private final MacAddress address;
21
22     public MatchArpTha(MacAddress address) {
23         this.address = address;
24     }
25
26     @Override
27     protected void applyValue(MatchBuilder matchBuilder, ArpMatch value) {
28         matchBuilder.setLayer3Match(value);
29     }
30
31     @Override
32     protected void populateBuilder(ArpMatchBuilder builder) {
33         builder.setArpTargetHardwareAddress(new ArpTargetHardwareAddressBuilder().setAddress(address).build());
34     }
35
36     public MacAddress getAddress() {
37         return address;
38     }
39
40     @Override
41     public boolean equals(Object other) {
42         if (this == other) {
43             return true;
44         }
45         if (other == null || getClass() != other.getClass()) {
46             return false;
47         }
48         if (!super.equals(other)) {
49             return false;
50         }
51
52         MatchArpTha that = (MatchArpTha) other;
53
54         return address != null ? address.equals(that.address) : that.address == null;
55     }
56
57     @Override
58     public int hashCode() {
59         int result = super.hashCode();
60         result = 31 * result + (address != null ? address.hashCode() : 0);
61         return result;
62     }
63 }