@XmlSerializable - redundent/lombok-pg GitHub Wiki

@Action

Overview

Generates a toXml() method on any class with this annotation. Also adds implements XmlSerializable to the class

Example

With Lombok

import java.sql.Timestamp;
import lombok.XmlSerializable;
@XmlSerializable
public class DataObject {
	private long dataObjectId;
	private String name;
	private String description;
	private Timestamp createdDate;
	private Timestamp updatedDate;
}

Vanilla Java

import java.sql.Timestamp;
import lombok.core.xml.XAttribute
import lombok.core.xml.XElement;
import lombok.core.xml.XmlSerializable;
public class DataObject implements XmlSerializable {	
	private long dataObjectId;
	private String name;
	private String description;
	private Timestamp createdDate;
	private Timestamp updatedDate;
	
	@java.lang.Override
	public XElement toXml() {
		final XElement element = new XElement("DataObject");
		element.appendChild(new XAttribute("dataObjectId", this.dataObjectId));
		element.appendChild(new XAttribute("name", this.name));
		element.appendChild(new XAttribute("description", this.description));
		element.appendChild(new XAttribute("createdDate", this.createdDate));
		element.appendChild(new XAttribute("updatedDate", this.updatedDate));
		return element;
	}
}

Configuration

Respects typical javax.xml.bind.annotation.* annotations for customizing elements/attributes

⚠️ **GitHub.com Fallback** ⚠️