@Test public void testProcessBuilder() { Range<Long> include = Range.closed(4L, 44L); Range<Long> exclude = Range.singleton(43L); Builder b1 = null; Builder b2 = LongSpace.builder().including(include); Builder b3 = LongSpace.builder().excluding(exclude); Builder b4 = LongSpace.builder().including(include).excluding(exclude); LongSpace b3Expected = LongSpace.builder().including(Range.closed(0L, 4294967295L)).excluding(exclude).build(); assertNull(BgpRouteConstraints.processBuilder(b1)); assertEquals(b2.build(), BgpRouteConstraints.processBuilder(b2)); assertEquals(b3Expected, BgpRouteConstraints.processBuilder(b3)); assertEquals(b4.build(), BgpRouteConstraints.processBuilder(b4)); }
@VisibleForTesting @Nullable static LongSpace processBuilder(@Nullable LongSpace.Builder builder) { if (builder == null) { return null; } if (builder.hasExclusionsOnly()) { return builder.including(THIRTY_TWO_BIT_RANGE).build(); } return builder.build(); }
BgpRouteConstraints { @VisibleForTesting @Nullable static LongSpace processBuilder(@Nullable LongSpace.Builder builder) { if (builder == null) { return null; } if (builder.hasExclusionsOnly()) { return builder.including(THIRTY_TWO_BIT_RANGE).build(); } return builder.build(); } }
BgpRouteConstraints { @VisibleForTesting @Nullable static LongSpace processBuilder(@Nullable LongSpace.Builder builder) { if (builder == null) { return null; } if (builder.hasExclusionsOnly()) { return builder.including(THIRTY_TWO_BIT_RANGE).build(); } return builder.build(); } @JsonCreator private  BgpRouteConstraints(
      @Nullable @JsonProperty(PROP_PREFIX) PrefixSpace prefix,
      @JsonProperty(PROP_COMPLEMENT_PREFIX) boolean complementPrefix,
      @Nullable @JsonProperty(PROP_LOCAL_PREFERENCE) LongSpace.Builder localPreference,
      @Nullable @JsonProperty(PROP_MED) LongSpace.Builder med,
      @Nullable @JsonProperty(PROP_COMMUNITIES) RegexConstraints communities,
      @Nullable @JsonProperty(PROP_AS_PATH) RegexConstraints asPath); private  BgpRouteConstraints(
      @Nullable PrefixSpace prefix,
      boolean complementPrefix,
      @Nullable LongSpace localPreference,
      @Nullable LongSpace med,
      @Nullable RegexConstraints communities,
      @Nullable RegexConstraints asPath); }
BgpRouteConstraints { @VisibleForTesting @Nullable static LongSpace processBuilder(@Nullable LongSpace.Builder builder) { if (builder == null) { return null; } if (builder.hasExclusionsOnly()) { return builder.including(THIRTY_TWO_BIT_RANGE).build(); } return builder.build(); } @JsonCreator private  BgpRouteConstraints(
      @Nullable @JsonProperty(PROP_PREFIX) PrefixSpace prefix,
      @JsonProperty(PROP_COMPLEMENT_PREFIX) boolean complementPrefix,
      @Nullable @JsonProperty(PROP_LOCAL_PREFERENCE) LongSpace.Builder localPreference,
      @Nullable @JsonProperty(PROP_MED) LongSpace.Builder med,
      @Nullable @JsonProperty(PROP_COMMUNITIES) RegexConstraints communities,
      @Nullable @JsonProperty(PROP_AS_PATH) RegexConstraints asPath); private  BgpRouteConstraints(
      @Nullable PrefixSpace prefix,
      boolean complementPrefix,
      @Nullable LongSpace localPreference,
      @Nullable LongSpace med,
      @Nullable RegexConstraints communities,
      @Nullable RegexConstraints asPath); static Builder builder(); @JsonProperty(PROP_PREFIX) @Nonnull PrefixSpace getPrefix(); @JsonProperty(PROP_COMPLEMENT_PREFIX) boolean getComplementPrefix(); @JsonProperty(PROP_LOCAL_PREFERENCE) @Nonnull LongSpace getLocalPreference(); @JsonProperty(PROP_MED) @Nonnull LongSpace getMed(); @JsonProperty(PROP_COMMUNITIES) @Nonnull RegexConstraints getCommunities(); @JsonProperty(PROP_AS_PATH) @Nonnull RegexConstraints getAsPath(); }
BgpRouteConstraints { @VisibleForTesting @Nullable static LongSpace processBuilder(@Nullable LongSpace.Builder builder) { if (builder == null) { return null; } if (builder.hasExclusionsOnly()) { return builder.including(THIRTY_TWO_BIT_RANGE).build(); } return builder.build(); } @JsonCreator private  BgpRouteConstraints(
      @Nullable @JsonProperty(PROP_PREFIX) PrefixSpace prefix,
      @JsonProperty(PROP_COMPLEMENT_PREFIX) boolean complementPrefix,
      @Nullable @JsonProperty(PROP_LOCAL_PREFERENCE) LongSpace.Builder localPreference,
      @Nullable @JsonProperty(PROP_MED) LongSpace.Builder med,
      @Nullable @JsonProperty(PROP_COMMUNITIES) RegexConstraints communities,
      @Nullable @JsonProperty(PROP_AS_PATH) RegexConstraints asPath); private  BgpRouteConstraints(
      @Nullable PrefixSpace prefix,
      boolean complementPrefix,
      @Nullable LongSpace localPreference,
      @Nullable LongSpace med,
      @Nullable RegexConstraints communities,
      @Nullable RegexConstraints asPath); static Builder builder(); @JsonProperty(PROP_PREFIX) @Nonnull PrefixSpace getPrefix(); @JsonProperty(PROP_COMPLEMENT_PREFIX) boolean getComplementPrefix(); @JsonProperty(PROP_LOCAL_PREFERENCE) @Nonnull LongSpace getLocalPreference(); @JsonProperty(PROP_MED) @Nonnull LongSpace getMed(); @JsonProperty(PROP_COMMUNITIES) @Nonnull RegexConstraints getCommunities(); @JsonProperty(PROP_AS_PATH) @Nonnull RegexConstraints getAsPath();  }