@@ -135,30 +135,22 @@ public Arbitrary<Short> shorts(
135135 return shortArbitrary ;
136136 }
137137
138- BigInteger positiveMin = constraint .getPositiveMin ();
139- BigInteger positiveMax = constraint .getPositiveMax ();
140- BigInteger negativeMin = constraint .getNegativeMin ();
141- BigInteger negativeMax = constraint .getNegativeMax ();
142-
143- ShortArbitrary positiveArbitrary = null ;
144- ShortArbitrary negativeArbitrary = null ;
145- if (positiveMin != null ) {
146- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> shortArbitrary );
147- positiveArbitrary = positiveArbitrary .greaterOrEqual (positiveMin .shortValueExact ());
148- }
149- if (positiveMax != null ) {
150- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> shortArbitrary );
151- positiveArbitrary = positiveArbitrary .lessOrEqual (positiveMax .shortValueExact ());
152- }
153- if (negativeMin != null ) {
154- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> shortArbitrary );
155- negativeArbitrary = negativeArbitrary .greaterOrEqual (negativeMin .shortValueExact ());
156- }
157- if (negativeMax != null ) {
158- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> shortArbitrary );
159- negativeArbitrary = negativeArbitrary .lessOrEqual (negativeMax .shortValueExact ());
160- }
161- return resolveArbitrary (shortArbitrary , positiveArbitrary , negativeArbitrary );
138+ BigInteger min = constraint .getMin ();
139+ BigInteger max = constraint .getMax ();
140+
141+ ShortArbitrary arbitrary = null ;
142+
143+ if (min != null ) {
144+ arbitrary = Types .defaultIfNull (arbitrary , () -> shortArbitrary );
145+ arbitrary = arbitrary .greaterOrEqual (min .shortValueExact ());
146+ }
147+
148+ if (max != null ) {
149+ arbitrary = Types .defaultIfNull (arbitrary , () -> shortArbitrary );
150+ arbitrary = arbitrary .lessOrEqual (max .shortValueExact ());
151+ }
152+
153+ return arbitrary != null ? arbitrary : shortArbitrary ;
162154 }
163155
164156 @ Override
@@ -171,30 +163,22 @@ public Arbitrary<Byte> bytes(
171163 return byteArbitrary ;
172164 }
173165
174- BigInteger positiveMin = constraint .getPositiveMin ();
175- BigInteger positiveMax = constraint .getPositiveMax ();
176- BigInteger negativeMin = constraint .getNegativeMin ();
177- BigInteger negativeMax = constraint .getNegativeMax ();
166+ BigInteger min = constraint .getMin ();
167+ BigInteger max = constraint .getMax ();
178168
179- ByteArbitrary positiveArbitrary = null ;
180- ByteArbitrary negativeArbitrary = null ;
181- if (positiveMin != null ) {
182- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> byteArbitrary );
183- positiveArbitrary = positiveArbitrary .greaterOrEqual (positiveMin .byteValueExact ());
184- }
185- if (positiveMax != null ) {
186- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> byteArbitrary );
187- positiveArbitrary = positiveArbitrary .lessOrEqual (positiveMax .byteValueExact ());
188- }
189- if (negativeMin != null ) {
190- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> byteArbitrary );
191- negativeArbitrary = negativeArbitrary .greaterOrEqual (negativeMin .byteValueExact ());
169+ ByteArbitrary arbitrary = null ;
170+
171+ if (min != null ) {
172+ arbitrary = Types .defaultIfNull (arbitrary , () -> byteArbitrary );
173+ arbitrary = arbitrary .greaterOrEqual (min .byteValueExact ());
192174 }
193- if (negativeMax != null ) {
194- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> byteArbitrary );
195- negativeArbitrary = negativeArbitrary .lessOrEqual (negativeMax .byteValueExact ());
175+
176+ if (max != null ) {
177+ arbitrary = Types .defaultIfNull (arbitrary , () -> byteArbitrary );
178+ arbitrary = arbitrary .lessOrEqual (max .byteValueExact ());
196179 }
197- return resolveArbitrary (byteArbitrary , positiveArbitrary , negativeArbitrary );
180+
181+ return arbitrary != null ? arbitrary : byteArbitrary ;
198182 }
199183
200184 @ Override
@@ -299,30 +283,22 @@ public Arbitrary<Integer> integers(
299283 return integerArbitrary ;
300284 }
301285
302- BigInteger positiveMin = constraint .getPositiveMin ();
303- BigInteger positiveMax = constraint .getPositiveMax ();
304- BigInteger negativeMin = constraint .getNegativeMin ();
305- BigInteger negativeMax = constraint .getNegativeMax ();
286+ BigInteger min = constraint .getMin ();
287+ BigInteger max = constraint .getMax ();
306288
307- IntegerArbitrary positiveArbitrary = null ;
308- IntegerArbitrary negativeArbitrary = null ;
309- if (positiveMin != null ) {
310- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> integerArbitrary );
311- positiveArbitrary = positiveArbitrary .greaterOrEqual (positiveMin .intValueExact ());
312- }
313- if (positiveMax != null ) {
314- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> integerArbitrary );
315- positiveArbitrary = positiveArbitrary .lessOrEqual (positiveMax .intValueExact ());
316- }
317- if (negativeMin != null ) {
318- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> integerArbitrary );
319- negativeArbitrary = negativeArbitrary .greaterOrEqual (negativeMin .intValueExact ());
289+ IntegerArbitrary arbitrary = null ;
290+
291+ if (min != null ) {
292+ arbitrary = Types .defaultIfNull (arbitrary , () -> integerArbitrary );
293+ arbitrary = arbitrary .greaterOrEqual (min .intValueExact ());
320294 }
321- if (negativeMax != null ) {
322- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> integerArbitrary );
323- negativeArbitrary = negativeArbitrary .lessOrEqual (negativeMax .intValueExact ());
295+
296+ if (max != null ) {
297+ arbitrary = Types .defaultIfNull (arbitrary , () -> integerArbitrary );
298+ arbitrary = arbitrary .lessOrEqual (max .intValueExact ());
324299 }
325- return resolveArbitrary (integerArbitrary , positiveArbitrary , negativeArbitrary );
300+
301+ return arbitrary != null ? arbitrary : integerArbitrary ;
326302 }
327303
328304 @ Override
@@ -335,30 +311,22 @@ public Arbitrary<Long> longs(
335311 return longArbitrary ;
336312 }
337313
338- BigInteger positiveMin = constraint .getPositiveMin ();
339- BigInteger positiveMax = constraint .getPositiveMax ();
340- BigInteger negativeMin = constraint .getNegativeMin ();
341- BigInteger negativeMax = constraint .getNegativeMax ();
314+ BigInteger min = constraint .getMin ();
315+ BigInteger max = constraint .getMax ();
342316
343- LongArbitrary positiveArbitrary = null ;
344- LongArbitrary negativeArbitrary = null ;
345- if (positiveMin != null ) {
346- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> longArbitrary );
347- positiveArbitrary = positiveArbitrary .greaterOrEqual (positiveMin .longValueExact ());
348- }
349- if (positiveMax != null ) {
350- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> longArbitrary );
351- positiveArbitrary = positiveArbitrary .lessOrEqual (positiveMax .longValueExact ());
352- }
353- if (negativeMin != null ) {
354- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> longArbitrary );
355- negativeArbitrary = negativeArbitrary .greaterOrEqual (negativeMin .longValueExact ());
317+ LongArbitrary arbitrary = null ;
318+
319+ if (min != null ) {
320+ arbitrary = Types .defaultIfNull (arbitrary , () -> longArbitrary );
321+ arbitrary = arbitrary .greaterOrEqual (min .longValueExact ());
356322 }
357- if (negativeMax != null ) {
358- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> longArbitrary );
359- negativeArbitrary = negativeArbitrary .lessOrEqual (negativeMax .longValueExact ());
323+
324+ if (max != null ) {
325+ arbitrary = Types .defaultIfNull (arbitrary , () -> longArbitrary );
326+ arbitrary = arbitrary .lessOrEqual (max .longValueExact ());
360327 }
361- return resolveArbitrary (longArbitrary , positiveArbitrary , negativeArbitrary );
328+
329+ return arbitrary != null ? arbitrary : longArbitrary ;
362330 }
363331
364332 @ Override
@@ -371,31 +339,22 @@ public Arbitrary<BigInteger> bigIntegers(
371339 return bigIntegerArbitrary ;
372340 }
373341
374- BigInteger positiveMin = constraint .getPositiveMin ();
375- BigInteger positiveMax = constraint .getPositiveMax ();
376- BigInteger negativeMin = constraint .getNegativeMin ();
377- BigInteger negativeMax = constraint .getNegativeMax ();
342+ BigInteger min = constraint .getMin ();
343+ BigInteger max = constraint .getMax ();
378344
379- BigIntegerArbitrary positiveArbitrary = null ;
380- BigIntegerArbitrary negativeArbitrary = null ;
381- if (positiveMin != null ) {
382- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> bigIntegerArbitrary );
383- positiveArbitrary = positiveArbitrary .greaterOrEqual (positiveMin );
384- }
385- if (positiveMax != null ) {
386- positiveArbitrary = Types .defaultIfNull (positiveArbitrary , () -> bigIntegerArbitrary );
387- positiveArbitrary = positiveArbitrary .lessOrEqual (positiveMax );
388- }
389- if (negativeMin != null ) {
390- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> bigIntegerArbitrary );
391- negativeArbitrary = negativeArbitrary .greaterOrEqual (negativeMin );
345+ BigIntegerArbitrary arbitrary = null ;
346+
347+ if (min != null ) {
348+ arbitrary = Types .defaultIfNull (arbitrary , () -> bigIntegerArbitrary );
349+ arbitrary = arbitrary .greaterOrEqual (min );
392350 }
393- if (negativeMax != null ) {
394- negativeArbitrary = Types .defaultIfNull (negativeArbitrary , () -> bigIntegerArbitrary );
395- negativeArbitrary = negativeArbitrary .lessOrEqual (negativeMax );
351+
352+ if (max != null ) {
353+ arbitrary = Types .defaultIfNull (arbitrary , () -> bigIntegerArbitrary );
354+ arbitrary = arbitrary .lessOrEqual (max );
396355 }
397356
398- return resolveArbitrary ( bigIntegerArbitrary , positiveArbitrary , negativeArbitrary ) ;
357+ return arbitrary != null ? arbitrary : bigIntegerArbitrary ;
399358 }
400359
401360 @ Override
0 commit comments