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

浦口区网站建设苏州制作网页找哪家

浦口区网站建设,苏州制作网页找哪家,电子商务网站系统建设实训心得,密山网站面向对象代码代码生成是减少无聊任务的不健康负担的一种常用方法#xff0c;这些任务常常使我们急切地对代码苦恼。 我见过的许多代码生成框架都使用模板替换重复方法#xff0c;在该模板中#xff0c;您编写了模板#xff0c;以了解生成的代码文件的外观#xff0c;然后替… 面向对象代码 代码生成是减少无聊任务的不健康负担的一种常用方法这些任务常常使我们急切地对代码苦恼。 我见过的许多代码生成框架都使用模板替换重复方法在该模板中您编写了模板以了解生成的代码文件的外观然后替换某些关键字并重复其他部分以生成所需的特定文件。 这种让我烦恼的方法的问题是要编译生成的代码真的很难知道生成的代码是否可以工作。 您可能已经更改了一个类的名称并且突然生成的代码无法构建。 为了解决此问题 我启动了一个名为CodeGen的项目 该项目旨在完全面向对象以便您可以从模板到可执行代码的所有过程中受益于类型安全。 生成器的主要用例是Speedment软件 但它可以用于各种项目。 考虑以下代码 final Generator generator new JavaGenerator();final File file File.of(org/example/Foo.java).add(Class.of(Foo).public_().add(Field.of(x, DOUBLE_PRIMITIVE).final_()).add(Field.of(y, DOUBLE_PRIMITIVE).final_()).add(Field.of(z, DOUBLE_PRIMITIVE).final_()).call(new AutoConstructor()).call(new AutoSetGetAdd()).call(new AutoEquals())).call(new AutoJavadoc()).call(new AutoImports(generator)) ; 应用程序的模型树是使用bean构建的。 可以将新方法和成员变量添加到树中以创建同一类的变体。 当要呈现代码时可以轻松地将其传递给生成器类。 String code generator.on(file).get(); 生成的代码如下所示 /*** Write some documentation here.*/ package org.example;import java.util.Optional;/*** author You name here*/ public class Foo {private final double x;private final double y;private final double z;/*** Initializes the Foo component.** param x the x* param y the y* param z the z*/public Foo(double x, double y, double z) {this.x x;this.y y;this.z z;}/*** Returns the value of x.** return the value of x*/public double getX() {return x;}/*** Sets a new value for x.** param x the new value of x*/public void setX(double x) {this.x x;}/*** Returns the value of y.** return the value of y*/public double getY() {return y;}/*** Sets a new value for y.** param y the new value of y*/public void setY(double y) {this.y y;}/*** Returns the value of z.** return the value of z*/public double getZ() {return z;}/*** Sets a new value for z.** param z the new value of z*/public void setZ(double z) {this.z z;}/*** Generates a hashCode for this object. If any field is* changed to another value, the hashCode may be different.* Two objects with the same values are guaranteed to have* the same hashCode. Two objects with the same hashCode are* not guaranteed to have the same hashCode.** return the hash code*/Overridepublic int hashCode() {int hash 7;hash 31 * hash (Double.hashCode(this.x));hash 31 * hash (Double.hashCode(this.y));hash 31 * hash (Double.hashCode(this.z));return hash;}/*** Compares this object with the specified one for equality.* The other object must be of the same type and not null for* the method to return true.** param other the object to compare with* return {code true} if the objects are equal*/Overridepublic boolean equals(Object other) {return Optional.ofNullable(other).filter(o - getClass().equals(o.getClass())).map(o - (Foo) o).filter(o - this.x o.x).filter(o - this.y o.y).filter(o - this.z o.z).isPresent();} } 每个组件都是作为接口类对实现的因此您可以动态更改实现而无需重写系统的其他部分。 希望这对其他人有帮助 翻译自: https://www.javacodegeeks.com/2016/02/object-oriented-approach-code-generation.html面向对象代码
http://www.yutouwan.com/news/226020/

相关文章:

  • 精品课程网站建设毕业设计论文河南汝州文明建设门户网站
  • python进行网站开发营销策划方案案例
  • 网站申请名称建站软件有哪些功能
  • 登陆网站空间盐城城南建设局一局网站
  • 佛山中谦建设网站网站外链查询
  • 下载上海发布官方网站企业展厅策划设计公司有哪些
  • 好网站页面网站什么语言好
  • 微信上打开连接的网站怎么做网站视频要vip怎么看
  • wordpress首页加音乐赣州seo唐三
  • 网站后台模板关联自己做的网站百度广告推广收费标准
  • 做海报免费素材网站有哪些网站设计与网页制作公司
  • 织梦dede建站教程视频网站建设代码编译的问题及解决方案
  • 网站 方案html代码大全txt
  • 宁波医院网站建设免费连接网络的软件
  • 什么网站做简历免费下载电子商务网站建设的方法
  • 怎么在手机上传百度云wordpress百度seo快速排名
  • alexa全球网站排名网站建设属于哪个分类编码
  • 烟台网站建设兼职开发网站的流程是
  • 西安网站公司哪家好政务网站建设依据国家
  • 企业网站的特点山东企业站点seo
  • 青岛企业建设网站企业餐饮行业做网站的数据
  • 展台设计展会展位设计广州企业网站seo
  • 网站频繁改版企业网站建设相关书籍在线阅读
  • 网站如何不被百度搜到做同业业务一般关注哪些网站
  • 网站商城建站c 网站购物车怎么做
  • 富通建设工程有限公司网站商务网站建设实验报告
  • 网站的设计路线任丘市做网站
  • 越南做网站服务器网站建设 样板
  • 深圳龙华企业网站设计wordpress下载破解
  • 网站建设吴中区绵阳 网站设计