io.muserver.openapi.XmlObjectBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mu-server Show documentation
Show all versions of mu-server Show documentation
A simple but powerful web server framework
package io.muserver.openapi;
import java.net.URI;
/**
* 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.
*/
public class XmlObjectBuilder {
private String name;
private URI namespace;
private String prefix;
private boolean attribute = false;
private boolean wrapped = false;
/**
* @param name Replaces the name of the element/attribute used for the described schema property. When defined within items
, it will affect the name of the individual XML elements within the list. When defined alongside type
being array
(outside the items
), it will affect the wrapping element and only if wrapped
is true
. If wrapped
is false
, it will be ignored.
* @return The current builder
*/
public XmlObjectBuilder withName(String name) {
this.name = name;
return this;
}
/**
* @param namespace The URI of the namespace definition. Value MUST be in the form of an absolute URI.
* @return The current builder
*/
public XmlObjectBuilder withNamespace(URI namespace) {
this.namespace = namespace;
return this;
}
/**
* @param prefix The prefix to be used for the name.
* @return The current builder
*/
public XmlObjectBuilder withPrefix(String prefix) {
this.prefix = prefix;
return this;
}
/**
* @param attribute Declares whether the property definition translates to an attribute instead of an element. Default value is false.
* @return The current builder
*/
public XmlObjectBuilder withAttribute(boolean attribute) {
this.attribute = attribute;
return this;
}
/**
* @param wrapped MAY be used only for an array definition. Signifies whether the array is wrapped (for example,
* <books><book/><book/></books>
) or unwrapped
* (<book/><book/>
). Default value is false
. The definition takes
* effect only when defined alongside type
being array
(outside the items
).
* @return The current builder
*/
public XmlObjectBuilder withWrapped(boolean wrapped) {
this.wrapped = wrapped;
return this;
}
public XmlObject build() {
return new XmlObject(name, namespace, prefix, attribute, wrapped);
}
/**
* Creates a builder for a {@link XmlObject}
* @return A new builder
*/
public static XmlObjectBuilder xmlObject() {
return new XmlObjectBuilder();
}
}