Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Max implements Constraint {
- long max;
- public Number constrain(Number n) {
- if (n.longValue() <= max) {
- return n;
- }
- // return a number of the type passed in with value max
- }
- }
- n.getClass().getConstructor(new Class<?>[] { n.getClass() }).newInstance(max);
Add Comment
Please, Sign In to add comment