Class Sharable.Builder<T>

java.lang.Object
org.mvplugins.multiverse.inventories.share.Sharable.Builder<T>
Type Parameters:
T - The type of data the new Sharable will represent.
Enclosing interface:
Sharable<T>

public static class Sharable.Builder<T> extends Object
This class is used to build new Sharables. Simply instantiate this and use method chaining to set all the options for your Sharable.
  • Constructor Details

    • Builder

      public Builder(String name, Class<T> type, SharableHandler<T> handler)
      Parameters:
      name - The primary name of the new Sharable.
      type - The type of data the Sharable represents.
      handler - The object that will handle switching the Sharable data between player and profile.
  • Method Details

    • optional

      public Sharable.Builder<T> optional()
      Indicates that the new Sharable is optional as described in Sharable.isOptional().
      Returns:
      This builder object for method chaining.
    • altName

      public Sharable.Builder<T> altName(String name)
      Parameters:
      name - An alternate name for this Sharable which can be used to indicate a group is sharing this Sharable.
      Returns:
      This builder object for method chaining.
    • stringSerializer

      public Sharable.Builder<T> stringSerializer(ProfileEntry entry)
      Sets this sharable to be serialized as a string in the profile data file. To use this, the class type indicates in the Builder's constructor MUST have a static .valueOf(String) method that returns it's type.
      Parameters:
      entry - The profile entry describing where this Sharable is located in the profile file.
      Returns:
      This builder object for method chaining.
      Throws:
      IllegalArgumentException - This is thrown if the type indicated in the Builder's constructor does not fit the constraints indicated above.
    • defaultSerializer

      public Sharable.Builder<T> defaultSerializer(ProfileEntry entry)
      This will make the Sharable use the default serializer which simply passes the data as is to the persistence object for persistence. This will only work depending on the data type this Sharable represents and further depending on the types the persistence methods accept. Generally, boxed primitives are okay as well as Lists of boxed primitives and Map<String, Object>. All other types will likely require a custom SharableSerializer indicated with serializer(ProfileEntry, SharableSerializer).
      Parameters:
      entry - The profile entry describing where this Sharable is located in the profile file.
      Returns:
      This builder object for method chaining.
    • serializer

      public Sharable.Builder<T> serializer(ProfileEntry entry, SharableSerializer<T> serializer)
      This allows you to specify a custom SharableSerializer to use to convert the data represented by this Sharable into something acceptable by persistence.
      Parameters:
      entry - The profile entry describing where this Sharable is located in the profile file.
      serializer - A custom serializer describing how to handle the data in order for it to be persisted in the profile.
      Returns:
      This builder object for method chaining.
    • build

      public Sharable<T> build()
      Returns:
      The new Sharable object built by this Builder.