java.lang.Object
ch.tocco.nice2.optional.cms.api.publish.Mode

public final class Mode extends Object
Mode for getting the page content. Can contain any key value pairs to pass to the single content providers. If some content providers should be skipped at all, use skipProviders(String, String...) to create an instance of this class.
  • Constructor Details

    • Mode

      public Mode()
  • Method Details

    • skipProviders

      public static Mode skipProviders(String first, String... others)
      Create a mode to skip the specified providers.
      Returns:
      a new Mode instance.
    • with

      public <T> Mode with(Mode.Key<T> key, T value)
      Add a key value pair to this mode.
      Type Parameters:
      T - The type of the value.
      Parameters:
      key - The key.
      value - The value.
      Returns:
      the mode.
    • get

      public <T> Optional<T> get(Mode.Key<T> key)
      Get a value for a specific key.
      Type Parameters:
      T - The type of the value.
      Parameters:
      key - The key of the value.
      Returns:
      the value or Optional.empty() if not set or null.
    • is

      public boolean is(String key)
      Shortcut for get(Key) with boolean values.
      Parameters:
      key - The key of the value.
      Returns:
      true if the boolean value is set and it equals true, else false.
    • key

      public static <T> Mode.Key<T> key(String name, Class<T> type)
      Create a key instance.
      Parameters:
      name - The name of the key.
      type - The type for the value.
      Returns:
      the key instance.