Class InternalKey<T>

java.lang.Object
org.instancio.internal.settings.InternalKey<T>
All Implemented Interfaces:
Comparable<SettingKey<T>>, AutoAdjustable, SettingKey<T>

public final class InternalKey<T> extends Object implements SettingKey<T>, AutoAdjustable, Comparable<SettingKey<T>>
  • Constructor Details

    • InternalKey

      public InternalKey(String propertyKey, Class<?> type, @Nullable @Nullable Object defaultValue, @Nullable @Nullable RangeAdjuster rangeAdjuster, boolean allowsNullValue)
  • Method Details

    • propertyKey

      public String propertyKey()
      Description copied from interface: SettingKey
      A unique property key identifying this setting. The property key is used to identify the setting in a properties file.
      Specified by:
      propertyKey in interface SettingKey<T>
      Returns:
      a unique property key identifying this setting
    • type

      public Class<T> type()
      Description copied from interface: SettingKey
      The type of value associated with this key.

      This method is used for converting a value from a string to the specified type() when retrieving the value from Settings.

      Specified by:
      type in interface SettingKey<T>
      Returns:
      the type of value associated with this key
    • defaultValue

      public T defaultValue()
      Description copied from interface: SettingKey
      Default value for this key.
      Specified by:
      defaultValue in interface SettingKey<T>
      Returns:
      default value, or null if not defined
    • allowsNullValue

      public boolean allowsNullValue()
      Description copied from interface: SettingKey
      Indicates whether the value for this key can be set to null. Setting a null for a key that does not accept null will produce an exception.
      Specified by:
      allowsNullValue in interface SettingKey<T>
      Returns:
      true if null is allowed, false otherwise
    • autoAdjust

      public <N extends Number & Comparable<N>> void autoAdjust(@NotNull @NotNull Settings settings, @NotNull N otherValue)
      Description copied from interface: AutoAdjustable
      Auto-adjusts the Settings value for this key based on the value of another setting key.
      Specified by:
      autoAdjust in interface AutoAdjustable
      Type Parameters:
      N - a comparable number
      Parameters:
      settings - to adjust
      otherValue - value of the other setting to base the adjustment off
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • compareTo

      public int compareTo(SettingKey<T> o)
      Specified by:
      compareTo in interface Comparable<T>
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • builder

      public static <T> SettingKey.SettingKeyBuilder<T> builder(Class<T> type)