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

网站移动端生成器flashfxp上传多个网站

网站移动端生成器,flashfxp上传多个网站,网站建设与维护是什么,盐城手机网站建设大家好#xff0c;我是烤鸭#xff1a;今天说一下初始化对象的几种方式#xff1a;1. 多参数构造器2. 构建器3. 构造器后 get/set方法举个例子:这里有个机构entity#xff0c;提供一个默认构造器 package com.xxx.xxx.modules.sys.entity;/*** 机构Entity* versi…大家好我是烤鸭今天说一下初始化对象的几种方式1.    多参数构造器2.    构建器3.    构造器后 get/set方法举个例子:这里有个机构entity提供一个默认构造器 package com.xxx.xxx.modules.sys.entity;/*** 机构Entity* version 2013-05-15*/ public class Office {private static final long serialVersionUID 1L;private Area area; // 归属区域private String code; // 机构编码private String type; // 机构类型1公司2部门3小组private String grade; // 机构等级1一级2二级3三级4四级private String address; // 联系地址private String zipCode; // 邮政编码private String master; // 负责人private String phone; // 电话private String fax; // 传真private String email; // 邮箱private String useable;//是否可用private User primaryPerson;//主负责人private User deputyPerson;//副负责人private ListString childDeptList;//快速添加子部门private String officeCode; //新增字段,门店id,和code值一样private String businessArea; //2.0新增字段,营业面积private String businessHours; //2.0新增字段,营业时间public Office(){super();} } 如果想创建一个这样的对象进行参数传递或者进行其他操作数据库等等。1.   多参数构造器这是全参构造器: public Office(Area area, String code, String type, String grade, String address, String zipCode, String master, String phone, String fax, String email, String useable, User primaryPerson, User deputyPerson, ListString childDeptList, String officeCode, String businessArea, String businessHours, String jxName) {this.area area;this.code code;this.type type;this.grade grade;this.address address;this.zipCode zipCode;this.master master;this.phone phone;this.fax fax;this.email email;this.useable useable;this.primaryPerson primaryPerson;this.deputyPerson deputyPerson;this.childDeptList childDeptList;this.officeCode officeCode;this.businessArea businessArea;this.businessHours businessHours;this.jxName jxName;}2.   构建器这是全参构建器: private Office(Office.Builder builder){this.id builder.id;this.area builder.area;this.code builder.code;this.type builder.type;this.grade builder.grade;this.address builder.address;this.name builder.name;this.email builder.email;this.phone builder.phone;this.zipCode builder.zipCode;this.master builder.master;this.parent builder.parent;this.parentIds builder.parentIds;this.fax builder.fax;this.sort builder.sort;this.primaryPerson builder.primaryPerson;this.deputyPerson builder.deputyPerson;this.childDeptList builder.childDeptList;this.officeCode builder.officeCode;this.businessArea builder.businessArea;this.useable builder.useable;this.businessHours builder.businessHours;this.delFlag builder.delFlag;this.createBy builder.createBy;this.updateBy builder.updateBy;this.updateDate builder.updateDate;this.createDate builder.createDate;}//利用构建器创建对象public static class Builder extends Office{private static final long serialVersionUID 1L;private Area area; // 归属区域private String code; // 机构编码private String type; // 机构类型1公司2部门3小组private String grade; // 机构等级1一级2二级3三级4四级private String address; // 联系地址private String zipCode; // 邮政编码private String master; // 负责人private String phone; // 电话private String fax; // 传真private String email; // 邮箱private String useable;//是否可用private User primaryPerson;//主负责人private User deputyPerson;//副负责人private ListString childDeptList;//快速添加子部门private String officeCode; //新增字段,门店id,和code值一样private String businessArea; //2.0新增字段,营业面积private String businessHours; //2.0新增字段,营业时间public Builder() {super();}public Builder id(String id){this.id id;return this;}public Office build(){return new Office(this);}public Builder area(Area area){this.area area;return this;}public Builder name(String name) {this.name name;return this;}public Builder master(String master) {this.master master;return this;}public Builder code(String code) {this.code code;return this;}public Builder type(String type){this.type type;return this;}public Builder grade(String grade) {this.grade grade;return this;}public Builder address(String address) {this.address address;return this;}public Builder zipCode(String zipCode) {this.zipCode zipCode;return this;}public Builder password(String master) {this.master master;return this;}public Builder parent(Office parent) {this.parent parent;return this;}public Builder parentIds(String parentIds) {this.parentIds parentIds;return this;}public Builder phone(String phone) {this.phone phone;return this;}public Builder fax(String fax) {this.fax fax;return this;}public Builder email(String email) {this.email email;return this;}public Builder useable(String useable) {this.useable useable;return this;}public Builder sort(Integer sort) {this.sort sort;return this;}public Builder primaryPerson(User primaryPerson) {this.primaryPerson primaryPerson;return this;}public Builder deputyPerson(User deputyPerson) {this.deputyPerson deputyPerson;return this;}public Builder childDeptList(ListString childDeptList) {this.childDeptList childDeptList;return this;}public Builder officeCode(String officeCode) {this.officeCode officeCode;return this;}public Builder businessArea(String businessArea) {this.businessArea businessArea;return this;}public Builder businessHours(String businessHours) {this.businessHours businessHours;return this;}public Builder delFlag(String delFlag) {this.delFlag delFlag;if(StringUtils.isBlank(delFlag)){this.delFlag IDBConstant.APPLICATION_DELETE_FLAG_VALID ;}return this;}public Builder createBy(User createBy) {this.createBy createBy;return this;}public Builder updateBy(User updateBy) {this.updateBy updateBy;return this;}public Builder createDate(Date createDate) {this.createDate createDate;return this;}public Builder updateDate(Date updateDate) {this.updateDate updateDate;return this;}}3.   get/set方法自动生成就行public ListString getChildDeptList() {return childDeptList;}public void setChildDeptList(ListString childDeptList) {this.childDeptList childDeptList;}public String getUseable() {return useable;}public void setUseable(String useable) {this.useable useable;}public User getPrimaryPerson() {return primaryPerson;}public void setPrimaryPerson(User primaryPerson) {this.primaryPerson primaryPerson;}public User getDeputyPerson() {return deputyPerson;}public void setDeputyPerson(User deputyPerson) {this.deputyPerson deputyPerson;}public Office getParent() {return parent;}public void setParent(Office parent) {this.parent parent;}NotNullpublic Area getArea() {return area;}public void setArea(Area area) {this.area area;}Length(min1, max1)public String getType() {return type;}public void setType(String type) {this.type type;}Length(min1, max1)public String getGrade() {return grade;}public void setGrade(String grade) {this.grade grade;}Length(min0, max255)public String getAddress() {return address;}public void setAddress(String address) {this.address address;}Length(min0, max100)public String getZipCode() {return zipCode;}public void setZipCode(String zipCode) {this.zipCode zipCode;}Length(min0, max100)public String getMaster() {return master;}public void setMaster(String master) {this.master master;}Length(min0, max200)public String getPhone() {return phone;}public void setPhone(String phone) {this.phone phone;}Length(min0, max200)public String getFax() {return fax;}public void setFax(String fax) {this.fax fax;}Length(min0, max200)public String getEmail() {return email;}public void setEmail(String email) {this.email email;}Length(min0, max100)public String getCode() {return code;}public void setCode(String code) {this.code code;}Overridepublic String toString() {return name;}public String getOfficeCode() {return officeCode;}public void setOfficeCode(String officeCode) {this.officeCode officeCode;}public String getBusinessArea() {return businessArea;}public void setBusinessArea(String businessArea) {this.businessArea businessArea;}public String getBusinessHours() {return businessHours;}public void setBusinessHours(String businessHours) {this.businessHours businessHours;} }public ListString getChildDeptList() {return childDeptList;}public void setChildDeptList(ListString childDeptList) {this.childDeptList childDeptList;}public String getUseable() {return useable;}public void setUseable(String useable) {this.useable useable;}public User getPrimaryPerson() {return primaryPerson;}public void setPrimaryPerson(User primaryPerson) {this.primaryPerson primaryPerson;}public User getDeputyPerson() {return deputyPerson;}public void setDeputyPerson(User deputyPerson) {this.deputyPerson deputyPerson;}public Office getParent() {return parent;}public void setParent(Office parent) {this.parent parent;}NotNullpublic Area getArea() {return area;}public void setArea(Area area) {this.area area;}Length(min1, max1)public String getType() {return type;}public void setType(String type) {this.type type;}Length(min1, max1)public String getGrade() {return grade;}public void setGrade(String grade) {this.grade grade;}Length(min0, max255)public String getAddress() {return address;}public void setAddress(String address) {this.address address;}Length(min0, max100)public String getZipCode() {return zipCode;}public void setZipCode(String zipCode) {this.zipCode zipCode;}Length(min0, max100)public String getMaster() {return master;}public void setMaster(String master) {this.master master;}Length(min0, max200)public String getPhone() {return phone;}public void setPhone(String phone) {this.phone phone;}Length(min0, max200)public String getFax() {return fax;}public void setFax(String fax) {this.fax fax;}Length(min0, max200)public String getEmail() {return email;}public void setEmail(String email) {this.email email;}Length(min0, max100)public String getCode() {return code;}public void setCode(String code) {this.code code;}Overridepublic String toString() {return name;}public String getOfficeCode() {return officeCode;}public void setOfficeCode(String officeCode) {this.officeCode officeCode;}public String getBusinessArea() {return businessArea;}public void setBusinessArea(String businessArea) {this.businessArea businessArea;}public String getBusinessHours() {return businessHours;}public void setBusinessHours(String businessHours) {this.businessHours businessHours;}4.    用法如果我想构造一个对象4.1    构造器直接上图吧当我new Office()的时候我不知道需要传入什么类型的参数也不知道每个参数代表哪个字段。 多个字段的时候不推荐这种方式。几个字段算多我觉得5吧。4.2    构建器上图的字段比例子中的多了几个 构建器构造的对象很清晰而且相对利于维护构造器的话需要修改构造方法构建器在builder对象中加属性就好了。为什么说构建器更安全因为一个对象在可能有多个构造器通过构造器来创建没法保证一致性。比如new Office(id)和new Office(name)这两个对象怎么保证一致呢。4.3    get/set方法不演示了就拿上图来说set属性需要多少行代码起码多两倍不止。5.    关于构建器和构造器JavaBean模式自身有严重的缺点因为构造过程被分到几个调用中在构造过程中Javabean可能处于不一致的状态类无法仅仅通过检验构造器参数的有效性来保证一致性。JavaBean模式阻止了把类做成不可变的可能这就需要程序员付出额外的努力确保线程安全 。Java中传统的抽象工厂实现是Class对象newInstance方法总是企图调用类的无参构造器这个构造器甚至可能根本不存在。Class.newInstance破坏了编译时的异常检查。Builder模式也存在不足。为了创建对象必须先创建它的构建器。在十分注重性能的情况下可能就成问题了。Builder模式还比重叠构造器模式更加冗长因此它只在有很多参数的时候才使用比如4个或者更多个参数。通常最好一开始就使用构建器。如果类的构造器或者静态工厂中具有多个参数设计这种类时Builder模式就是种不错的选择特别是当大多数参数都是可选的时候。与使用传统的重叠构造器模式相比使用Builder模式的客户端代码将更易于阅读和编写构建器也比JavaBeans更加安全。参考资料 《Effective Java 中文版 第2版》
http://www.zqtcl.cn/news/936566/

相关文章:

  • 网站开发学院网页制作模板html图片
  • 企业门户网站模板html上线网站备案和实名认证
  • 抖音代运营内容seo职业规划
  • dedecms网站制作教程做网站买好域名怎么办
  • 网站建立于网页设计ai网站设计
  • 青海省建设工程造价网站电商设计网站培训
  • 软件开发过程的阶段划分优化手机访问网站速度
  • 知名网站建设公司做分销网站好吗
  • 服务器php网站打不开潍坊网站模板在哪
  • 网站管理员要干些什么开发公司专票
  • 陕西省建设银行网站6网站都有什么类型的
  • 哪里有做网站设计全国室内设计学校
  • 简单的网站php开发教程账户竞价托管哪里好
  • dede网站搬家教程浙江省住房和城乡建设部网站
  • 网站分页符怎么做做网站是什么意思
  • 影视网站开发工程师店铺装修
  • ip138查询网站网址域名ip网站外包制作
  • 网站建设需求怎么写网站seo快速排名优化
  • 网站后台文章添加成功 不显示注册安全工程师是干什么的
  • 网页制作网站建设百度网站推广费用多少钱
  • 长沙网站建设软件wordpress加菜单
  • 网站建设教育板块wordpress $pagenow
  • 岳阳手机网站建设自己可以给公司做网站吗
  • 旅游网站建设目的关于建设网站的需求分析
  • 手机可以建立网站吗自己造网站
  • 厦门建网站哪家好手机编程网站
  • 网站搭建后台奥门网站建设
  • 电子商务网站免费模板展示型网站与营销型网站
  • 除了红动中国还有哪些设计网站宁波建网站哪家
  • 网站的建设费用预算策划书wdcp网站备份