@Test public void testThenToMatch() { Prefix prefix = Prefix.parse("1.1.1.1/24"); NatRuleThen then = new NatRuleThenPrefix(prefix, DESTINATION); assertThat(ReverseStaticNat.thenToMatch(then), equalTo(new NatRuleMatchSrcAddr(prefix))); then = new NatRuleThenPrefixName("prefix", DESTINATION); assertThat(ReverseStaticNat.thenToMatch(then), equalTo(new NatRuleMatchSrcAddrName("prefix"))); }
@VisibleForTesting static NatRuleMatch thenToMatch(NatRuleThen then) { checkArgument( (then instanceof NatRuleThenPrefix) || (then instanceof NatRuleThenPrefixName), "Not supported type of then in static nat: " + then); if (then instanceof NatRuleThenPrefix) { NatRuleThenPrefix thenPrefix = (NatRuleThenPrefix) then; return new NatRuleMatchSrcAddr(thenPrefix.getPrefix()); } NatRuleThenPrefixName thenPrefix = (NatRuleThenPrefixName) then; return new NatRuleMatchSrcAddrName(thenPrefix.getName()); }
ReverseStaticNat { @VisibleForTesting static NatRuleMatch thenToMatch(NatRuleThen then) { checkArgument( (then instanceof NatRuleThenPrefix) || (then instanceof NatRuleThenPrefixName), "Not supported type of then in static nat: " + then); if (then instanceof NatRuleThenPrefix) { NatRuleThenPrefix thenPrefix = (NatRuleThenPrefix) then; return new NatRuleMatchSrcAddr(thenPrefix.getPrefix()); } NatRuleThenPrefixName thenPrefix = (NatRuleThenPrefixName) then; return new NatRuleMatchSrcAddrName(thenPrefix.getName()); } }
ReverseStaticNat { @VisibleForTesting static NatRuleMatch thenToMatch(NatRuleThen then) { checkArgument( (then instanceof NatRuleThenPrefix) || (then instanceof NatRuleThenPrefixName), "Not supported type of then in static nat: " + then); if (then instanceof NatRuleThenPrefix) { NatRuleThenPrefix thenPrefix = (NatRuleThenPrefix) then; return new NatRuleMatchSrcAddr(thenPrefix.getPrefix()); } NatRuleThenPrefixName thenPrefix = (NatRuleThenPrefixName) then; return new NatRuleMatchSrcAddrName(thenPrefix.getName()); }  }
ReverseStaticNat { @VisibleForTesting static NatRuleMatch thenToMatch(NatRuleThen then) { checkArgument( (then instanceof NatRuleThenPrefix) || (then instanceof NatRuleThenPrefixName), "Not supported type of then in static nat: " + then); if (then instanceof NatRuleThenPrefix) { NatRuleThenPrefix thenPrefix = (NatRuleThenPrefix) then; return new NatRuleMatchSrcAddr(thenPrefix.getPrefix()); } NatRuleThenPrefixName thenPrefix = (NatRuleThenPrefixName) then; return new NatRuleMatchSrcAddrName(thenPrefix.getName()); }   }
ReverseStaticNat { @VisibleForTesting static NatRuleMatch thenToMatch(NatRuleThen then) { checkArgument( (then instanceof NatRuleThenPrefix) || (then instanceof NatRuleThenPrefixName), "Not supported type of then in static nat: " + then); if (then instanceof NatRuleThenPrefix) { NatRuleThenPrefix thenPrefix = (NatRuleThenPrefix) then; return new NatRuleMatchSrcAddr(thenPrefix.getPrefix()); } NatRuleThenPrefixName thenPrefix = (NatRuleThenPrefixName) then; return new NatRuleMatchSrcAddrName(thenPrefix.getName()); }    }