Skip to content

Commit

Permalink
#9 Started to add JavaDocs for Short API numeric boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
ctapobep committed Nov 1, 2017
1 parent 6cbd7ac commit f5d242f
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions datagen/src/main/java/io/qala/datagen/RandomShortApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,30 @@
public class RandomShortApi {
private RandomShortApi() {}

/**
* @param max inclusive, must be greater than 0
* @return integer between 0 (inclusive) to {@code max}
*/
public static int integer(int max) {
return upTo(max).integer();
}
/**
* @param min inclusive, must be less than {@code max}
* @param max inclusive, must be greater than {@code min}
* @return integer from {@code min} to {@code max}
*/
public static int integer(int min, int max) {
return between(min, max).integer();
}
public static int integer() {
return between(Integer.MIN_VALUE, Integer.MAX_VALUE).integer();
}

/** @return value between 0 (inclusive) and {@link Integer#MAX_VALUE} (inclusive) */
public static int positiveInteger() {

This comment has been minimized.

Copy link
@php-coder

php-coder Nov 6, 2017

wow... is zero a positive number? Anyway, it's surprise me.

This comment has been minimized.

Copy link
@ctapobep

ctapobep Nov 7, 2017

Author Member

Yeah, as often happens - you can think both ways and both are going to be surprising (for different people). From Java and C standpoint 0 is "positive". But Math guys wouldn't agree. To untie the knot we could probably have two distinct methods - positiveInteger() & naturalInteger() (or nonNegativeInteger()).

return upTo(Integer.MAX_VALUE).integer();
}
/** @return value between {@link Long#MIN_VALUE} (inclusive) and {@link Long#MAX_VALUE} (inclusive) */
public static long Long() {
return between(Long.MIN_VALUE, Long.MAX_VALUE).Long();
}
Expand Down

0 comments on commit f5d242f

Please sign in to comment.