This :: methodReference or equivalent in static init block in Java 8

Just curious: I have the following code:

@Component
public class GoogleExceptionRetryClassifier implements Classifier<Throwable, Boolean>
{
   private static final Collection<Classifier<Throwable, Boolean>> classifiers = new ArrayList<Classifier<Throwable, Boolean>>();
   static
   {
      classifiers.add((tr) -> classInCauseChain(tr, UnknownHostException.class));
      classifiers.add((tr) -> classInCauseChain(tr, SocketTimeoutException.class));

      //vv--LINE BELOW!!!!--vv
      classifiers.add(GoogleExceptionRetryClassifier::isGoogleHTTP5XXError);
   }

...

}

      

Is there a way in the above line to prevent the current class from being displayed? A method is a static method in the same class as a static initializer block. I realize I can't do this::isGoogleHTTP5XXError

it because there is no instance yet, but it seems like it would be nice to have something like ::isGoogleHTTP5XXError

that that would output my current class without having to outline it. Does it exist?

+2
java java-8 method-reference


source to share


No one has answered this question yet

See similar questions:

3
Why does the class / object name have to be explicitly specified for method references?

or similar:

6170
Is Java "pass-by-reference" or "pass-by-value"?
3799
How do I read / convert an InputStream to a string in Java?
3324
How to generate random integers in a specific range in Java?
3073
How to efficiently iterate over each entry in a Java map?
3044
Making a memory leak with Java
2956
What is the difference between public, secure, batch and private in Java?
2936
When to use LinkedList over ArrayList in Java?
2853
How can I convert String to int in Java?
2248
Is a finally block always executable in Java?
1636
Java inner class and static nested class



All Articles
Loading...
X
Show
Funny
Dev
Pics