/** * Create a Pattern Matcher on cyclops2-react adapter type (note this will only fold * on known types within the cyclops2-react library) * * <pre> * {@code * Adapter<Integer> adapter = QueueFactories.<Integer>unboundedQueue() * .build(); * * String result = Xors.adapter(adapter) .visit(queue->"we have a queue",topic->"we have a topic"); * * //"we have a queue" * } * </pre> * * @param adapter Adapter to fold on * @return Structural pattern matcher for Adapter types. */ public static <T> Either<Queue<T>, Topic<T>> adapter(final Adapter<T> adapter) { return adapter.matches(); }
/** * Create a Pattern Matcher on cyclops2-react adapter type (note this will only fold * on known types within the cyclops2-react library) * * <pre> * {@code * Adapter<Integer> adapter = QueueFactories.<Integer>unboundedQueue() * .build(); * * String result = Xors.adapter(adapter) .visit(queue->"we have a queue",topic->"we have a topic"); * * //"we have a queue" * } * </pre> * * @param adapter Adapter to fold on * @return Structural pattern matcher for Adapter types. */ public static <T> Either<Queue<T>, Topic<T>> adapter(final Adapter<T> adapter) { return adapter.matches(); }