fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.function.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. static class Foo<F extends Foo<F>>
  11. {
  12. <V> void myself(final Optional<V> value, final BiConsumer<? super F, V> destination)
  13. {
  14. if (value.isPresent())
  15. {
  16. destination.accept((F) this, value.get());
  17. }
  18. }
  19. }
  20.  
  21. static class Bar extends Foo<Bar> {
  22. void setAnswer(Integer i) {}
  23. }
  24.  
  25. void outThere(Bar bar)
  26. {
  27. bar.myself(Optional.of(42), Bar::setAnswer);
  28. }
  29.  
  30. public static void main (String[] args) throws java.lang.Exception
  31. {
  32. // your code goes here
  33. }
  34. }
Success #stdin #stdout 0.09s 47004KB
stdin
Standard input is empty
stdout
Standard output is empty