ClusterMetaComparatorVisitor implements MetaComparatorVisitor<ShardMeta> { @Override public void visitModified(MetaComparator comparator) { ((ShardMetaComparator)comparator).accept(new MetaComparatorVisitor<Redis>() { @Override public void visitAdded(Redis added) { if(added instanceof RedisMeta) { redisAdd.accept((RedisMeta) added); } } @Override public void visitModified(MetaComparator comparator) { logger.info("[visitModified][redis] {}", comparator); RedisComparator redisComparator = (RedisComparator) comparator; Redis current = redisComparator.getCurrent(), future = redisComparator.getFuture(); if(current instanceof RedisMeta && future instanceof RedisMeta) { if(((RedisMeta) current).isMaster() ^ ((RedisMeta) future).isMaster()) { redisChanged.accept((RedisMeta) future); } } } @Override public void visitRemoved(Redis removed) { if(removed instanceof RedisMeta) { redisDelete.accept((RedisMeta) removed); } } }); } ClusterMetaComparatorVisitor(Consumer<RedisMeta> redisAdd, Consumer<RedisMeta> redisDelete, Consumer<RedisMeta> redisChanged); @Override void visitAdded(ShardMeta added); @Override void visitModified(MetaComparator comparator); @Override void visitRemoved(ShardMeta removed);  }
@Test public void testVisitModified() { boolean trueVal = true, falseVal = false; System.out.println(true ^ false); System.out.println(false ^ false); System.out.println(true ^ true); System.out.println(false ^ true); }