Class Spin<T extends Spin<?>>

java.lang.Object
org.camunda.spin.Spin<T>
Direct Known Subclasses:
SpinJsonNode, SpinXmlNode

public abstract class Spin<T extends Spin<?>> extends Object
Author:
Sebastian Menski, Daniel Meyer
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract String
    Provides the name of the dataformat used by this spin.
    JSON(Object input)
    Creates a spin wrapper for a data input.
    abstract <C> C
    mapTo(Class<C> type)
    Maps the wrapped object to an instance of a java class.
    abstract <C> C
    mapTo(String type)
    Maps the wrapped object to a java object.
    static <T extends Spin<?>>
    T
    S(Object input)
    Creates a spin wrapper for a data input.
    static <T extends Spin<?>>
    T
    S(Object input, String dataFormatName)
    Creates a spin wrapper for a data input of a given data format.
    static <T extends Spin<?>>
    T
    S(Object input, DataFormat<T> format)
    Creates a spin wrapper for a data input of a given data format.
    abstract String
    Returns the wrapped object as string representation.
    abstract Object
    Return the wrapped object.
    abstract void
    Writes the wrapped object to a existing writer.
    XML(Object input)
    Creates a spin wrapper for a data input.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Spin

      public Spin()
  • Method Details

    • S

      public static <T extends Spin<?>> T S(Object input, DataFormat<T> format)
      Creates a spin wrapper for a data input of a given data format.
      Parameters:
      input - the input to wrap
      format - the data format of the input
      Returns:
      the spin wrapper for the input
      Throws:
      IllegalArgumentException - in case an argument of illegal type is provided (such as 'null')
    • S

      public static <T extends Spin<?>> T S(Object input, String dataFormatName)
      Creates a spin wrapper for a data input of a given data format.
      Parameters:
      input - the input to wrap
      dataFormatName - the data format name of the input
      Returns:
      the spin wrapper for the input
      Throws:
      IllegalArgumentException - in case an argument of illegal type is provided (such as 'null')
    • S

      public static <T extends Spin<?>> T S(Object input)
      Creates a spin wrapper for a data input. The data format of the input is auto detected.
      Parameters:
      input - the input to wrap
      Returns:
      the spin wrapper for the input
      Throws:
      IllegalArgumentException - in case an argument of illegal type is provided (such as 'null')
    • XML

      public static SpinXmlElement XML(Object input)
      Creates a spin wrapper for a data input. The data format of the input is assumed to be XML.
      Parameters:
      input - the input to wrap
      Returns:
      the spin wrapper for the input
      Throws:
      IllegalArgumentException - in case an argument of illegal type is provided (such as 'null')
    • JSON

      public static SpinJsonNode JSON(Object input)
      Creates a spin wrapper for a data input. The data format of the input is assumed to be JSON.
      Parameters:
      input - the input to wrap
      Returns:
      the spin wrapper for the input
      Throws:
      IllegalArgumentException - in case an argument of illegal type is provided (such as 'null')
    • getDataFormatName

      public abstract String getDataFormatName()
      Provides the name of the dataformat used by this spin.
      Returns:
      the name of the dataformat used by this Spin.
    • unwrap

      public abstract Object unwrap()
      Return the wrapped object. The return type of this method depends on the concrete data format.
      Returns:
      the object wrapped by this wrapper.
    • toString

      public abstract String toString()
      Returns the wrapped object as string representation.
      Overrides:
      toString in class Object
      Returns:
      the string representation
    • writeToWriter

      public abstract void writeToWriter(Writer writer)
      Writes the wrapped object to a existing writer.
      Parameters:
      writer - the writer to write to
    • mapTo

      public abstract <C> C mapTo(Class<C> type)
      Maps the wrapped object to an instance of a java class.
      Parameters:
      type - the java class to map to
      Returns:
      the mapped object
    • mapTo

      public abstract <C> C mapTo(String type)
      Maps the wrapped object to a java object. The object is determined based on the configuration string which is data format specific.
      Parameters:
      type - the class name to map to
      Returns:
      the mapped object