真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

Java8consumer風(fēng)格Builder-創(chuàng)新互聯(lián)

創(chuàng)新互聯(lián)為您提適合企業(yè)的網(wǎng)站設(shè)計(jì)?讓您的網(wǎng)站在搜索引擎具有高度排名,讓您的網(wǎng)站具備超強(qiáng)的網(wǎng)絡(luò)競(jìng)爭(zhēng)力!結(jié)合企業(yè)自身,進(jìn)行網(wǎng)站設(shè)計(jì)及把握,最后結(jié)合企業(yè)文化和具體宗旨等,才能創(chuàng)作出一份性化解決方案。從網(wǎng)站策劃到網(wǎng)站制作、做網(wǎng)站, 我們的網(wǎng)頁(yè)設(shè)計(jì)師為您提供的解決方案。> 1 public static class GenericBuilder { 2 private final Supplier instantiate; 3 4 private final List> consumers = new ArrayList<>(); 5 6 public GenericBuilder(Supplier instantiate) { 7 this.instantiate = instantiate; 8 } 9 10 public static GenericBuilder of(Supplier instantiator) { 11 return new GenericBuilder<>(instantiator); 12 } 13 14 public GenericBuilder with(BiConsumer biConsumer, U value) { 15 Consumer setOperationFunction = instance -> biConsumer.accept(instance, value); 16 consumers.add(setOperationFunction); 17 return this; 18 } 19 20 public T build() { 21 T instance = instantiate.get(); 22 23 // loop call each set function with object instance!24 consumers.forEach(consumer -> consumer.accept(instance)); 25 consumers.clear(); 26 27 return instance; 28 } 29 }使用:Java8consumer風(fēng)格B
uilder
 1 public class Dummy {
 2 private String name;
 3 private Integer age;
 4 private Boolean foreigner;
 5 
 6 public String getName() {
 7  return name;
 8         }
 9 
10 public void setName(String name) {
11  this.name = name;
12         }
13 
14 public Integer getAge() {
15  return age;
16         }
17 
18 public void setAge(Integer age) {
19  this.age = age;
20         }
21 
22 public Boolean getForeigner() {
23  return foreigner;
24         }
25 
26 public void setForeigner(Boolean foreigner) {
27  this.foreigner = foreigner;
28         }
29 
30 
31     }
Dummy build = GenericBuilder.of(Dummy::new).with(Dummy::setAge, 12)
                .with(Dummy::setName,"Vodoo")
                .with(Dummy::setForeigner,false).build();

本文題目:Java8consumer風(fēng)格Builder-創(chuàng)新互聯(lián)
文章位置:http://weahome.cn/article/djhcgi.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部