Created
November 2, 2016 20:26
-
-
Save thomaspoignant/5afc1031bebc830ed2f2bfa64fbf81bc to your computer and use it in GitHub Desktop.
Example of a Static Factory Method, for the this article https://medium.com/@thomaspoignant/static-factory-methods-59e88d2d737f#.9sxp2fho6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RandomLongGenerator { | |
private final long min; | |
private final long max; | |
private RandomIntGenerator(long min, long max) { | |
this.min = min; | |
this.max = max; | |
} | |
public static RandomLongGenerator between(long max, long min) { | |
return new RandomLongGenerator(min, max); | |
} | |
public static RandomLongGenerator biggerThan(long min) { | |
return new RandomLongGenerator(min, Long.MAX_VALUE); | |
} | |
public static RandomLongGenerator smallerThan(int max) { | |
return new RandomLongGenerator(Long.MIN_VALUE, max); | |
} | |
public int next() {...} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment