@Test public void testEmpty() { AristaBgpPeerFilter pf = new AristaBgpPeerFilter("name"); assertThat(pf.toLongSpace(), equalTo(BgpPeerConfig.ALL_AS_NUMBERS)); }
public LongSpace toLongSpace() { if (_lines.isEmpty()) { return BgpPeerConfig.ALL_AS_NUMBERS; } LongSpace currentSpace = LongSpace.EMPTY; for (AristaBgpPeerFilterLine l : ImmutableList.copyOf(_lines.values()).reverse()) { if (l.getAction() == Action.ACCEPT) { currentSpace = currentSpace.union(l.getRange()); } else if (l.getAction() == Action.REJECT) { currentSpace = currentSpace.difference(l.getRange()); } else { throw new IllegalStateException( String.format("Unsupported bgp peer-filter action: %s", l.getAction())); } } return currentSpace; }
AristaBgpPeerFilter implements Serializable { public LongSpace toLongSpace() { if (_lines.isEmpty()) { return BgpPeerConfig.ALL_AS_NUMBERS; } LongSpace currentSpace = LongSpace.EMPTY; for (AristaBgpPeerFilterLine l : ImmutableList.copyOf(_lines.values()).reverse()) { if (l.getAction() == Action.ACCEPT) { currentSpace = currentSpace.union(l.getRange()); } else if (l.getAction() == Action.REJECT) { currentSpace = currentSpace.difference(l.getRange()); } else { throw new IllegalStateException( String.format("Unsupported bgp peer-filter action: %s", l.getAction())); } } return currentSpace; } }
AristaBgpPeerFilter implements Serializable { public LongSpace toLongSpace() { if (_lines.isEmpty()) { return BgpPeerConfig.ALL_AS_NUMBERS; } LongSpace currentSpace = LongSpace.EMPTY; for (AristaBgpPeerFilterLine l : ImmutableList.copyOf(_lines.values()).reverse()) { if (l.getAction() == Action.ACCEPT) { currentSpace = currentSpace.union(l.getRange()); } else if (l.getAction() == Action.REJECT) { currentSpace = currentSpace.difference(l.getRange()); } else { throw new IllegalStateException( String.format("Unsupported bgp peer-filter action: %s", l.getAction())); } } return currentSpace; } AristaBgpPeerFilter(String name); }
AristaBgpPeerFilter implements Serializable { public LongSpace toLongSpace() { if (_lines.isEmpty()) { return BgpPeerConfig.ALL_AS_NUMBERS; } LongSpace currentSpace = LongSpace.EMPTY; for (AristaBgpPeerFilterLine l : ImmutableList.copyOf(_lines.values()).reverse()) { if (l.getAction() == Action.ACCEPT) { currentSpace = currentSpace.union(l.getRange()); } else if (l.getAction() == Action.REJECT) { currentSpace = currentSpace.difference(l.getRange()); } else { throw new IllegalStateException( String.format("Unsupported bgp peer-filter action: %s", l.getAction())); } } return currentSpace; } AristaBgpPeerFilter(String name); String getName(); void addLine(LongSpace range, Action action); void addLine(int seq, LongSpace range, Action action); LongSpace toLongSpace(); }
AristaBgpPeerFilter implements Serializable { public LongSpace toLongSpace() { if (_lines.isEmpty()) { return BgpPeerConfig.ALL_AS_NUMBERS; } LongSpace currentSpace = LongSpace.EMPTY; for (AristaBgpPeerFilterLine l : ImmutableList.copyOf(_lines.values()).reverse()) { if (l.getAction() == Action.ACCEPT) { currentSpace = currentSpace.union(l.getRange()); } else if (l.getAction() == Action.REJECT) { currentSpace = currentSpace.difference(l.getRange()); } else { throw new IllegalStateException( String.format("Unsupported bgp peer-filter action: %s", l.getAction())); } } return currentSpace; } AristaBgpPeerFilter(String name); String getName(); void addLine(LongSpace range, Action action); void addLine(int seq, LongSpace range, Action action); LongSpace toLongSpace();  }