@Test public void testFilter3() { List<WeEvent> from = new ArrayList<>(); from.add(new WeEvent(topicName, content)); String[] topics = {}; List<WeEvent> to = Subscription.filter(from, topics, ""); Assert.assertTrue(to.isEmpty()); }
public static List<WeEvent> filter(List<WeEvent> from, String[] topics, String tag) { List<WeEvent> to = new ArrayList<>(); for (WeEvent event : from) { for (String topic : topics) { boolean topic_target = false; if (isTopicPattern(topic)) { if (patternMatch(event.getTopic(), topic)) { topic_target = true; } } else { if (topic.equals(event.getTopic())) { topic_target = true; } } if (topic_target) { if (StringUtils.isBlank(tag)) { to.add(event); } else { if (tag.equals(event.getExtensions().get(WeEvent.WeEvent_TAG))) { to.add(event); } } } } } return to; }
Subscription { public static List<WeEvent> filter(List<WeEvent> from, String[] topics, String tag) { List<WeEvent> to = new ArrayList<>(); for (WeEvent event : from) { for (String topic : topics) { boolean topic_target = false; if (isTopicPattern(topic)) { if (patternMatch(event.getTopic(), topic)) { topic_target = true; } } else { if (topic.equals(event.getTopic())) { topic_target = true; } } if (topic_target) { if (StringUtils.isBlank(tag)) { to.add(event); } else { if (tag.equals(event.getExtensions().get(WeEvent.WeEvent_TAG))) { to.add(event); } } } } } return to; } }
Subscription { public static List<WeEvent> filter(List<WeEvent> from, String[] topics, String tag) { List<WeEvent> to = new ArrayList<>(); for (WeEvent event : from) { for (String topic : topics) { boolean topic_target = false; if (isTopicPattern(topic)) { if (patternMatch(event.getTopic(), topic)) { topic_target = true; } } else { if (topic.equals(event.getTopic())) { topic_target = true; } } if (topic_target) { if (StringUtils.isBlank(tag)) { to.add(event); } else { if (tag.equals(event.getExtensions().get(WeEvent.WeEvent_TAG))) { to.add(event); } } } } } return to; } Subscription(IBlockChain blockChain, String uuid, String[] topics, String groupId, String offset, String tag, IConsumer.ConsumerListener listener); }
Subscription { public static List<WeEvent> filter(List<WeEvent> from, String[] topics, String tag) { List<WeEvent> to = new ArrayList<>(); for (WeEvent event : from) { for (String topic : topics) { boolean topic_target = false; if (isTopicPattern(topic)) { if (patternMatch(event.getTopic(), topic)) { topic_target = true; } } else { if (topic.equals(event.getTopic())) { topic_target = true; } } if (topic_target) { if (StringUtils.isBlank(tag)) { to.add(event); } else { if (tag.equals(event.getExtensions().get(WeEvent.WeEvent_TAG))) { to.add(event); } } } } } return to; } Subscription(IBlockChain blockChain, String uuid, String[] topics, String groupId, String offset, String tag, IConsumer.ConsumerListener listener); Long getNotifyingEventCount(); Long getNotifiedEventCount(); Date getNotifyTimeStamp(); void dispatch(List<WeEvent> events, boolean mainLoop, Long blockHeight); synchronized void doStart(Executor executor); synchronized void doStop(); synchronized void stopHistory(); synchronized boolean tryStopHistory(Long mainLastBlock); static List<WeEvent> filter(List<WeEvent> from, String[] topics, String tag); static boolean isTopicPattern(String pattern); static void validateTopicPattern(String pattern); static boolean patternMatch(String topic, String pattern); }
Subscription { public static List<WeEvent> filter(List<WeEvent> from, String[] topics, String tag) { List<WeEvent> to = new ArrayList<>(); for (WeEvent event : from) { for (String topic : topics) { boolean topic_target = false; if (isTopicPattern(topic)) { if (patternMatch(event.getTopic(), topic)) { topic_target = true; } } else { if (topic.equals(event.getTopic())) { topic_target = true; } } if (topic_target) { if (StringUtils.isBlank(tag)) { to.add(event); } else { if (tag.equals(event.getExtensions().get(WeEvent.WeEvent_TAG))) { to.add(event); } } } } } return to; } Subscription(IBlockChain blockChain, String uuid, String[] topics, String groupId, String offset, String tag, IConsumer.ConsumerListener listener); Long getNotifyingEventCount(); Long getNotifiedEventCount(); Date getNotifyTimeStamp(); void dispatch(List<WeEvent> events, boolean mainLoop, Long blockHeight); synchronized void doStart(Executor executor); synchronized void doStop(); synchronized void stopHistory(); synchronized boolean tryStopHistory(Long mainLastBlock); static List<WeEvent> filter(List<WeEvent> from, String[] topics, String tag); static boolean isTopicPattern(String pattern); static void validateTopicPattern(String pattern); static boolean patternMatch(String topic, String pattern);  }