package org.yeshi.utils.generater.vo; import org.yeshi.utils.StringUtil; import org.yeshi.utils.generater.entity.BaseData; import org.yeshi.utils.generater.entity.ClassInfo; import javax.annotation.Nullable; /** * @author Administrator * @title: ExceptionVO * @description: 自定义异常输出 * @date 2021/10/12 10:30 */ public class ExceptionVO extends BaseData { private ClassInfo base; public static class Builder { private ClassInfo base; private Class entity; private String packageName; public Builder setBase(@Nullable ClassInfo base) { this.base = base; return this; } public Builder setEntity(Class entity) { this.entity = entity; return this; } public Builder setPackageName(String packageName) { this.packageName = packageName; return this; } public ExceptionVO build() throws Exception { if (entity == null) { throw new Exception("entity不能为空"); } if (this.base == null) { this.base = new ClassInfo(Exception.class.getSimpleName(), Exception.class.getName()); } if (StringUtil.isNullOrEmpty(packageName)) { throw new Exception("packageName不能为空"); } ExceptionVO vo = new ExceptionVO(); vo.setBase(base); vo.setEntity(new ClassInfo(entity.getSimpleName(), entity.getName())); vo.setPackageName(packageName); return vo; } } public ClassInfo getBase() { return base; } public void setBase(ClassInfo base) { this.base = base; } }