Class ObjectConverter


  • public final class ObjectConverter
    extends java.lang.Object
    Converts Java objects to configs and vice-versa.
    • Constructor Summary

      Constructors 
      Constructor Description
      ObjectConverter()
      Creates a new ObjectConverter with the default parameters.
      ObjectConverter​(boolean bypassTransient, boolean bypassFinal)
      Creates a new ObjectConverter with advanced parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void toConfig​(java.lang.Class<?> clazz, Config destination)  
      <C extends Config>
      C
      toConfig​(java.lang.Class<?> clazz, java.util.function.Supplier<C> destinationSupplier)  
      void toConfig​(java.lang.Object o, Config destination)
      Converts an Object to a Config.
      <C extends Config>
      C
      toConfig​(java.lang.Object o, java.util.function.Supplier<C> destinationSupplier)
      Converts an Object to a Config.
      void toObject​(UnmodifiableConfig config, java.lang.Object destination)
      Converts a Config to an Object.
      <O> O toObject​(UnmodifiableConfig config, java.util.function.Supplier<O> destinationSupplier)
      Converts a Config to an Object.
      • Methods inherited from class java.lang.Object

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

      • ObjectConverter

        public ObjectConverter​(boolean bypassTransient,
                               boolean bypassFinal)
        Creates a new ObjectConverter with advanced parameters.
        Parameters:
        bypassTransient - true to use (parse or write) a field even if it's transient
        bypassFinal - true to write a field even if it's final
      • ObjectConverter

        public ObjectConverter()
        Creates a new ObjectConverter with the default parameters. This is equivalent to new ObjectConverter(false, true).
        See Also:
        ObjectConverter(boolean, boolean)
    • Method Detail

      • toConfig

        public void toConfig​(java.lang.Object o,
                             Config destination)
        Converts an Object to a Config.
        Parameters:
        o - the object to convert
        destination - the Config where to put the values into
      • toConfig

        public void toConfig​(java.lang.Class<?> clazz,
                             Config destination)
      • toConfig

        public <C extends Config> C toConfig​(java.lang.Object o,
                                             java.util.function.Supplier<C> destinationSupplier)
        Converts an Object to a Config.
        Type Parameters:
        C - the destination's type
        Parameters:
        o - the object to convert
        destinationSupplier - a Supplier that provides the Config where to put the values into
        Returns:
        the Config obtained from the Supplier
      • toConfig

        public <C extends Config> C toConfig​(java.lang.Class<?> clazz,
                                             java.util.function.Supplier<C> destinationSupplier)
      • toObject

        public void toObject​(UnmodifiableConfig config,
                             java.lang.Object destination)
        Converts a Config to an Object.
        Parameters:
        config - the config to convert
        destination - the Object where to put the values into
      • toObject

        public <O> O toObject​(UnmodifiableConfig config,
                              java.util.function.Supplier<O> destinationSupplier)
        Converts a Config to an Object.
        Type Parameters:
        O - the destination's type
        Parameters:
        config - the config to convert
        destinationSupplier - a Supplier that provides the Object where to put the values into
        Returns:
        the object obtained from the Supplier