2 * Copyright © 2017 Red Hat, Inc. and others. All rights reserved.
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.instructions;
10 import java.math.BigInteger;
11 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
18 * Write metadata instruction.
20 public class InstructionWriteMetadata extends AbstractInstructionInfoImpl {
21 private static final long serialVersionUID = 1L;
23 private final BigInteger metadata;
24 private final BigInteger mask;
26 public InstructionWriteMetadata(BigInteger metadata, BigInteger mask) {
27 this.metadata = metadata;
32 public Instruction buildInstruction(int instructionKey) {
33 return new InstructionBuilder()
34 .setInstruction(new WriteMetadataCaseBuilder()
35 .setWriteMetadata(new WriteMetadataBuilder()
36 .setMetadata(metadata)
37 .setMetadataMask(mask)
42 .setKey(new InstructionKey(instructionKey))
46 public BigInteger getMetadata() {
50 public BigInteger getMask() {
55 public boolean equals(Object other) {
59 if (other == null || getClass() != other.getClass()) {
63 InstructionWriteMetadata that = (InstructionWriteMetadata) other;
65 if (metadata != null ? !metadata.equals(that.metadata) : that.metadata != null) {
68 return mask != null ? mask.equals(that.mask) : that.mask == null;
72 public int hashCode() {
73 int result = metadata != null ? metadata.hashCode() : 0;
74 result = 31 * result + (mask != null ? mask.hashCode() : 0);
79 public String toString() {
80 return "InstructionWriteMetadata[metadata=" + metadata + ", mask=" + mask + "]";