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


source to share





All Articles