2

只是好奇:我有以下代码:

@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);
   }

...

}

有没有办法在指示的行上避免列出当前类?该方法是与静态初始化程序块相同的类中的静态方法。我意识到我做不到,this::isGoogleHTTP5XXError因为还没有实例,但似乎最好有这样的东西::isGoogleHTTP5XXError来推断我当前的课程,而不必把它拼出来。这存在吗?

4

0 回答 0