
com.github.hexffff0.eggs.persistence.ExecuteUnitList Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Eggs Show documentation
Show all versions of Eggs Show documentation
Eggs是一个强大的Intellij IDEA 插件,它允许你在运行时编写Java代码与IDEA进行交互,最终得到你想要的效果,例如生成代码。
The newest version!
package com.github.hexffff0.eggs.persistence;
import java.io.StringReader;
import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import javax.xml.bind.JAXB;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
/**
* @author hyc
* @since 2021/2/4
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class ExecuteUnitList {
@XmlElement(type = ExecuteUnit.class)
@XmlElementWrapper
private List executeUnitList = new ArrayList<>();
public ExecuteUnitList() {}
public ExecuteUnitList(List executeUnits) {
this.executeUnitList.addAll(executeUnits);
}
public ExecuteUnitList(ExecuteUnit executeUnit) {
this.executeUnitList.add(executeUnit);
}
public List getExecuteUnitList() {
executeUnitList.forEach(ExecuteUnit::regenerateId);
return executeUnitList;
}
public void setExecuteUnitList(List executeUnitList) {
this.executeUnitList = executeUnitList;
}
public static List fromXml(String xml) {
ExecuteUnitList list = JAXB.unmarshal(new StringReader(xml), ExecuteUnitList.class);
return list.executeUnitList;
}
public static String toXml(List executeUnits) {
ExecuteUnitList executeUnitList = new ExecuteUnitList(executeUnits);
StringWriter sw = new StringWriter();
JAXB.marshal(executeUnitList, sw);
return sw.toString();
}
public static String toXml(ExecuteUnit templates) {
ExecuteUnitList executeUnitList = new ExecuteUnitList(templates);
StringWriter sw = new StringWriter();
JAXB.marshal(executeUnitList, sw);
return sw.toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy