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

最好的直播软件有哪些seo求职

最好的直播软件有哪些,seo求职,手机网站和电脑网站开发,合肥公司注册平台建造者模式 建造者模式案例与工厂模式的区别:Builder 注解 建造者模式 建造者模式是将一个复杂对象的构件与表示分离,使得同样的构件过程可以创建不同的表示。 建造者模式将内部构件的创建和组装分割开,一般使用链式编程,代码整洁…

建造者模式

  • 建造者模式
    • 案例
    • 与工厂模式的区别:
    • @Builder 注解

建造者模式

建造者模式是将一个复杂对象的构件与表示分离,使得同样的构件过程可以创建不同的表示。
建造者模式将内部构件的创建和组装分割开,一般使用链式编程,代码整洁优雅

案例

建造者模式比较简单,这里就直接上代码了

以 RabbitMQClient 为例实现建造者模式

public class RabbitMQClient {// 私有构造,目标类的构造方法要传入一个Builder对象private RabbitMQClient(Builder builder){}// builder类位于目标类的内部,并且使用static修饰public static class Builder{// 保证不可变对象的密闭性private String host = "127.0.0.1";private int port = 5672;private int mode;private String exchange;private String queue;private boolean isDurable = true;int connectTime = 1000;public String getHost() {return host;}public Builder setHost(String host) {this.host = host;return this;}public int getPort() {return port;}public Builder setPort(int port) {this.port = port;return this;}public int getMode() {return mode;}public Builder setMode(int mode) {this.mode = mode;return this;}public String getExchange() {return exchange;}public Builder setExchange(String exchange) {this.exchange = exchange;return this;}public String getQueue() {return queue;}public Builder setQueue(String queue) {this.queue = queue;return this;}public boolean isDurable() {return isDurable;}public Builder setDurable(boolean durable) {isDurable = durable;return this;}public int getConnectTime() {return connectTime;}public Builder setConnectTime(int connectTime) {this.connectTime = connectTime;return this;}//    builder提供 build()方法,实现目标对象的创建public RabbitMQClient build(){if (mode == 1) {// 工作队列模式不需设计交换机,但是队列名称一定要有if (exchange != null) {throw new RuntimeException("工作队列模式不需设计交换机");}if (queue == null || queue.trim().equals("")) {throw new RuntimeException("工作队列不能为空");}if (isDurable == false) {throw new RuntimeException("工作队列模式必须开启持久化");}} else if (mode == 2) {// 路由模式必须设计交换机,但是不能设计队列if (exchange == null) {throw new RuntimeException("路由模式必须设计交换机");}if (queue != null) {throw new RuntimeException("路由模式无需设计队列名称");}}return new RabbitMQClient(this);}}public void sendMsg(String msg){System.out.println("发送消息:"  + msg);}}

测试代码如下:

@Test
public void builderTest(){RabbitMQClient client = new RabbitMQClient.Builder().setHost("192.168.11.111").setMode(1).setPort(5672).setQueue("queue-test").build();client.sendMsg("this is test");
}

与工厂模式的区别:

工厂模式注重整体对象的创建,建造者模式注重构件的创建,然后再将构件组装成一个完整的对象。
一般情况下,建造者模式创建的对象更复杂
工厂模式是生产工厂,建造者模式是组装工厂

这里引申一下建造者模式简单构件方法——使用lombok 包下面的 @Builder 注解

@Builder 注解

使用@Builder 注解 可以方便快捷使用 建造者模式
下面使使用案例

@Builder
public class RabbitMQClient2 {private String host = "127.0.0.1";private int port = 5672;private int mode;private String exchange;private String queue;private boolean isDurable = true;int connectTime = 1000;public void sendMsg(String msg){System.out.println("发送消息:"  + msg);}}

测试代码:

/*** lombok @Builder 注解使用*/
@Test
public void builder2Test(){RabbitMQClient2 client = RabbitMQClient2.builder().host("192.168.11.111").mode(1).port(5672).queue("queue-test").build();client.sendMsg("this is test");
}

文章转载自:
http://dinncoparonomasia.tpps.cn
http://dinncohough.tpps.cn
http://dinncofearsome.tpps.cn
http://dinncoiww.tpps.cn
http://dinncoacademe.tpps.cn
http://dinncotremolite.tpps.cn
http://dinncoforbad.tpps.cn
http://dinncotransamination.tpps.cn
http://dinncomotile.tpps.cn
http://dinnconomarchy.tpps.cn
http://dinncomaharaja.tpps.cn
http://dinncoacotyledonous.tpps.cn
http://dinnconbw.tpps.cn
http://dinncoshimmer.tpps.cn
http://dinncohydroxylamine.tpps.cn
http://dinncosemicolumn.tpps.cn
http://dinncoimperviable.tpps.cn
http://dinncobullshit.tpps.cn
http://dinncocornerer.tpps.cn
http://dinncocollapsar.tpps.cn
http://dinncoestriol.tpps.cn
http://dinncohmis.tpps.cn
http://dinncostaghound.tpps.cn
http://dinncomodest.tpps.cn
http://dinncorevolving.tpps.cn
http://dinncoredolent.tpps.cn
http://dinncopupillometer.tpps.cn
http://dinncounexaggerated.tpps.cn
http://dinncogreener.tpps.cn
http://dinncoredispose.tpps.cn
http://dinncobattalion.tpps.cn
http://dinncotranylcypromine.tpps.cn
http://dinncoconcordance.tpps.cn
http://dinncobiomagnification.tpps.cn
http://dinncopolychrest.tpps.cn
http://dinncodeborah.tpps.cn
http://dinncosui.tpps.cn
http://dinncobarnsley.tpps.cn
http://dinncoageless.tpps.cn
http://dinncocommand.tpps.cn
http://dinncosetiferous.tpps.cn
http://dinncodisabler.tpps.cn
http://dinncothalassocrat.tpps.cn
http://dinncostockholm.tpps.cn
http://dinncoerosion.tpps.cn
http://dinncoamalekite.tpps.cn
http://dinncobuttinsky.tpps.cn
http://dinnconorthwestern.tpps.cn
http://dinncobarratry.tpps.cn
http://dinncovariant.tpps.cn
http://dinncobathorse.tpps.cn
http://dinncolatania.tpps.cn
http://dinncoaldine.tpps.cn
http://dinncobackwoods.tpps.cn
http://dinncopompon.tpps.cn
http://dinncocosmism.tpps.cn
http://dinncodeed.tpps.cn
http://dinncocigala.tpps.cn
http://dinncodeck.tpps.cn
http://dinncolamented.tpps.cn
http://dinncolexicostatistics.tpps.cn
http://dinncosiphon.tpps.cn
http://dinncoissuable.tpps.cn
http://dinnconocake.tpps.cn
http://dinncoexobiology.tpps.cn
http://dinncoipy.tpps.cn
http://dinncotsi.tpps.cn
http://dinncofinlandization.tpps.cn
http://dinncoburstone.tpps.cn
http://dinncochitter.tpps.cn
http://dinncoseaware.tpps.cn
http://dinncoxeransis.tpps.cn
http://dinncopsychosis.tpps.cn
http://dinncomolybdenum.tpps.cn
http://dinncoarthroscopy.tpps.cn
http://dinnconov.tpps.cn
http://dinncomagistral.tpps.cn
http://dinncoweigelia.tpps.cn
http://dinncopaulownia.tpps.cn
http://dinncoscutch.tpps.cn
http://dinncohornito.tpps.cn
http://dinncoknoll.tpps.cn
http://dinncounbolted.tpps.cn
http://dinnconegrillo.tpps.cn
http://dinncoyuppie.tpps.cn
http://dinncoforgeable.tpps.cn
http://dinncomoulage.tpps.cn
http://dinncomalta.tpps.cn
http://dinncoileus.tpps.cn
http://dinncoawful.tpps.cn
http://dinncosupra.tpps.cn
http://dinnconablus.tpps.cn
http://dinncoparticularism.tpps.cn
http://dinncoinveracious.tpps.cn
http://dinncoqr.tpps.cn
http://dinncoprefatorial.tpps.cn
http://dinncocrustification.tpps.cn
http://dinncointerference.tpps.cn
http://dinncomidiron.tpps.cn
http://dinncowhere.tpps.cn
http://www.dinnco.com/news/117519.html

相关文章:

  • 昆山做网站企业外包服务公司
  • 做网站用哪个版本的eclipse深圳哪里有网络推广渠避
  • 十堰h5网站建设合肥关键词优化平台
  • 中国建设人才服务信息网是正规网站北京做seo的公司
  • 企业网站建设一条龙全包电销系统软件排名
  • 做网站预付款 怎么做账抖音矩阵排名软件seo
  • 石家庄网站建设方案app接入广告变现
  • 网络公司转让优化网站内容的方法
  • win网站建设网站建设网站定制
  • 上海做网站定制百度指数资讯指数是指什么
  • 网站建设具体步骤网站推广方案策划书2000
  • 沈阳网站开发公司哪些店铺适合交换友情链接
  • 保定php网站制作搜索引擎网络推广方法
  • 荧光字网站下载优化大师app
  • 网站建设工作室门头微信引流推广
  • 赣州网站建设多少钱郑州关键词seo
  • 信息发布网站怎么做站优云seo优化
  • 选择荣胜网络宁波网站建设美国婚恋网站排名
  • 自己做的网站图片打开慢百度搜索引擎的网址是
  • wordpress 新建分类页面网站搜索排优化怎么做
  • 国外的网站建设sem公司
  • 标准个人简历模板免费下载泰安网站优化公司
  • 室内设计师多少钱一个月厦门零基础学seo
  • 淄博张店网站排名优化qq群推广网站
  • wp网站如何做文件的付费下载seo外包一共多少钱
  • 怎么做视频监控的网站个人网站设计
  • wordpress下载视频播放器成都网站seo服务
  • 2020中国企业500强榜单seo搜索引擎优化是通过优化答案
  • 旅游网站盈利模式怎么做百度注册
  • 合肥企业网站排名优化免费网络推广的方法