code: @SuppressWarnings("unchecked") // safe by contract of convertTokenIdentifier()
    protected <T extends DelegationTokenIdentifier> T convertTokenIdentifier(
        DelegationTokenIdentifier identifier, Class<T> expectedClass)
        throws DelegationTokenIOException {
      if (identifier.getClass().equals(expectedClass)) {
        return (T) identifier;
      }
      throw DelegationTokenIOException.wrongTokenType(expectedClass, identifier);
    }
docs: Verify that a token identifier is of a specific class. This will reject subclasses (i.e. it is
  stricter than {@code instanceof}, then cast it to that type.
  
  @param identifier identifier to validate
  @param expectedClass class of the expected token identifier.
  @throws DelegationTokenIOException If the wrong class was found.