Guest User

Untitled

a guest
Jun 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.32 KB | None | 0 0
  1. public class Max implements Constraint {
  2.  
  3. long max;
  4.  
  5. public Number constrain(Number n) {
  6. if (n.longValue() <= max) {
  7. return n;
  8. }
  9. // return a number of the type passed in with value max
  10. }
  11. }
  12.  
  13. n.getClass().getConstructor(new Class<?>[] { n.getClass() }).newInstance(max);
Add Comment
Please, Sign In to add comment