package com.hx.auto.util;
|
|
import org.w3c.dom.Document;
|
import org.w3c.dom.NamedNodeMap;
|
import org.w3c.dom.Node;
|
import org.w3c.dom.NodeList;
|
import org.xml.sax.SAXException;
|
|
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.ParserConfigurationException;
|
import javax.xml.transform.OutputKeys;
|
import javax.xml.transform.Transformer;
|
import javax.xml.transform.TransformerException;
|
import javax.xml.transform.TransformerFactory;
|
import javax.xml.transform.dom.DOMSource;
|
import javax.xml.transform.stream.StreamResult;
|
import java.io.File;
|
import java.io.IOException;
|
import java.io.StringWriter;
|
import java.lang.reflect.Field;
|
import java.util.*;
|
|
/**
|
*
|
* @author chenjiahe 2020-06-28
|
*
|
*/
|
public class GeneratorClassParentUtil {
|
|
/**
|
* 获取父类的字段
|
* @param fields
|
* @param clas
|
* @return
|
*/
|
public static Field[] getPatentFields(Field[] fields,Class<?> clas){
|
if (clas.getSuperclass() != null) {
|
Class clsSup = clas.getSuperclass();
|
List<Field> fieldList = new ArrayList<Field>();
|
fieldList.addAll(Arrays.asList(fields));
|
fieldList.addAll(Arrays.asList(clsSup.getDeclaredFields()));
|
fields = new Field[fieldList.size()];
|
int i = 0;
|
for (Object field : fieldList.toArray()) {
|
fields[i] = (Field) field;
|
i++;
|
}
|
fields = getPatentFields(fields,clsSup);
|
}
|
return fields;
|
}
|
|
|
}
|