Class AdaptTo


  • @ProviderType
    public final class AdaptTo
    extends java.lang.Object
    Utility methods around Sling Adaptable.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T notNull​(@NotNull org.apache.sling.api.adapter.Adaptable adaptable, @NotNull java.lang.Class<T> type)
      Try to adapt the adaptable to the given type and ensures that it succeeds.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • notNull

        @NotNull
        public static <T> T notNull​(@NotNull
                                    @NotNull org.apache.sling.api.adapter.Adaptable adaptable,
                                    @NotNull
                                    @NotNull java.lang.Class<T> type)
        Try to adapt the adaptable to the given type and ensures that it succeeds.
        Type Parameters:
        T - Type
        Parameters:
        adaptable - Adaptable
        type - Type
        Returns:
        Adaption result (not null)
        Throws:
        UnableToAdaptException - if the adaption was not successful