@Override public CommandMessageFilter or(CommandMessageFilter other) { if (other instanceof CommandNameFilter) { return new CommandNameFilter( Stream.concat( commandNames.stream(), ((CommandNameFilter) other).commandNames.stream()) .collect(Collectors.toSet())); } else { return new OrCommandMessageFilter(this, other); } }
@Override public CommandMessageFilter and(CommandMessageFilter other) { if (other instanceof CommandNameFilter) { return new CommandNameFilter(commandNames.stream() .filter(((CommandNameFilter) other).commandNames::contains) .collect(Collectors.toSet())); } else { return (t) -> matches(t) && other.matches(t); } }
/** * {@inheritDoc} * <p/> * In the DistributedCommandBus, the handler is subscribed to the local segment only. */ @Override public Registration subscribe(String commandName, MessageHandler<? super CommandMessage<?>> handler) { Registration reg = connector.subscribe(commandName, handler); updateFilter(commandFilter.get().or(new CommandNameFilter(commandName))); return () -> { updateFilter(commandFilter.get().and(new DenyCommandNameFilter(commandName))); return reg.cancel(); }; }
@Override public Predicate<CommandMessage<?>> and(Predicate<? super CommandMessage<?>> other) { if (other instanceof CommandNameFilter) { return new CommandNameFilter(commandNames.stream() .filter(((CommandNameFilter) other).commandNames::contains) .collect(Collectors.toSet())); } else { return (t) -> test(t) && other.test(t); } }
@Override public Predicate<CommandMessage<?>> or(Predicate<? super CommandMessage<?>> other) { if (other instanceof CommandNameFilter) { return new CommandNameFilter( Stream.concat( commandNames.stream(), ((CommandNameFilter) other).commandNames.stream()) .collect(Collectors.toSet())); } else { return (t) -> test(t) || other.test(t); } }
@Override public CommandMessageFilter or(CommandMessageFilter other) { if (other instanceof CommandNameFilter) { return new CommandNameFilter( Stream.concat( commandNames.stream(), ((CommandNameFilter) other).commandNames.stream()) .collect(Collectors.toSet())); } else { return new OrCommandMessageFilter(this, other); } }
@Override public CommandMessageFilter and(CommandMessageFilter other) { if (other instanceof CommandNameFilter) { return new CommandNameFilter(commandNames.stream() .filter(((CommandNameFilter) other).commandNames::contains) .collect(Collectors.toSet())); } else { return (t) -> matches(t) && other.matches(t); } }
/** * {@inheritDoc} * <p/> * In the DistributedCommandBus, the handler is subscribed to the local segment only. */ @Override public Registration subscribe(String commandName, MessageHandler<? super CommandMessage<?>> handler) { Registration reg = connector.subscribe(commandName, handler); updateFilter(commandFilter.get().or(new CommandNameFilter(commandName))); return () -> { updateFilter(commandFilter.get().and(new DenyCommandNameFilter(commandName))); return reg.cancel(); }; }
/** * {@inheritDoc} * <p/> * In the DistributedCommandBus, the handler is subscribed to the local segment only. */ @Override public Registration subscribe(String commandName, MessageHandler<? super CommandMessage<?>> handler) { Registration reg = connector.subscribe(commandName, handler); updateFilter(commandFilter.get().or(new CommandNameFilter(commandName))); return () -> { updateFilter(commandFilter.get().and(new DenyCommandNameFilter(commandName))); return reg.cancel(); }; }