Make ActionInfo immutable
This subtly changes the behaviour of ActionInfo's actionKey. Please
carefully code review to make sure that no code anywhere assumes that
ActionInfo's actionKey gets automagically updated when FlowEntity's
getFlowBuilder() is used. From a pure Java development point of view
this seems logical, because you created the ActionInfo with a certain
actionKey given to the ActionInfo (or the default 0), and would not
expect it to just change by itself! (Or is it perhaps simply wrong to
have actionKey in ActionInfo all together, and this numeric index should
only be present in Action?)
Immutable objects are a Good Thing(TM). They are clear and thread safe
by default. All YANG gen. objects are immutable, and created by
*Builder, for a very good reason. We should make all hand-crafted beans
the same (or, ideally, better, just code generate them all as well, use
YANG, or using Google AutoValue; if YANG for simple Beans is somehow not
good; see
https://github.com/google/auto/blob/master/value/userguide/index.md).
This solves a specific problem I ran into when writing tests, where I
found it very un-intutive that what looked like a "getter", the
getFlowBuilder(), would change objects. The new
ActionInfoImmutableTest illustrates the specific problem I ran into, and
which originally motived me to do this - but immutable beans is a good
idea generally anyway.
This also makes the intention of the code in these classes much clearer
to read (the idea of the API as-is seems to be that always only either
String actionValues or BI bigActionValues is set; never both). Removal
of setActionKey is only consistent then.
Similar to what was already done in
https://git.opendaylight.org/gerrit/#/c/41524/ for InstructionInfo and
(Nx)MatchInfo.
Change-Id: Id0619b1ab6013bee53f392603acb85f9c4f18f7c
Signed-off-by: Michael Vorburger <vorburger@redhat.com>