ys.artifact-network.1.0.5.source-code.struct_util.btl Maven / Gradle / Ivy
package ${packageName};
import org.artifact.core.lang.DTO;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Supplier;
import ${packageName}.structs.*;
public class StructUtil {
static Map> cahce = new HashMap<>();
static Map codes = new HashMap<>();
static {
<%
for(struct in structs){
var hashCode = HashUtil.javaDefaultHash(struct.structName)+"";
%>
// ${struct.remark}
cahce.put(${hashCode},() -> new ${struct.structName}());
<%}%>
<%
for(struct in structs){
hashCode = HashUtil.javaDefaultHash(struct.structName)+"";
%>
// ${struct.remark}
codes.put(${packageName}.structs.${struct.structName}.class,${hashCode});
<%}%>
}
public static T create(int code){
return (T) cahce.get(code).get();
}
public static Integer structCode(Class structClass){
return codes.get(structClass);
}
}