├── .gitignore
├── .travis.yml
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── settings.gradle
└── src
├── main
└── java
│ └── rx
│ ├── joins
│ ├── ActivePlan0.java
│ ├── ActivePlan1.java
│ ├── ActivePlan2.java
│ ├── ActivePlan3.java
│ ├── ActivePlan4.java
│ ├── ActivePlan5.java
│ ├── ActivePlan6.java
│ ├── ActivePlan7.java
│ ├── ActivePlan8.java
│ ├── ActivePlan9.java
│ ├── ActivePlanN.java
│ ├── JoinObserver.java
│ ├── JoinObserver1.java
│ ├── Pattern.java
│ ├── Pattern1.java
│ ├── Pattern2.java
│ ├── Pattern3.java
│ ├── Pattern4.java
│ ├── Pattern5.java
│ ├── Pattern6.java
│ ├── Pattern7.java
│ ├── Pattern8.java
│ ├── Pattern9.java
│ ├── PatternN.java
│ ├── Plan0.java
│ ├── Plan1.java
│ ├── Plan2.java
│ ├── Plan3.java
│ ├── Plan4.java
│ ├── Plan5.java
│ ├── Plan6.java
│ ├── Plan7.java
│ ├── Plan8.java
│ ├── Plan9.java
│ ├── PlanN.java
│ └── operators
│ │ └── OperatorJoinPatterns.java
│ └── observables
│ └── JoinObservable.java
└── test
└── java
└── rx
└── joins
└── operators
├── OperatorJoinsTest.java
└── TestException.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled source #
2 | ###################
3 | *.com
4 | *.class
5 | *.dll
6 | *.exe
7 | *.o
8 | *.so
9 |
10 | # Packages #
11 | ############
12 | # it's better to unpack these files and commit the raw source
13 | # git has its own built in compression methods
14 | *.7z
15 | *.dmg
16 | *.gz
17 | *.iso
18 | *.jar
19 | *.rar
20 | *.tar
21 | *.zip
22 |
23 | # Logs and databases #
24 | ######################
25 | *.log
26 |
27 | # OS generated files #
28 | ######################
29 | .DS_Store*
30 | ehthumbs.db
31 | Icon?
32 | Thumbs.db
33 |
34 | # Editor Files #
35 | ################
36 | *~
37 | *.swp
38 |
39 | # Gradle Files #
40 | ################
41 | .gradle
42 | .gradletasknamecache
43 | .m2
44 |
45 | # Build output directies
46 | target/
47 | build/
48 |
49 | # IntelliJ specific files/directories
50 | out
51 | .idea
52 | *.ipr
53 | *.iws
54 | *.iml
55 | atlassian-ide-plugin.xml
56 |
57 | # Eclipse specific files/directories
58 | .classpath
59 | .project
60 | .settings
61 | .metadata
62 | bin/
63 |
64 | # NetBeans specific files/directories
65 | .nbattrs
66 | /.nb-gradle/profiles/private/
67 | .nb-gradle-properties
68 |
69 | # Scala build
70 | *.cache
71 | /.nb-gradle/private/
72 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: java
2 |
3 | jdk:
4 | - oraclejdk7
5 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing to RxJava
2 |
3 | If you would like to contribute code you can do so through GitHub by forking the repository and sending a pull request (on a branch other than `master` or `gh-pages`).
4 |
5 | When submitting code, please make every effort to follow existing conventions and style in order to keep the code as readable as possible.
6 |
7 | ## License
8 |
9 | By contributing your code, you agree to license your contribution under the terms of the APLv2: https://github.com/ReactiveX/RxJava/blob/master/LICENSE
10 |
11 | All files are released with the Apache 2.0 license.
12 |
13 | If you are adding a new file it should have a header like this:
14 |
15 | ```
16 | /**
17 | * Copyright 2014 Netflix, Inc.
18 | *
19 | * Licensed under the Apache License, Version 2.0 (the "License");
20 | * you may not use this file except in compliance with the License.
21 | * You may obtain a copy of the License at
22 | *
23 | * http://www.apache.org/licenses/LICENSE-2.0
24 | *
25 | * Unless required by applicable law or agreed to in writing, software
26 | * distributed under the License is distributed on an "AS IS" BASIS,
27 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28 | * See the License for the specific language governing permissions and
29 | * limitations under the License.
30 | */
31 | ```
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 |
2 | Apache License
3 | Version 2.0, January 2004
4 | http://www.apache.org/licenses/
5 |
6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7 |
8 | 1. Definitions.
9 |
10 | "License" shall mean the terms and conditions for use, reproduction,
11 | and distribution as defined by Sections 1 through 9 of this document.
12 |
13 | "Licensor" shall mean the copyright owner or entity authorized by
14 | the copyright owner that is granting the License.
15 |
16 | "Legal Entity" shall mean the union of the acting entity and all
17 | other entities that control, are controlled by, or are under common
18 | control with that entity. For the purposes of this definition,
19 | "control" means (i) the power, direct or indirect, to cause the
20 | direction or management of such entity, whether by contract or
21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
22 | outstanding shares, or (iii) beneficial ownership of such entity.
23 |
24 | "You" (or "Your") shall mean an individual or Legal Entity
25 | exercising permissions granted by this License.
26 |
27 | "Source" form shall mean the preferred form for making modifications,
28 | including but not limited to software source code, documentation
29 | source, and configuration files.
30 |
31 | "Object" form shall mean any form resulting from mechanical
32 | transformation or translation of a Source form, including but
33 | not limited to compiled object code, generated documentation,
34 | and conversions to other media types.
35 |
36 | "Work" shall mean the work of authorship, whether in Source or
37 | Object form, made available under the License, as indicated by a
38 | copyright notice that is included in or attached to the work
39 | (an example is provided in the Appendix below).
40 |
41 | "Derivative Works" shall mean any work, whether in Source or Object
42 | form, that is based on (or derived from) the Work and for which the
43 | editorial revisions, annotations, elaborations, or other modifications
44 | represent, as a whole, an original work of authorship. For the purposes
45 | of this License, Derivative Works shall not include works that remain
46 | separable from, or merely link (or bind by name) to the interfaces of,
47 | the Work and Derivative Works thereof.
48 |
49 | "Contribution" shall mean any work of authorship, including
50 | the original version of the Work and any modifications or additions
51 | to that Work or Derivative Works thereof, that is intentionally
52 | submitted to Licensor for inclusion in the Work by the copyright owner
53 | or by an individual or Legal Entity authorized to submit on behalf of
54 | the copyright owner. For the purposes of this definition, "submitted"
55 | means any form of electronic, verbal, or written communication sent
56 | to the Licensor or its representatives, including but not limited to
57 | communication on electronic mailing lists, source code control systems,
58 | and issue tracking systems that are managed by, or on behalf of, the
59 | Licensor for the purpose of discussing and improving the Work, but
60 | excluding communication that is conspicuously marked or otherwise
61 | designated in writing by the copyright owner as "Not a Contribution."
62 |
63 | "Contributor" shall mean Licensor and any individual or Legal Entity
64 | on behalf of whom a Contribution has been received by Licensor and
65 | subsequently incorporated within the Work.
66 |
67 | 2. Grant of Copyright License. Subject to the terms and conditions of
68 | this License, each Contributor hereby grants to You a perpetual,
69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70 | copyright license to reproduce, prepare Derivative Works of,
71 | publicly display, publicly perform, sublicense, and distribute the
72 | Work and such Derivative Works in Source or Object form.
73 |
74 | 3. Grant of Patent License. Subject to the terms and conditions of
75 | this License, each Contributor hereby grants to You a perpetual,
76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77 | (except as stated in this section) patent license to make, have made,
78 | use, offer to sell, sell, import, and otherwise transfer the Work,
79 | where such license applies only to those patent claims licensable
80 | by such Contributor that are necessarily infringed by their
81 | Contribution(s) alone or by combination of their Contribution(s)
82 | with the Work to which such Contribution(s) was submitted. If You
83 | institute patent litigation against any entity (including a
84 | cross-claim or counterclaim in a lawsuit) alleging that the Work
85 | or a Contribution incorporated within the Work constitutes direct
86 | or contributory patent infringement, then any patent licenses
87 | granted to You under this License for that Work shall terminate
88 | as of the date such litigation is filed.
89 |
90 | 4. Redistribution. You may reproduce and distribute copies of the
91 | Work or Derivative Works thereof in any medium, with or without
92 | modifications, and in Source or Object form, provided that You
93 | meet the following conditions:
94 |
95 | (a) You must give any other recipients of the Work or
96 | Derivative Works a copy of this License; and
97 |
98 | (b) You must cause any modified files to carry prominent notices
99 | stating that You changed the files; and
100 |
101 | (c) You must retain, in the Source form of any Derivative Works
102 | that You distribute, all copyright, patent, trademark, and
103 | attribution notices from the Source form of the Work,
104 | excluding those notices that do not pertain to any part of
105 | the Derivative Works; and
106 |
107 | (d) If the Work includes a "NOTICE" text file as part of its
108 | distribution, then any Derivative Works that You distribute must
109 | include a readable copy of the attribution notices contained
110 | within such NOTICE file, excluding those notices that do not
111 | pertain to any part of the Derivative Works, in at least one
112 | of the following places: within a NOTICE text file distributed
113 | as part of the Derivative Works; within the Source form or
114 | documentation, if provided along with the Derivative Works; or,
115 | within a display generated by the Derivative Works, if and
116 | wherever such third-party notices normally appear. The contents
117 | of the NOTICE file are for informational purposes only and
118 | do not modify the License. You may add Your own attribution
119 | notices within Derivative Works that You distribute, alongside
120 | or as an addendum to the NOTICE text from the Work, provided
121 | that such additional attribution notices cannot be construed
122 | as modifying the License.
123 |
124 | You may add Your own copyright statement to Your modifications and
125 | may provide additional or different license terms and conditions
126 | for use, reproduction, or distribution of Your modifications, or
127 | for any such Derivative Works as a whole, provided Your use,
128 | reproduction, and distribution of the Work otherwise complies with
129 | the conditions stated in this License.
130 |
131 | 5. Submission of Contributions. Unless You explicitly state otherwise,
132 | any Contribution intentionally submitted for inclusion in the Work
133 | by You to the Licensor shall be under the terms and conditions of
134 | this License, without any additional terms or conditions.
135 | Notwithstanding the above, nothing herein shall supersede or modify
136 | the terms of any separate license agreement you may have executed
137 | with Licensor regarding such Contributions.
138 |
139 | 6. Trademarks. This License does not grant permission to use the trade
140 | names, trademarks, service marks, or product names of the Licensor,
141 | except as required for reasonable and customary use in describing the
142 | origin of the Work and reproducing the content of the NOTICE file.
143 |
144 | 7. Disclaimer of Warranty. Unless required by applicable law or
145 | agreed to in writing, Licensor provides the Work (and each
146 | Contributor provides its Contributions) on an "AS IS" BASIS,
147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148 | implied, including, without limitation, any warranties or conditions
149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150 | PARTICULAR PURPOSE. You are solely responsible for determining the
151 | appropriateness of using or redistributing the Work and assume any
152 | risks associated with Your exercise of permissions under this License.
153 |
154 | 8. Limitation of Liability. In no event and under no legal theory,
155 | whether in tort (including negligence), contract, or otherwise,
156 | unless required by applicable law (such as deliberate and grossly
157 | negligent acts) or agreed to in writing, shall any Contributor be
158 | liable to You for damages, including any direct, indirect, special,
159 | incidental, or consequential damages of any character arising as a
160 | result of this License or out of the use or inability to use the
161 | Work (including but not limited to damages for loss of goodwill,
162 | work stoppage, computer failure or malfunction, or any and all
163 | other commercial damages or losses), even if such Contributor
164 | has been advised of the possibility of such damages.
165 |
166 | 9. Accepting Warranty or Additional Liability. While redistributing
167 | the Work or Derivative Works thereof, You may choose to offer,
168 | and charge a fee for, acceptance of support, warranty, indemnity,
169 | or other liability obligations and/or rights consistent with this
170 | License. However, in accepting such obligations, You may act only
171 | on Your own behalf and on Your sole responsibility, not on behalf
172 | of any other Contributor, and only if You agree to indemnify,
173 | defend, and hold each Contributor harmless for any liability
174 | incurred by, or claims asserted against, such Contributor by reason
175 | of your accepting any such warranty or additional liability.
176 |
177 | END OF TERMS AND CONDITIONS
178 |
179 | APPENDIX: How to apply the Apache License to your work.
180 |
181 | To apply the Apache License to your work, attach the following
182 | boilerplate notice, with the fields enclosed by brackets "[]"
183 | replaced with your own identifying information. (Don't include
184 | the brackets!) The text should be enclosed in the appropriate
185 | comment syntax for the file format. We also recommend that a
186 | file or class name and description of purpose be included on the
187 | same "printed page" as the copyright notice for easier
188 | identification within third-party archives.
189 |
190 | Copyright 2012 Netflix, Inc.
191 |
192 | Licensed under the Apache License, Version 2.0 (the "License");
193 | you may not use this file except in compliance with the License.
194 | You may obtain a copy of the License at
195 |
196 | http://www.apache.org/licenses/LICENSE-2.0
197 |
198 | Unless required by applicable law or agreed to in writing, software
199 | distributed under the License is distributed on an "AS IS" BASIS,
200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201 | See the License for the specific language governing permissions and
202 | limitations under the License.
203 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # RxJava Joins
2 |
3 | Joins operators for [RxJava](https://github.com/ReactiveX/RxJava).
4 |
5 | ## Master Build Status
6 |
7 |
8 |
9 | ## Communication
10 |
11 | - Google Group: [RxJava](http://groups.google.com/d/forum/rxjava)
12 | - Twitter: [@RxJava](http://twitter.com/RxJava)
13 | - [GitHub Issues](https://github.com/ReactiveX/RxJavaJoins/issues)
14 |
15 |
16 | ## Binaries
17 |
18 | Binaries and dependency information for Maven, Ivy, Gradle and others can be found at [http://search.maven.org](http://search.maven.org/#search%7Cga%7C1%7Cio.reactivex.rxjava-joins).
19 |
20 | Example for Maven:
21 |
22 | ```xml
23 |
24 | io.reactivex
25 | rxjava-joins
26 | x.y.z
27 |
28 | ```
29 | for Ivy:
30 |
31 | ```xml
32 |
33 | ```
34 |
35 | and for Gradle:
36 | ```groovy
37 | compile 'io.reactivex:rxjava-joins:0.22.0'
38 | ```
39 | ## Build
40 |
41 | To build:
42 |
43 | ```
44 | $ git clone git@github.com:ReactiveX/RxJavaJoins.git
45 | $ cd RxJavaJoins/
46 | $ ./gradlew build
47 | ```
48 |
49 | ## Bugs and Feedback
50 |
51 | For bugs, questions and discussions please use the [Github Issues](https://github.com/ReactiveX/RxJavaJoins/issues).
52 |
53 |
54 | ## LICENSE
55 |
56 | Licensed under the Apache License, Version 2.0 (the "License");
57 | you may not use this file except in compliance with the License.
58 | You may obtain a copy of the License at
59 |
60 |
61 |
62 | Unless required by applicable law or agreed to in writing, software
63 | distributed under the License is distributed on an "AS IS" BASIS,
64 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
65 | See the License for the specific language governing permissions and
66 | limitations under the License.
67 |
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | repositories { jcenter() }
3 | dependencies { classpath 'com.netflix.nebula:gradle-rxjava-project-plugin:2.+' }
4 | }
5 |
6 | apply plugin: 'rxjava-project'
7 | apply plugin: 'java'
8 |
9 | dependencies {
10 | compile 'io.reactivex:rxjava:1.0.+'
11 | testCompile 'junit:junit-dep:4.10'
12 | testCompile 'org.mockito:mockito-core:1.8.5'
13 | }
14 |
15 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | version=1.0.0-RC1-SNAPSHOT
2 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ReactiveX/RxJavaJoins/65b5c7fa03bd375c9e1f7906d7143068fde9b714/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Wed Feb 05 12:05:54 CET 2014
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-bin.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # For Cygwin, ensure paths are in UNIX format before anything is touched.
46 | if $cygwin ; then
47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
48 | fi
49 |
50 | # Attempt to set APP_HOME
51 | # Resolve links: $0 may be a link
52 | PRG="$0"
53 | # Need this for relative symlinks.
54 | while [ -h "$PRG" ] ; do
55 | ls=`ls -ld "$PRG"`
56 | link=`expr "$ls" : '.*-> \(.*\)$'`
57 | if expr "$link" : '/.*' > /dev/null; then
58 | PRG="$link"
59 | else
60 | PRG=`dirname "$PRG"`"/$link"
61 | fi
62 | done
63 | SAVED="`pwd`"
64 | cd "`dirname \"$PRG\"`/" >&-
65 | APP_HOME="`pwd -P`"
66 | cd "$SAVED" >&-
67 |
68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
69 |
70 | # Determine the Java command to use to start the JVM.
71 | if [ -n "$JAVA_HOME" ] ; then
72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
73 | # IBM's JDK on AIX uses strange locations for the executables
74 | JAVACMD="$JAVA_HOME/jre/sh/java"
75 | else
76 | JAVACMD="$JAVA_HOME/bin/java"
77 | fi
78 | if [ ! -x "$JAVACMD" ] ; then
79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
80 |
81 | Please set the JAVA_HOME variable in your environment to match the
82 | location of your Java installation."
83 | fi
84 | else
85 | JAVACMD="java"
86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
87 |
88 | Please set the JAVA_HOME variable in your environment to match the
89 | location of your Java installation."
90 | fi
91 |
92 | # Increase the maximum file descriptors if we can.
93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
94 | MAX_FD_LIMIT=`ulimit -H -n`
95 | if [ $? -eq 0 ] ; then
96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
97 | MAX_FD="$MAX_FD_LIMIT"
98 | fi
99 | ulimit -n $MAX_FD
100 | if [ $? -ne 0 ] ; then
101 | warn "Could not set maximum file descriptor limit: $MAX_FD"
102 | fi
103 | else
104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
105 | fi
106 | fi
107 |
108 | # For Darwin, add options to specify how the application appears in the dock
109 | if $darwin; then
110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
111 | fi
112 |
113 | # For Cygwin, switch paths to Windows format before running java
114 | if $cygwin ; then
115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
117 |
118 | # We build the pattern for arguments to be converted via cygpath
119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120 | SEP=""
121 | for dir in $ROOTDIRSRAW ; do
122 | ROOTDIRS="$ROOTDIRS$SEP$dir"
123 | SEP="|"
124 | done
125 | OURCYGPATTERN="(^($ROOTDIRS))"
126 | # Add a user-defined pattern to the cygpath arguments
127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129 | fi
130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
131 | i=0
132 | for arg in "$@" ; do
133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135 |
136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138 | else
139 | eval `echo args$i`="\"$arg\""
140 | fi
141 | i=$((i+1))
142 | done
143 | case $i in
144 | (0) set -- ;;
145 | (1) set -- "$args0" ;;
146 | (2) set -- "$args0" "$args1" ;;
147 | (3) set -- "$args0" "$args1" "$args2" ;;
148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154 | esac
155 | fi
156 |
157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
158 | function splitJvmOpts() {
159 | JVM_OPTS=("$@")
160 | }
161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
163 |
164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
165 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name='rxjava-joins'
2 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan0.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package rx.joins;
17 |
18 | import java.util.HashMap;
19 | import java.util.Map;
20 |
21 | /**
22 | * Represents an activated plan.
23 | */
24 | public abstract class ActivePlan0 {
25 | protected final Map joinObservers = new HashMap();
26 |
27 | protected abstract void match();
28 |
29 | protected void addJoinObserver(JoinObserver joinObserver) {
30 | joinObservers.put(joinObserver, joinObserver);
31 | }
32 |
33 | protected void dequeue() {
34 | for (JoinObserver jo : joinObservers.values()) {
35 | jo.dequeue();
36 | }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan1.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action1;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan1 extends ActivePlan0 {
26 | private final Action1 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 |
30 | ActivePlan1(JoinObserver1 jo1, Action1 onNext, Action0 onCompleted) {
31 | this.onNext = onNext;
32 | this.onCompleted = onCompleted;
33 | this.jo1 = jo1;
34 | addJoinObserver(jo1);
35 | }
36 |
37 | @Override
38 | protected void match() {
39 | if (!jo1.queue().isEmpty()) {
40 | Notification n1 = jo1.queue().peek();
41 | if (n1.isOnCompleted()) {
42 | onCompleted.call();
43 | } else {
44 | dequeue();
45 | onNext.call(n1.getValue());
46 | }
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan2.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action2;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan2 extends ActivePlan0 {
26 | private final Action2 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 | private final JoinObserver1 jo2;
30 |
31 | ActivePlan2(JoinObserver1 jo1, JoinObserver1 jo2, Action2 onNext, Action0 onCompleted) {
32 | this.onNext = onNext;
33 | this.onCompleted = onCompleted;
34 | this.jo1 = jo1;
35 | this.jo2 = jo2;
36 | addJoinObserver(jo1);
37 | addJoinObserver(jo2);
38 | }
39 |
40 | @Override
41 | protected void match() {
42 | if (!jo1.queue().isEmpty() && !jo2.queue().isEmpty()) {
43 | Notification n1 = jo1.queue().peek();
44 | Notification n2 = jo2.queue().peek();
45 |
46 | if (n1.isOnCompleted() || n2.isOnCompleted()) {
47 | onCompleted.call();
48 | } else {
49 | dequeue();
50 | onNext.call(n1.getValue(), n2.getValue());
51 | }
52 | }
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan3.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action3;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan3 extends ActivePlan0 {
26 | private final Action3 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 first;
29 | private final JoinObserver1 second;
30 | private final JoinObserver1 third;
31 |
32 | ActivePlan3(JoinObserver1 first,
33 | JoinObserver1 second,
34 | JoinObserver1 third,
35 | Action3 onNext,
36 | Action0 onCompleted) {
37 | this.onNext = onNext;
38 | this.onCompleted = onCompleted;
39 | this.first = first;
40 | this.second = second;
41 | this.third = third;
42 | addJoinObserver(first);
43 | addJoinObserver(second);
44 | addJoinObserver(third);
45 | }
46 |
47 | @Override
48 | protected void match() {
49 | if (!first.queue().isEmpty()
50 | && !second.queue().isEmpty()
51 | && !third.queue().isEmpty()) {
52 | Notification n1 = first.queue().peek();
53 | Notification n2 = second.queue().peek();
54 | Notification n3 = third.queue().peek();
55 |
56 | if (n1.isOnCompleted() || n2.isOnCompleted() || n3.isOnCompleted()) {
57 | onCompleted.call();
58 | } else {
59 | dequeue();
60 | onNext.call(n1.getValue(), n2.getValue(), n3.getValue());
61 | }
62 | }
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan4.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action4;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan4 extends ActivePlan0 {
26 | private final Action4 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 | private final JoinObserver1 jo2;
30 | private final JoinObserver1 jo3;
31 | private final JoinObserver1 jo4;
32 |
33 | ActivePlan4(
34 | JoinObserver1 jo1,
35 | JoinObserver1 jo2,
36 | JoinObserver1 jo3,
37 | JoinObserver1 jo4,
38 | Action4 onNext,
39 | Action0 onCompleted) {
40 | this.onNext = onNext;
41 | this.onCompleted = onCompleted;
42 | this.jo1 = jo1;
43 | this.jo2 = jo2;
44 | this.jo3 = jo3;
45 | this.jo4 = jo4;
46 | addJoinObserver(jo1);
47 | addJoinObserver(jo2);
48 | addJoinObserver(jo3);
49 | addJoinObserver(jo4);
50 | }
51 |
52 | @Override
53 | protected void match() {
54 | if (!jo1.queue().isEmpty()
55 | && !jo2.queue().isEmpty()
56 | && !jo3.queue().isEmpty()
57 | && !jo4.queue().isEmpty()) {
58 | Notification n1 = jo1.queue().peek();
59 | Notification n2 = jo2.queue().peek();
60 | Notification n3 = jo3.queue().peek();
61 | Notification n4 = jo4.queue().peek();
62 |
63 | if (n1.isOnCompleted()
64 | || n2.isOnCompleted()
65 | || n3.isOnCompleted()
66 | || n4.isOnCompleted()) {
67 | onCompleted.call();
68 | } else {
69 | dequeue();
70 | onNext.call(n1.getValue(), n2.getValue(), n3.getValue(), n4.getValue());
71 | }
72 | }
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan5.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action5;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan5 extends ActivePlan0 {
26 | private final Action5 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 | private final JoinObserver1 jo2;
30 | private final JoinObserver1 jo3;
31 | private final JoinObserver1 jo4;
32 | private final JoinObserver1 jo5;
33 |
34 | ActivePlan5(
35 | JoinObserver1 jo1,
36 | JoinObserver1 jo2,
37 | JoinObserver1 jo3,
38 | JoinObserver1 jo4,
39 | JoinObserver1 jo5,
40 | Action5 onNext,
41 | Action0 onCompleted) {
42 | this.onNext = onNext;
43 | this.onCompleted = onCompleted;
44 | this.jo1 = jo1;
45 | this.jo2 = jo2;
46 | this.jo3 = jo3;
47 | this.jo4 = jo4;
48 | this.jo5 = jo5;
49 | addJoinObserver(jo1);
50 | addJoinObserver(jo2);
51 | addJoinObserver(jo3);
52 | addJoinObserver(jo4);
53 | addJoinObserver(jo5);
54 | }
55 |
56 | @Override
57 | protected void match() {
58 | if (!jo1.queue().isEmpty()
59 | && !jo2.queue().isEmpty()
60 | && !jo3.queue().isEmpty()
61 | && !jo4.queue().isEmpty()
62 | && !jo5.queue().isEmpty()
63 | ) {
64 | Notification n1 = jo1.queue().peek();
65 | Notification n2 = jo2.queue().peek();
66 | Notification n3 = jo3.queue().peek();
67 | Notification n4 = jo4.queue().peek();
68 | Notification n5 = jo5.queue().peek();
69 |
70 | if (n1.isOnCompleted()
71 | || n2.isOnCompleted()
72 | || n3.isOnCompleted()
73 | || n4.isOnCompleted()
74 | || n5.isOnCompleted()
75 | ) {
76 | onCompleted.call();
77 | } else {
78 | dequeue();
79 | onNext.call(
80 | n1.getValue(),
81 | n2.getValue(),
82 | n3.getValue(),
83 | n4.getValue(),
84 | n5.getValue()
85 | );
86 | }
87 | }
88 | }
89 |
90 | }
91 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan6.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action6;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan6 extends ActivePlan0 {
26 | private final Action6 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 | private final JoinObserver1 jo2;
30 | private final JoinObserver1 jo3;
31 | private final JoinObserver1 jo4;
32 | private final JoinObserver1 jo5;
33 | private final JoinObserver1 jo6;
34 |
35 | ActivePlan6(
36 | JoinObserver1 jo1,
37 | JoinObserver1 jo2,
38 | JoinObserver1 jo3,
39 | JoinObserver1 jo4,
40 | JoinObserver1 jo5,
41 | JoinObserver1 jo6,
42 | Action6 onNext,
43 | Action0 onCompleted) {
44 | this.onNext = onNext;
45 | this.onCompleted = onCompleted;
46 | this.jo1 = jo1;
47 | this.jo2 = jo2;
48 | this.jo3 = jo3;
49 | this.jo4 = jo4;
50 | this.jo5 = jo5;
51 | this.jo6 = jo6;
52 | addJoinObserver(jo1);
53 | addJoinObserver(jo2);
54 | addJoinObserver(jo3);
55 | addJoinObserver(jo4);
56 | addJoinObserver(jo5);
57 | addJoinObserver(jo6);
58 | }
59 |
60 | @Override
61 | protected void match() {
62 | if (!jo1.queue().isEmpty()
63 | && !jo2.queue().isEmpty()
64 | && !jo3.queue().isEmpty()
65 | && !jo4.queue().isEmpty()
66 | && !jo5.queue().isEmpty()
67 | && !jo6.queue().isEmpty()
68 | ) {
69 | Notification n1 = jo1.queue().peek();
70 | Notification n2 = jo2.queue().peek();
71 | Notification n3 = jo3.queue().peek();
72 | Notification n4 = jo4.queue().peek();
73 | Notification n5 = jo5.queue().peek();
74 | Notification n6 = jo6.queue().peek();
75 |
76 | if (n1.isOnCompleted()
77 | || n2.isOnCompleted()
78 | || n3.isOnCompleted()
79 | || n4.isOnCompleted()
80 | || n5.isOnCompleted()
81 | || n6.isOnCompleted()
82 | ) {
83 | onCompleted.call();
84 | } else {
85 | dequeue();
86 | onNext.call(
87 | n1.getValue(),
88 | n2.getValue(),
89 | n3.getValue(),
90 | n4.getValue(),
91 | n5.getValue(),
92 | n6.getValue()
93 | );
94 | }
95 | }
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan7.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action7;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan7 extends ActivePlan0 {
26 | private final Action7 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 | private final JoinObserver1 jo2;
30 | private final JoinObserver1 jo3;
31 | private final JoinObserver1 jo4;
32 | private final JoinObserver1 jo5;
33 | private final JoinObserver1 jo6;
34 | private final JoinObserver1 jo7;
35 |
36 | ActivePlan7(
37 | JoinObserver1 jo1,
38 | JoinObserver1 jo2,
39 | JoinObserver1 jo3,
40 | JoinObserver1 jo4,
41 | JoinObserver1 jo5,
42 | JoinObserver1 jo6,
43 | JoinObserver1 jo7,
44 | Action7 onNext,
45 | Action0 onCompleted) {
46 | this.onNext = onNext;
47 | this.onCompleted = onCompleted;
48 | this.jo1 = jo1;
49 | this.jo2 = jo2;
50 | this.jo3 = jo3;
51 | this.jo4 = jo4;
52 | this.jo5 = jo5;
53 | this.jo6 = jo6;
54 | this.jo7 = jo7;
55 | addJoinObserver(jo1);
56 | addJoinObserver(jo2);
57 | addJoinObserver(jo3);
58 | addJoinObserver(jo4);
59 | addJoinObserver(jo5);
60 | addJoinObserver(jo6);
61 | addJoinObserver(jo7);
62 | }
63 |
64 | @Override
65 | protected void match() {
66 | if (!jo1.queue().isEmpty()
67 | && !jo2.queue().isEmpty()
68 | && !jo3.queue().isEmpty()
69 | && !jo4.queue().isEmpty()
70 | && !jo5.queue().isEmpty()
71 | && !jo6.queue().isEmpty()
72 | && !jo7.queue().isEmpty()
73 | ) {
74 | Notification n1 = jo1.queue().peek();
75 | Notification n2 = jo2.queue().peek();
76 | Notification n3 = jo3.queue().peek();
77 | Notification n4 = jo4.queue().peek();
78 | Notification n5 = jo5.queue().peek();
79 | Notification n6 = jo6.queue().peek();
80 | Notification n7 = jo7.queue().peek();
81 |
82 | if (n1.isOnCompleted()
83 | || n2.isOnCompleted()
84 | || n3.isOnCompleted()
85 | || n4.isOnCompleted()
86 | || n5.isOnCompleted()
87 | || n6.isOnCompleted()
88 | || n7.isOnCompleted()
89 | ) {
90 | onCompleted.call();
91 | } else {
92 | dequeue();
93 | onNext.call(
94 | n1.getValue(),
95 | n2.getValue(),
96 | n3.getValue(),
97 | n4.getValue(),
98 | n5.getValue(),
99 | n6.getValue(),
100 | n7.getValue()
101 | );
102 | }
103 | }
104 | }
105 |
106 | }
107 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan8.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action8;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan8 extends ActivePlan0 {
26 | private final Action8 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 | private final JoinObserver1 jo2;
30 | private final JoinObserver1 jo3;
31 | private final JoinObserver1 jo4;
32 | private final JoinObserver1 jo5;
33 | private final JoinObserver1 jo6;
34 | private final JoinObserver1 jo7;
35 | private final JoinObserver1 jo8;
36 |
37 | ActivePlan8(
38 | JoinObserver1 jo1,
39 | JoinObserver1 jo2,
40 | JoinObserver1 jo3,
41 | JoinObserver1 jo4,
42 | JoinObserver1 jo5,
43 | JoinObserver1 jo6,
44 | JoinObserver1 jo7,
45 | JoinObserver1 jo8,
46 | Action8 onNext,
47 | Action0 onCompleted) {
48 | this.onNext = onNext;
49 | this.onCompleted = onCompleted;
50 | this.jo1 = jo1;
51 | this.jo2 = jo2;
52 | this.jo3 = jo3;
53 | this.jo4 = jo4;
54 | this.jo5 = jo5;
55 | this.jo6 = jo6;
56 | this.jo7 = jo7;
57 | this.jo8 = jo8;
58 | addJoinObserver(jo1);
59 | addJoinObserver(jo2);
60 | addJoinObserver(jo3);
61 | addJoinObserver(jo4);
62 | addJoinObserver(jo5);
63 | addJoinObserver(jo6);
64 | addJoinObserver(jo7);
65 | addJoinObserver(jo8);
66 | }
67 |
68 | @Override
69 | protected void match() {
70 | if (!jo1.queue().isEmpty()
71 | && !jo2.queue().isEmpty()
72 | && !jo3.queue().isEmpty()
73 | && !jo4.queue().isEmpty()
74 | && !jo5.queue().isEmpty()
75 | && !jo6.queue().isEmpty()
76 | && !jo7.queue().isEmpty()
77 | && !jo8.queue().isEmpty()
78 | ) {
79 | Notification n1 = jo1.queue().peek();
80 | Notification n2 = jo2.queue().peek();
81 | Notification n3 = jo3.queue().peek();
82 | Notification n4 = jo4.queue().peek();
83 | Notification n5 = jo5.queue().peek();
84 | Notification n6 = jo6.queue().peek();
85 | Notification n7 = jo7.queue().peek();
86 | Notification n8 = jo8.queue().peek();
87 |
88 | if (n1.isOnCompleted()
89 | || n2.isOnCompleted()
90 | || n3.isOnCompleted()
91 | || n4.isOnCompleted()
92 | || n5.isOnCompleted()
93 | || n6.isOnCompleted()
94 | || n7.isOnCompleted()
95 | || n8.isOnCompleted()
96 | ) {
97 | onCompleted.call();
98 | } else {
99 | dequeue();
100 | onNext.call(
101 | n1.getValue(),
102 | n2.getValue(),
103 | n3.getValue(),
104 | n4.getValue(),
105 | n5.getValue(),
106 | n6.getValue(),
107 | n7.getValue(),
108 | n8.getValue()
109 | );
110 | }
111 | }
112 | }
113 |
114 | }
115 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlan9.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Notification;
19 | import rx.functions.Action0;
20 | import rx.functions.Action9;
21 |
22 | /**
23 | * Represents an active plan.
24 | */
25 | public final class ActivePlan9 extends ActivePlan0 {
26 | private final Action9 onNext;
27 | private final Action0 onCompleted;
28 | private final JoinObserver1 jo1;
29 | private final JoinObserver1 jo2;
30 | private final JoinObserver1 jo3;
31 | private final JoinObserver1 jo4;
32 | private final JoinObserver1 jo5;
33 | private final JoinObserver1 jo6;
34 | private final JoinObserver1 jo7;
35 | private final JoinObserver1 jo8;
36 | private final JoinObserver1 jo9;
37 |
38 | ActivePlan9(
39 | JoinObserver1 jo1,
40 | JoinObserver1 jo2,
41 | JoinObserver1 jo3,
42 | JoinObserver1 jo4,
43 | JoinObserver1 jo5,
44 | JoinObserver1 jo6,
45 | JoinObserver1 jo7,
46 | JoinObserver1 jo8,
47 | JoinObserver1 jo9,
48 | Action9 onNext,
49 | Action0 onCompleted) {
50 | this.onNext = onNext;
51 | this.onCompleted = onCompleted;
52 | this.jo1 = jo1;
53 | this.jo2 = jo2;
54 | this.jo3 = jo3;
55 | this.jo4 = jo4;
56 | this.jo5 = jo5;
57 | this.jo6 = jo6;
58 | this.jo7 = jo7;
59 | this.jo8 = jo8;
60 | this.jo9 = jo9;
61 | addJoinObserver(jo1);
62 | addJoinObserver(jo2);
63 | addJoinObserver(jo3);
64 | addJoinObserver(jo4);
65 | addJoinObserver(jo5);
66 | addJoinObserver(jo6);
67 | addJoinObserver(jo7);
68 | addJoinObserver(jo8);
69 | addJoinObserver(jo9);
70 | }
71 |
72 | @Override
73 | protected void match() {
74 | if (!jo1.queue().isEmpty()
75 | && !jo2.queue().isEmpty()
76 | && !jo3.queue().isEmpty()
77 | && !jo4.queue().isEmpty()
78 | && !jo5.queue().isEmpty()
79 | && !jo6.queue().isEmpty()
80 | && !jo7.queue().isEmpty()
81 | && !jo8.queue().isEmpty()
82 | && !jo9.queue().isEmpty()
83 | ) {
84 | Notification n1 = jo1.queue().peek();
85 | Notification n2 = jo2.queue().peek();
86 | Notification n3 = jo3.queue().peek();
87 | Notification n4 = jo4.queue().peek();
88 | Notification n5 = jo5.queue().peek();
89 | Notification n6 = jo6.queue().peek();
90 | Notification n7 = jo7.queue().peek();
91 | Notification n8 = jo8.queue().peek();
92 | Notification n9 = jo9.queue().peek();
93 |
94 | if (n1.isOnCompleted()
95 | || n2.isOnCompleted()
96 | || n3.isOnCompleted()
97 | || n4.isOnCompleted()
98 | || n5.isOnCompleted()
99 | || n6.isOnCompleted()
100 | || n7.isOnCompleted()
101 | || n8.isOnCompleted()
102 | || n9.isOnCompleted()
103 | ) {
104 | onCompleted.call();
105 | } else {
106 | dequeue();
107 | onNext.call(
108 | n1.getValue(),
109 | n2.getValue(),
110 | n3.getValue(),
111 | n4.getValue(),
112 | n5.getValue(),
113 | n6.getValue(),
114 | n7.getValue(),
115 | n8.getValue(),
116 | n9.getValue()
117 | );
118 | }
119 | }
120 | }
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/ActivePlanN.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | import rx.Notification;
22 | import rx.functions.Action0;
23 | import rx.functions.ActionN;
24 |
25 | /**
26 | * Represents an active plan.
27 | */
28 | public final class ActivePlanN extends ActivePlan0 {
29 | private final ActionN onNext;
30 | private final Action0 onCompleted;
31 | private final List> observers;
32 |
33 | ActivePlanN(List> observers,
34 | ActionN onNext,
35 | Action0 onCompleted) {
36 | this.onNext = onNext;
37 | this.onCompleted = onCompleted;
38 | this.observers = new ArrayList>(observers);
39 | for (JoinObserver1 extends Object> jo : this.observers) {
40 | addJoinObserver(jo);
41 | }
42 | }
43 |
44 | @Override
45 | protected void match() {
46 | Object[] notifications = new Object[this.observers.size()];
47 | int j = 0;
48 | int completedCount = 0;
49 | for (JoinObserver1 extends Object> jo : this.observers) {
50 | if (jo.queue().isEmpty()) {
51 | return;
52 | }
53 | Notification extends Object> n = jo.queue().peek();
54 | if (n.isOnCompleted()) {
55 | completedCount++;
56 | }
57 | notifications[j] = n.getValue();
58 | j++;
59 | }
60 | if (completedCount == j) {
61 | onCompleted.call();
62 | } else {
63 | dequeue();
64 | onNext.call(notifications);
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/JoinObserver.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Subscription;
19 |
20 | /**
21 | * Base interface to manage joined observations.
22 | */
23 | public interface JoinObserver extends Subscription {
24 | void subscribe(Object gate);
25 |
26 | void dequeue();
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/JoinObserver1.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package rx.joins;
17 |
18 | import java.util.ArrayList;
19 | import java.util.LinkedList;
20 | import java.util.List;
21 | import java.util.Queue;
22 | import java.util.concurrent.atomic.AtomicBoolean;
23 |
24 | import rx.Notification;
25 | import rx.Observable;
26 | import rx.Subscriber;
27 | import rx.functions.Action1;
28 | import rx.observers.SafeSubscriber;
29 |
30 | /**
31 | * Default implementation of a join observer.
32 | */
33 | final class JoinObserver1 extends Subscriber> implements JoinObserver {
34 | private Object gate;
35 | private final Observable source;
36 | private final Action1 onError;
37 | private final List activePlans;
38 | private final Queue> queue;
39 | private final AtomicBoolean subscribed = new AtomicBoolean(false);
40 | private final SafeSubscriber> safeObserver;
41 |
42 | JoinObserver1(Observable source, Action1 onError) {
43 | this.source = source;
44 | this.onError = onError;
45 | queue = new LinkedList>();
46 | activePlans = new ArrayList();
47 | safeObserver = new SafeSubscriber>(new InnerObserver());
48 | // add this subscription so it gets unsubscribed when the parent does
49 | add(safeObserver);
50 | }
51 |
52 | public Queue> queue() {
53 | return queue;
54 | }
55 |
56 | public void addActivePlan(ActivePlan0 activePlan) {
57 | activePlans.add(activePlan);
58 | }
59 |
60 | @Override
61 | public void subscribe(Object gate) {
62 | if (subscribed.compareAndSet(false, true)) {
63 | this.gate = gate;
64 | source.materialize().unsafeSubscribe(this);
65 | } else {
66 | throw new IllegalStateException("Can only be subscribed to once.");
67 | }
68 | }
69 |
70 | @Override
71 | public void dequeue() {
72 | queue.remove();
73 | }
74 |
75 |
76 | @Override
77 | public void onNext(Notification args) {
78 | safeObserver.onNext(args);
79 | }
80 |
81 | @Override
82 | public void onError(Throwable e) {
83 | safeObserver.onError(e);
84 | }
85 |
86 | @Override
87 | public void onCompleted() {
88 | safeObserver.onCompleted();
89 | }
90 |
91 | void removeActivePlan(ActivePlan0 activePlan) {
92 | activePlans.remove(activePlan);
93 | if (activePlans.isEmpty()) {
94 | unsubscribe();
95 | }
96 | }
97 |
98 |
99 | private final class InnerObserver extends Subscriber> {
100 |
101 | @Override
102 | public void onNext(Notification args) {
103 | synchronized (gate) {
104 | if (!isUnsubscribed()) {
105 | if (args.isOnError()) {
106 | onError.call(args.getThrowable());
107 | return;
108 | }
109 | queue.add(args);
110 |
111 | // remark: activePlans might change while iterating
112 | for (ActivePlan0 a : new ArrayList(activePlans)) {
113 | a.match();
114 | }
115 | }
116 | }
117 | }
118 |
119 | @Override
120 | public void onError(Throwable e) {
121 | // not expected
122 | }
123 |
124 | @Override
125 | public void onCompleted() {
126 | // not expected or ignored
127 | }
128 | }
129 |
130 | }
--------------------------------------------------------------------------------
/src/main/java/rx/joins/Pattern.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package rx.joins;
18 |
19 | /**
20 | * Base interface for join patterns.
21 | *
22 | * @see MSDN: Pattern
23 | */
24 | public interface Pattern {
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/Pattern1.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Observable;
19 | import rx.functions.Func1;
20 |
21 | /**
22 | * Represents a join pattern over one observable sequence.
23 | */
24 | public final class Pattern1 implements Pattern {
25 | private final Observable o1;
26 |
27 | public Pattern1(Observable o1) {
28 | this.o1 = o1;
29 | }
30 |
31 | Observable o1() {
32 | return o1;
33 | }
34 |
35 | /**
36 | * Matches when all observable sequences have an available
37 | * element and projects the elements by invoking the selector function.
38 | *
39 | * @param selector
40 | * the function that will be invoked for elements in the source sequences.
41 | * @return the plan for the matching
42 | * @throws NullPointerException
43 | * if selector is null
44 | */
45 | public Plan0 then(Func1 selector) {
46 | if (selector == null) {
47 | throw new NullPointerException();
48 | }
49 | return new Plan1(this, selector);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/Pattern2.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Observable;
19 | import rx.functions.Func2;
20 |
21 | /**
22 | * Represents a join pattern over observable sequences.
23 | */
24 | public final class Pattern2 implements Pattern {
25 | private final Observable o1;
26 | private final Observable o2;
27 |
28 | public Pattern2(Observable o1, Observable o2) {
29 | this.o1 = o1;
30 | this.o2 = o2;
31 | }
32 |
33 | Observable o1() {
34 | return o1;
35 | }
36 |
37 | Observable o2() {
38 | return o2;
39 | }
40 |
41 | /**
42 | * Creates a pattern that matches when all three observable sequences have an available element.
43 | *
44 | * @param other
45 | * Observable sequence to match with the two previous sequences.
46 | * @return Pattern object that matches when all observable sequences have an available element.
47 | */
48 | public Pattern3 and(Observable other) {
49 | if (other == null) {
50 | throw new NullPointerException();
51 | }
52 | return new Pattern3(o1, o2, other);
53 | }
54 |
55 | /**
56 | * Matches when all observable sequences have an available
57 | * element and projects the elements by invoking the selector function.
58 | *
59 | * @param selector
60 | * the function that will be invoked for elements in the source sequences.
61 | * @return the plan for the matching
62 | * @throws NullPointerException
63 | * if selector is null
64 | */
65 | public Plan0 then(Func2 selector) {
66 | if (selector == null) {
67 | throw new NullPointerException();
68 | }
69 | return new Plan2(this, selector);
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/Pattern3.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Observable;
19 | import rx.functions.Func3;
20 |
21 | /**
22 | * Represents a join pattern over observable sequences.
23 | */
24 | public final class Pattern3 implements Pattern {
25 | private final Observable o1;
26 | private final Observable o2;
27 | private final Observable o3;
28 |
29 | public Pattern3(Observable o1, Observable o2,
30 | Observable o3) {
31 | this.o1 = o1;
32 | this.o2 = o2;
33 | this.o3 = o3;
34 | }
35 |
36 | Observable o1() {
37 | return o1;
38 | }
39 |
40 | Observable o2() {
41 | return o2;
42 | }
43 |
44 | Observable o3() {
45 | return o3;
46 | }
47 |
48 | /**
49 | * Creates a pattern that matches when all three observable sequences have an available element.
50 | *
51 | * @param other
52 | * Observable sequence to match with the two previous sequences.
53 | * @return Pattern object that matches when all observable sequences have an available element.
54 | */
55 | public Pattern4 and(Observable other) {
56 | if (other == null) {
57 | throw new NullPointerException();
58 | }
59 | return new Pattern4(o1, o2, o3, other);
60 | }
61 |
62 | /**
63 | * Matches when all observable sequences have an available
64 | * element and projects the elements by invoking the selector function.
65 | *
66 | * @param selector
67 | * the function that will be invoked for elements in the source sequences.
68 | * @return the plan for the matching
69 | * @throws NullPointerException
70 | * if selector is null
71 | */
72 | public Plan0 then(Func3 selector) {
73 | if (selector == null) {
74 | throw new NullPointerException();
75 | }
76 | return new Plan3(this, selector);
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/Pattern4.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Observable;
19 | import rx.functions.Func4;
20 |
21 | /**
22 | * Represents a join pattern over observable sequences.
23 | */
24 | public final class Pattern4 implements Pattern {
25 | private final Observable o1;
26 | private final Observable o2;
27 | private final Observable o3;
28 | private final Observable o4;
29 |
30 | public Pattern4(
31 | Observable o1,
32 | Observable o2,
33 | Observable o3,
34 | Observable o4
35 | ) {
36 | this.o1 = o1;
37 | this.o2 = o2;
38 | this.o3 = o3;
39 | this.o4 = o4;
40 | }
41 |
42 | Observable o1() {
43 | return o1;
44 | }
45 |
46 | Observable o2() {
47 | return o2;
48 | }
49 |
50 | Observable o3() {
51 | return o3;
52 | }
53 |
54 | Observable o4() {
55 | return o4;
56 | }
57 |
58 | /**
59 | * Creates a pattern that matches when all four observable sequences have an available element.
60 | *
61 | * @param other
62 | * Observable sequence to match with the three previous sequences.
63 | * @return Pattern object that matches when all observable sequences have an available element.
64 | */
65 | public Pattern5 and(Observable other) {
66 | if (other == null) {
67 | throw new NullPointerException();
68 | }
69 | return new Pattern5(o1, o2, o3, o4, other);
70 | }
71 | /**
72 | * Matches when all observable sequences have an available
73 | * element and projects the elements by invoking the selector function.
74 | *
75 | * @param selector
76 | * the function that will be invoked for elements in the source sequences.
77 | * @return the plan for the matching
78 | * @throws NullPointerException
79 | * if selector is null
80 | */
81 | public Plan0 then(Func4 selector) {
82 | if (selector == null) {
83 | throw new NullPointerException();
84 | }
85 | return new Plan4(this, selector);
86 | }
87 | }
88 |
--------------------------------------------------------------------------------
/src/main/java/rx/joins/Pattern5.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2014 Netflix, Inc.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5 | * use this file except in compliance with the License. You may obtain a copy of
6 | * the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 | * License for the specific language governing permissions and limitations under
14 | * the License.
15 | */
16 | package rx.joins;
17 |
18 | import rx.Observable;
19 | import rx.functions.Func5;
20 |
21 | /**
22 | * Represents a join pattern over observable sequences.
23 | */
24 | public final class Pattern5 implements Pattern {
25 | private final Observable o1;
26 | private final Observable o2;
27 | private final Observable o3;
28 | private final Observable o4;
29 | private final Observable o5;
30 |
31 | public Pattern5(
32 | Observable o1,
33 | Observable