Advertisement
Guest User

Untitled

a guest
Apr 19th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. public final class ShapesIntersection implements Maybe<Rectangle> {
  2. public ShapesIntersection(Shape a, Shape b) {
  3. this.a = a;
  4. this.b = b;
  5. }
  6.  
  7. @Override
  8. public boolean isPresent() {
  9. // find out if shapes intersect
  10. }
  11.  
  12. @Override
  13. public Rectangle get() {
  14. // find the common piece of two shapes
  15. }
  16. }
  17.  
  18. public inteface Maybe<T> {
  19. T get();
  20. boolean isPresent();
  21. default Optional<T> asOptional() {
  22. return isPresent() ?
  23. Optional.of(get()) :
  24. Optional.empty();
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement