Making all these fields final and explicitly initialize to null
[genius.git] / mdsalutil / mdsalutil-api / src / main / java / org / opendaylight / genius / mdsalutil / MatchInfo.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
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;
9
10 import com.google.common.base.MoreObjects;
11 import java.io.Serializable;
12 import java.math.BigInteger;
13 import java.util.Arrays;
14 import java.util.Map;
15
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
17
18 public class MatchInfo implements Serializable, MatchInfoBase {
19     private static final long serialVersionUID = 1L;
20
21     private final MatchFieldType m_matchField;
22     private final long[] m_alMatchValues;
23     private final BigInteger[] m_aBigIntValues;
24     private final String[] m_asMatchValues;
25
26     public MatchInfo(MatchFieldType matchField, long[] alMatchValues) {
27         m_matchField = matchField;
28         m_alMatchValues = alMatchValues;
29         m_aBigIntValues = null;
30         m_asMatchValues = null;
31     }
32
33     public MatchInfo(MatchFieldType matchField, BigInteger[] alBigMatchValues) {
34         m_matchField = matchField;
35         m_alMatchValues = null;
36         m_aBigIntValues = alBigMatchValues;
37         m_asMatchValues = null;
38     }
39
40     public MatchInfo(MatchFieldType matchField, String[] alStringMatchValues) {
41         m_matchField = matchField;
42         m_alMatchValues = null;
43         m_aBigIntValues = null;
44         m_asMatchValues = alStringMatchValues;
45     }
46
47     @Override
48     public void createInnerMatchBuilder(Map<Class<?>, Object> mapMatchBuilder) {
49         m_matchField.createInnerMatchBuilder(this, mapMatchBuilder);
50     }
51
52     @Override
53     public void setMatch(MatchBuilder matchBuilder, Map<Class<?>, Object> mapMatchBuilder) {
54         m_matchField.setMatch(matchBuilder, this, mapMatchBuilder);
55     }
56
57     public MatchFieldType getMatchField() {
58         return m_matchField;
59     }
60
61     public long[] getMatchValues() {
62         return m_alMatchValues;
63     }
64
65     public BigInteger[] getBigMatchValues() {
66         return m_aBigIntValues;
67     }
68
69     public String[] getStringMatchValues() {
70         return m_asMatchValues;
71     }
72
73     @Override
74     public String toString() {
75         return MoreObjects.toStringHelper(this).omitNullValues().add("matchField", m_matchField)
76                 .add("matchValues", Arrays.toString(m_alMatchValues))
77                 .add("bigMatchValues", Arrays.deepToString(m_aBigIntValues))
78                 .add("stringMatchValues", Arrays.deepToString(m_asMatchValues)).toString();
79     }
80 }