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.packet.IPProtocols;
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.match.IpMatch;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
18 public class MatchIpProtocol extends MatchInfoHelper<IpMatch, IpMatchBuilder> {
19 public static final MatchIpProtocol TCP = new MatchIpProtocol(IPProtocols.TCP.shortValue());
20 public static final MatchIpProtocol UDP = new MatchIpProtocol(IPProtocols.UDP.shortValue());
21 public static final MatchIpProtocol ICMP = new MatchIpProtocol(IPProtocols.ICMP.shortValue());
22 public static final MatchIpProtocol ICMPV6 = new MatchIpProtocol(IPProtocols.IPV6ICMP.shortValue());
24 private final short protocol;
26 public MatchIpProtocol(short protocol) {
27 this.protocol = protocol;
31 protected void applyValue(MatchBuilder matchBuilder, IpMatch value) {
32 matchBuilder.setIpMatch(value);
36 protected void populateBuilder(IpMatchBuilder builder) {
37 builder.setIpProtocol(protocol);
40 public short getProtocol() {
45 public boolean equals(Object o) {
46 if (this == o) return true;
47 if (o == null || getClass() != o.getClass()) return false;
48 if (!super.equals(o)) return false;
50 MatchIpProtocol that = (MatchIpProtocol) o;
52 return protocol == that.protocol;
56 public int hashCode() {
57 int result = super.hashCode();
58 result = 31 * result + (int) protocol;