Why does Guava’s Preconditions class contain a private, empty and unused interface?

  Kiến thức lập trình

Guava’s Preconditions class is defined as:

public final class Preconditions {
  private Preconditions() {}

  private interface Impossible {}

  // (static methods that are not using Impossible)
}

I understand that the unused private constructor prevents the class from being instantiated, but I’ve never seen an unused private interface before. It’s not a marker interface either, as there is no class that implements Impossible. Does this interface have any purpose?

Theme wordpress giá rẻ Theme wordpress giá rẻ Thiết kế website

LEAVE A COMMENT