1414 */
1515
1616import io .vavr .control .Either ;
17-
1817import org .assertj .core .error .BasicErrorMessageFactory ;
1918
2019/**
@@ -30,52 +29,49 @@ class EitherShouldContain extends BasicErrorMessageFactory {
3029 private static final String EXPECTING_TO_CONTAIN_SAME = "%nExpecting:%n <%s>%nto contain the instance (i.e. compared with ==):%n <%s>%nbut did not." ;
3130 private static final String EXPECTING_TO_CONTAIN_BUT_IS_LEFT = "%nExpecting:%n <%s>%nto contain on right side:%n <%s>%nbut was left sided." ;
3231 private static final String EXPECTING_TO_CONTAIN_BUT_IS_RIGHT = "%nExpecting:%n <%s>%nto contain on right side:%n <%s>%nbut was right sided." ;
33-
32+ private static final String EXPECTING_TO_CONTAIN_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [LEFT]%nbut did not." ;
33+ private static final String EXPECTING_TO_CONTAIN_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [RIGHT]%nbut did not." ;
34+ private static final String EXPECTING_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain on the [LEFT]:%n <%s>%nbut had <%s> on the [RIGHT]." ;
35+ private static final String EXPECTING_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain on the [RIGHT]:%n <%s>%nbut had <%s> on the [LEFT]." ;
3436 private EitherShouldContain (String message , Object actual , Object expected ) {
3537 super (message , actual , expected );
3638 }
3739
38- private static final String EXPECTING_TO_CONTAIN_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [LEFT]%nbut did not." ;
39- private static final String EXPECTING_TO_CONTAIN_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain:%n <%s> on the [RIGHT]%nbut did not." ;
40-
41- private static final String EXPECTING_ON_THE_LEFT = "%nExpecting:%n <%s>%nto contain on the [LEFT]:%n <%s>%nbut had <%s> on the [RIGHT]." ;
42- private static final String EXPECTING_ON_THE_RIGHT = "%nExpecting:%n <%s>%nto contain on the [RIGHT]:%n <%s>%nbut had <%s> on the [LEFT]." ;
43-
44- private EitherShouldContain (String format , Object ... arguments ) {
45- super (format , arguments );
46- }
40+ private EitherShouldContain (String format , Object ... arguments ) {
41+ super (format , arguments );
42+ }
4743
48- /**
49- * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument.
50- *
51- * @param either the {@link io.vavr.control.Either} which contains a value.
52- * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
53- * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
54- * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
55- * @return an error message factory
56- */
57- static <LEFT , RIGHT > EitherShouldContain shouldContain (Either <LEFT , RIGHT > either ,
58- Object expected ) {
59- return either .isLeft () ?
60- new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_LEFT , either , expected ) :
61- new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_RIGHT , either , expected );
62- }
44+ /**
45+ * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument.
46+ *
47+ * @param either the {@link io.vavr.control.Either} which contains a value.
48+ * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
49+ * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
50+ * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
51+ * @return an error message factory
52+ */
53+ static <LEFT , RIGHT > EitherShouldContain shouldContain (Either <LEFT , RIGHT > either ,
54+ Object expected ) {
55+ return either .isLeft () ?
56+ new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_LEFT , either , expected ) :
57+ new EitherShouldContain (EXPECTING_TO_CONTAIN_ON_THE_RIGHT , either , expected );
58+ }
6359
64- /**
65- * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument on expected side.
66- *
67- * @param either the {@link io.vavr.control.Either} which contains a value.
68- * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
69- * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
70- * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
71- * @return an error message factory
72- */
73- static <LEFT , RIGHT > EitherShouldContain shouldContainOnOtherSide (Either <LEFT , RIGHT > either ,
74- Object expected ) {
75- return either .isRight ()
76- ? new EitherShouldContain (EXPECTING_ON_THE_LEFT , either , expected , either .get ())
77- : new EitherShouldContain (EXPECTING_ON_THE_RIGHT , either , expected , either .getLeft ());
78- }
60+ /**
61+ * Indicates that the provided {@link io.vavr.control.Either} does not contain the provided argument on expected side.
62+ *
63+ * @param either the {@link io.vavr.control.Either} which contains a value.
64+ * @param expected the value we expect to be in the provided {@link io.vavr.control.Either}.
65+ * @param <LEFT> the type of the value contained in the {@link io.vavr.control.Either} on the left.
66+ * @param <RIGHT> the type of the value contained in the {@link io.vavr.control.Either} on the right.
67+ * @return an error message factory
68+ */
69+ static <LEFT , RIGHT > EitherShouldContain shouldContainOnOtherSide (Either <LEFT , RIGHT > either ,
70+ Object expected ) {
71+ return either .isRight ()
72+ ? new EitherShouldContain (EXPECTING_ON_THE_LEFT , either , expected , either .get ())
73+ : new EitherShouldContain (EXPECTING_ON_THE_RIGHT , either , expected , either .getLeft ());
74+ }
7975
8076 /**
8177 * Indicates that the provided {@link Either} does not contain the provided argument as right value.
@@ -84,7 +80,6 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainOnOtherSide(Either<LEFT, R
8480 * @param expectedValue the value we expect to be in the provided {@link Either} on the right side.
8581 * @param <LEFT> the type of the value contained in the {@link Either} on the left side.
8682 * @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
87- *
8883 * @return an error message factory
8984 */
9085 static <LEFT , RIGHT > EitherShouldContain shouldContainOnRight (Either <LEFT , RIGHT > either , RIGHT expectedValue ) {
@@ -101,7 +96,6 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainOnRight(Either<LEFT, RIGHT
10196 * @param expectedValue the value we expect to be in the provided {@link Either} on the right side.
10297 * @param <LEFT> the type of the value contained in the {@link Either} on the left side.
10398 * @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
104- *
10599 * @return an error message factory
106100 */
107101 static <LEFT , RIGHT > EitherShouldContain shouldContainSameOnRight (Either <LEFT , RIGHT > either , RIGHT expectedValue ) {
@@ -117,14 +111,13 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainSameOnRight(Either<LEFT, R
117111 * @param expectedValue the value we expect to be in the provided {@link Either} on the left side.
118112 * @param <LEFT> the type of the value contained in the {@link Either} on the left side.
119113 * @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
120- *
121114 * @return an error message factory
122115 */
123116 static <LEFT , RIGHT > EitherShouldContain shouldContainOnLeft (Either <LEFT , RIGHT > either ,
124- LEFT expectedValue ) {
117+ LEFT expectedValue ) {
125118 return either .isLeft () ?
126- new EitherShouldContain (EXPECTING_TO_CONTAIN , either , expectedValue ) :
127- shouldContainButIsRight (either , expectedValue );
119+ new EitherShouldContain (EXPECTING_TO_CONTAIN , either , expectedValue ) :
120+ shouldContainButIsRight (either , expectedValue );
128121 }
129122
130123 /**
@@ -135,21 +128,19 @@ static <LEFT, RIGHT> EitherShouldContain shouldContainOnLeft(Either<LEFT, RIGHT>
135128 * @param expectedValue the value we expect to be in the provided {@link Either} on the left side.
136129 * @param <LEFT> the type of the value contained in the {@link Either} on the left side.
137130 * @param <RIGHT> the type of the value contained in the {@link Either} on the right side.
138- *
139131 * @return an error message factory
140132 */
141133 static <LEFT , RIGHT > EitherShouldContain shouldContainSameOnLeft (Either <LEFT , RIGHT > either ,
142- LEFT expectedValue ) {
134+ LEFT expectedValue ) {
143135 return either .isLeft () ?
144- new EitherShouldContain (EXPECTING_TO_CONTAIN_SAME , either , expectedValue ) :
145- shouldContainButIsRight (either , expectedValue );
136+ new EitherShouldContain (EXPECTING_TO_CONTAIN_SAME , either , expectedValue ) :
137+ shouldContainButIsRight (either , expectedValue );
146138 }
147139
148140 /**
149141 * Indicates that an {@link Either} is left so it doesn't contain the expected right value.
150142 *
151143 * @param expectedRightValue the right value we expect to be in an {@link Either}.
152- *
153144 * @return an error message factory.
154145 */
155146 static EitherShouldContain shouldContainButIsLeft (Either <?, ?> either , Object expectedRightValue ) {
@@ -160,7 +151,6 @@ static EitherShouldContain shouldContainButIsLeft(Either<?, ?> either, Object ex
160151 * Indicates that an {@link Either} is right so it doesn't contain the expected left value.
161152 *
162153 * @param expectedRightValue the left value we expect to be in an {@link Either}.
163- *
164154 * @return an error message factory.
165155 */
166156 static EitherShouldContain shouldContainButIsRight (Either <?, ?> either , Object expectedRightValue ) {
0 commit comments