|
| 1 | +/******************************************************************************* |
| 2 | + * Copyright (c) 2018 Contributors to the Eclipse Foundation |
| 3 | + * |
| 4 | + * See the NOTICE file(s) distributed with this work for additional |
| 5 | + * information regarding copyright ownership. |
| 6 | + * |
| 7 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 8 | + * You may not use this file except in compliance with the License. |
| 9 | + * You may obtain a copy of the License at |
| 10 | + * |
| 11 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 12 | + * |
| 13 | + * Unless required by applicable law or agreed to in writing, software |
| 14 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 15 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 16 | + * See the License for the specific language governing permissions and |
| 17 | + * limitations under the License. |
| 18 | + ******************************************************************************/ |
| 19 | + |
| 20 | +package org.eclipse.microprofile.reactive.streams; |
| 21 | + |
| 22 | +import org.eclipse.microprofile.reactive.streams.spi.Graph; |
| 23 | + |
| 24 | +/** |
| 25 | + * Exists to allow access to the {@code toGraph} methods on each builder, so that these methods don't have to be |
| 26 | + * exposed publicly in the API. |
| 27 | + * |
| 28 | + * This is intended only for use by implementations of the API, to get direct access to the graphs without having to |
| 29 | + * build a publisher, processor or subscriber. This is particularly useful for cases where an implementation would |
| 30 | + * like to do additional manipulation using its own API to the stream, but have those manipulations fused to the |
| 31 | + * graph being manipulated. |
| 32 | + */ |
| 33 | +public class GraphAccessor { |
| 34 | + |
| 35 | + private GraphAccessor() { |
| 36 | + } |
| 37 | + |
| 38 | + /** |
| 39 | + * Build the graph for the given {@link PublisherBuilder}. |
| 40 | + * |
| 41 | + * @param publisherBuilder The builder to build the graph for. |
| 42 | + * @return The built graph. |
| 43 | + */ |
| 44 | + public static Graph buildGraphFor(PublisherBuilder<?> publisherBuilder) { |
| 45 | + return publisherBuilder.toGraph(); |
| 46 | + } |
| 47 | + |
| 48 | + /** |
| 49 | + * Build the graph for the given {@link ProcessorBuilder}. |
| 50 | + * |
| 51 | + * @param processorBuilder The builder to build the graph for. |
| 52 | + * @return The built graph. |
| 53 | + */ |
| 54 | + public static Graph buildGraphFor(ProcessorBuilder<?, ?> processorBuilder) { |
| 55 | + return processorBuilder.toGraph(); |
| 56 | + } |
| 57 | + |
| 58 | + /** |
| 59 | + * Build the graph for the given {@link SubscriberBuilder}. |
| 60 | + * |
| 61 | + * @param subscriberBuilder The builder to build the graph for. |
| 62 | + * @return The built graph. |
| 63 | + */ |
| 64 | + public static Graph buildGraphFor(SubscriberBuilder<?, ?> subscriberBuilder) { |
| 65 | + return subscriberBuilder.toGraph(); |
| 66 | + } |
| 67 | + |
| 68 | + /** |
| 69 | + * Build the graph for the given {@link CompletionRunner}. |
| 70 | + * |
| 71 | + * @param completionRunner The runner to build the graph for. |
| 72 | + * @return The built graph. |
| 73 | + */ |
| 74 | + public static Graph buildGraphFor(CompletionRunner<?> completionRunner) { |
| 75 | + return completionRunner.toGraph(); |
| 76 | + } |
| 77 | + |
| 78 | +} |
0 commit comments