java.lang.Object
com.mrivanplays.annotationconfig.core.resolver.options.CustomOptions

public final class CustomOptions extends Object
Represents a class, containing options for reading or writing a file. This can contain literally any information you want or need.
Since:
2.0.0
Author:
MrIvanPlays
  • Method Details

    • of

      public static CustomOptions of(Map<String,Option> customData)
      Creates a new CustomOptions instance with the specified data.
      Parameters:
      customData - the data you want these options constructed with
      Returns:
      populated mutable custom options instance
    • empty

      public static CustomOptions empty()
      Creates a new empty CustomOptions instance.
      Returns:
      empty mutable custom options instance
    • has

      public boolean has(String key)
      Returns whether this custom options instance has an Option, assigned to the specified key.
      Parameters:
      key - the key of the option you want to check if exists
      Returns:
      boolean value
    • isReplaceable

      Returns whether the Option, contained or not, in this custom options instance, assigned to the specified key, can be replaced. If there is an option assigned to the specified key, this will return a populated Optional, otherwise empty optional.
      Parameters:
      key - the key of the option you want to check if it can be replaced
      Returns:
      optional with a value, or empty optional
    • getAs

      public <T> Optional<T> getAs(String key, Class<T> type)
      Returns the held Option, assigned to the specified key, as the specified type. If there is no option assigned to this key, this will return an empty Optional, otherwise a value if the option's value can be assigned to the specified type. If the option's value cannot be assigned to the specified type, this method will throw an IllegalArgumentException
      Type Parameters:
      T - type
      Parameters:
      key - the key of the option you want to get
      type - the type you want it converted to
      Returns:
      filled optional or empty optional (check header)
      Throws:
      IllegalArgumentException - if the value is not assignable to the specified type
    • getAsOr

      public <T> T getAsOr(String key, Class<T> type, T def)
      Type Parameters:
      T - type
      Parameters:
      key - the key of the option you want to get
      type - the type you want it converted to
      def - a default value
      Returns:
      always a usable value
      See Also:
    • put

      public <T> void put(String key, Option<T> value)
      Assigns the specified Option to the specified key.
      Type Parameters:
      T - type
      Parameters:
      key - the key you want the specified option to be assigned to
      value - the option you want assigned to the specified key