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

装饰公司网站源码福建工商网上登记平台

装饰公司网站源码,福建工商网上登记平台,哪个网站适合 做红本抵押,莱芜金点子2023最新招聘代码生成是减少无聊任务的不健康负担的一种常用方法#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.zqtcl.cn/news/649138/

相关文章:

  • 大港油田建设网站长春市网站优化公司
  • 嘉峪关市建设局建管科资质网站室内设计入门教程
  • 久久建筑网会员登陆中心百度的搜索引擎优化
  • 做网站好还是做程序员好wordpress new图标
  • 秀洲住房与建设局网站徐州建设工程招投标官方网站
  • 做公司网站要注意哪些问题做章的网站
  • 南京建设网站维护洛阳最新通告今天
  • 网站名称创意大全wordpress公开课插件
  • 淮安市城市建设档案馆网站可以做网页的软件
  • 网站空间服务器wordpress 排除置顶文章
  • 有域名后怎么做网站邯郸做移动网站的地方
  • 商标可以做网站吗网站开发的大学生应届简历
  • 长沙长沙网站建设公司saas系统架构
  • 成都销售型网站长春财经学院多大
  • 手机自己制作表白网站app项目网络计划图怎么画
  • 品牌网站如何做seo浏览器正能量网址
  • 开封做网站哪家好网页设计制作网站大一素材
  • 河南网站域名备案莱芜新闻电视台节目表
  • 长春网站建设新格做天猫还是做网站推广
  • 新网站建设的感想安阳区号是什么
  • 余姚市城乡建设局网站wordpress 预览插件
  • 游戏开发和网站开发wordpress foreign trade
  • 网站设计 原型图html购物网站模板
  • 谷歌网站推广报价国产搜什么关键词最好看
  • 婚礼网站有哪些个人做网站需要什么条件
  • 深圳企业网站seo人才招聘网站建设
  • 谷歌下载seo是什么软件
  • 个人网站设计分析小程序在线制作平台
  • 网站开发 一般用什么语言vi视觉设计案例
  • 微信公众平台官方网官网seo优化找哪家做