Class Xml


@Bean(properties="name,namespace,prefix,attribute,wrapped,*") public class Xml extends SwaggerElement
A metadata object that allows for more fine-tuned XML model definitions.

When using arrays, XML element names are not inferred (for singular/plural forms) and the name property should be used to add that information.

Example:

// Construct using SwaggerBuilder. Xml xml = xml() .name("foo") .namespace("http://foo") // Serialize using JsonSerializer. String json = JsonSerializer.DEFAULT.toString(xml); // Or just use toString() which does the same as above. json = xml.toString();

// Output { "name": "foo", "namespace": "http://foo" }

See Also:
  • Constructor Details

    • Xml

      public Xml()
      Default constructor.
    • Xml

      public Xml(Xml copyFrom)
      Copy constructor.
      Parameters:
      copyFrom - The object to copy.
  • Method Details

    • copy

      public Xml copy()
      Make a deep copy of this object.
      Returns:
      A deep copy of this object.
    • getAttribute

      Bean property getter: attribute.

      Declares whether the property definition translates to an attribute instead of an element.

      Returns:
      The property value, or null if it is not set.
    • setAttribute

      public Xml setAttribute(Boolean value)
      Bean property setter: attribute.

      Declares whether the property definition translates to an attribute instead of an element.

      Parameters:
      value - The new value for this property.
      Default value is false.
      Can be null to unset the property.
      Returns:
      This object.
    • getName

      public String getName()
      Bean property getter: name.

      The name of the element/attribute used for the described schema property.

      Returns:
      The property value, or null if it is not set.
    • setName

      public Xml setName(String value)
      Bean property setter: name.

      The name of the element/attribute used for the described schema property.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getNamespace

      public String getNamespace()
      Bean property getter: namespace.

      The URL of the namespace definition.

      Returns:
      The property value, or null if it is not set.
    • setNamespace

      public Xml setNamespace(String value)
      Bean property setter: namespace.

      The URL of the namespace definition.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getPrefix

      public String getPrefix()
      Bean property getter: prefix.

      The prefix to be used for the name.

      Returns:
      The property value, or null if it is not set.
    • setPrefix

      public Xml setPrefix(String value)
      Bean property setter: prefix.

      The prefix to be used for the name.

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • getWrapped

      public Boolean getWrapped()
      Bean property getter: wrapped.

      Signifies whether the array is wrapped (for example, <books><book/><book/><books>) or unwrapped (<book/><book/>).
      The definition takes effect only when defined alongside type being array (outside the items).

      Returns:
      The property value, or null if it is not set.
    • setWrapped

      public Xml setWrapped(Boolean value)
      Bean property setter: wrapped.

      Signifies whether the array is wrapped (for example, <books><book/><book/><books>) or unwrapped (<book/><book/>).
      The definition takes effect only when defined alongside type being array (outside the items).

      Parameters:
      value - The new value for this property.
      Can be null to unset the property.
      Returns:
      This object.
    • get

      public <T> T get(String property, Class<T> type)
      Description copied from class: SwaggerElement
      Generic property getter.

      Can be used to retrieve non-standard Swagger fields such as "$ref".

      Overrides:
      get in class SwaggerElement
      Type Parameters:
      T - The datatype to cast the value to.
      Parameters:
      property - The property name to retrieve.
      type - The datatype to cast the value to.
      Returns:
      The property value, or null if the property does not exist or is not set.
    • set

      public Xml set(String property, Object value)
      Description copied from class: SwaggerElement
      Generic property setter.

      Can be used to set non-standard Swagger fields such as "$ref".

      Overrides:
      set in class SwaggerElement
      Parameters:
      property - The property name to set.
      value - The new value for the property.
      Returns:
      This object.
    • keySet

      public Set<String> keySet()
      Description copied from class: SwaggerElement
      Returns all the keys on this element.
      Overrides:
      keySet in class SwaggerElement
      Returns:
      All the keys on this element.
      Never null.