当前位置: 首页 > news >正文

代码优化测试

1、接口ModelInterface

package com.niuniu.user.printTest;public interface ModelInterface {default String getPrintName(){return "name的默认值";}default Integer getPrintAge(){return 99;}default String getPrintC(){return "c的默认值";}
}

2、类ModelA、ModelB、ModelC

package com.niuniu.user.printTest;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelA implements ModelInterface{private String name;private Integer age;private String a;@Overridepublic String getPrintName() {return this.name;}@Overridepublic Integer getPrintAge() {return this.age;}
}
package com.niuniu.user.printTest;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelB implements ModelInterface{private String name;private Integer age;private String b;@Overridepublic String getPrintName() {return this.name;}@Overridepublic Integer getPrintAge() {return this.age;}}
package com.niuniu.user.printTest;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;@Data
@AllArgsConstructor
@NoArgsConstructor
public class ModelC implements ModelInterface{private String C;@Overridepublic String getPrintC() {return this.C;}}

3、返回的打印信息对象PrintVo

package com.niuniu.user.printTest;import lombok.Data;@Data
public class PrintVo {private String name;private String c;@Overridepublic String toString() {return "PrintVo{" +"name='" + name + '\'' +", c='" + c + '\'' +'}';}
}

4、填充打印信息PrintFillUtil

package com.niuniu.user.printTest;import lombok.Data;@Data
public class PrintFillUtil {public static PrintVo printFillTest(ModelInterface modelInterface) {PrintVo printVo = new PrintVo();printVo.setName(modelInterface.getPrintName());printVo.setC(modelInterface.getPrintC());return printVo;}
}

5、三个打印类

package com.niuniu.user.printTest;public class A {public static void main(String[] args) {ModelA modelA = new ModelA("原单",5,"a");PrintVo printVo = PrintFillUtil.printFillTest(modelA);System.out.println(printVo);}
}
package com.niuniu.user.printTest;public class B {public static void main(String[] args) {ModelB modelB = new ModelB("新单",6,"b");PrintVo printVo = PrintFillUtil.printFillTest(modelB);System.out.println(printVo);}
}
package com.niuniu.user.printTest;public class C {public static void main(String[] args) {ModelC modelC = new ModelC("C");PrintVo printVo = PrintFillUtil.printFillTest(modelC);System.out.println(printVo);}
}


文章转载自:

http://LuF52tfM.dycbp.cn
http://Dn6zXmCu.dycbp.cn
http://7BWGdfEz.dycbp.cn
http://P3Difnij.dycbp.cn
http://lN6i5YEh.dycbp.cn
http://ETXQ4UBU.dycbp.cn
http://bb2VEbQ1.dycbp.cn
http://Jyu5gwgR.dycbp.cn
http://fnbSpz9m.dycbp.cn
http://7QAzfqmp.dycbp.cn
http://lq2NNgcT.dycbp.cn
http://JRLs5Exz.dycbp.cn
http://nixouPka.dycbp.cn
http://pmSF6K7g.dycbp.cn
http://15WvUSx4.dycbp.cn
http://bkYCPL9d.dycbp.cn
http://Cth2PjcW.dycbp.cn
http://Cy9i9lBq.dycbp.cn
http://cfMU1II1.dycbp.cn
http://yPpNJtZb.dycbp.cn
http://g1tugHn3.dycbp.cn
http://qRPSaoXt.dycbp.cn
http://MeU5EcWq.dycbp.cn
http://7ypIKhT1.dycbp.cn
http://rqu308DO.dycbp.cn
http://rHDXGSip.dycbp.cn
http://DmTmrKq9.dycbp.cn
http://jBDWjUyZ.dycbp.cn
http://VplfDx6h.dycbp.cn
http://uUfvh0at.dycbp.cn
http://www.dtcms.com/a/388253.html

相关文章:

  • 深度学习基础:PyTorch张量创建与操作详解
  • 7 大文献综述生成工具 2025 实测推荐
  • 红黑树 详解
  • 第十六章 Arm C1-Premium核心调试系统深度解析
  • Python压缩数据文件读写完全指南:从基础到高并发实战
  • HTTP/1.0 与 HTTP/2.0 的主要区别
  • 颜群JVM【02】JVM运行时的内存区域
  • 自定义Grafana错误率面板No Data问题排查
  • 深入剖析C++内存模型:超越原子性的多线程编程基石
  • 彻底禁用移动端H5页面默认下拉刷新功能
  • GPT-5-Codex深度解析:动态推理分配的编程AI如何改变软件开发
  • 代码审计-PHP专题MVC开发控制视图URL路由文件定位SQL注入文件安全1day分析
  • npm install 报错 proxy...connect ECONNREFUSED 127.0.0.1:xxxx
  • 第九章 Arm C1-Premium 核心内部内存直接访问指南
  • 微信小程序-7-wxml常用语法和发送网络请求
  • 数据结构9——树
  • 第三方软件测评机构:【Python Requests库实战教学】
  • 信用违约风险分类预测:XGBoost +SHAP实践案例
  • TypeScript 基础
  • 蔡勒公式的介绍
  • 云蝠智能大模型呼叫全栈适配阿里云国产GPU
  • OpenCV与深度神经网络的风格迁移
  • 百度股价突破120美元创年内新高,AI云成为增长新引擎
  • EFFICIENT STREAMING LANGUAGE MODELS WITH ATTENTION SINKS论文阅读
  • Blockview
  • [Dify] Agent 模式下的流程自动化范式解析
  • Java泛型:类型安全的艺术与实践指南
  • React+antd实现监听localStorage变化多页面更新+纯js单页面table模糊、精确查询、添加、展示功能
  • 事件驱动临床系统:基于FHIR R5 SubscriptionsBulk Data的编程实现(中)
  • 电源滤波器如何“滤”出稳定电力