ProtocolBuilder extends AbstractBuilder<ProtocolConfig, ProtocolBuilder> { public ProtocolConfig build() { ProtocolConfig protocolConfig = new ProtocolConfig(); super.build(protocolConfig); protocolConfig.setAccepts(accepts); protocolConfig.setAccesslog(accesslog); protocolConfig.setBuffer(buffer); protocolConfig.setCharset(charset); protocolConfig.setClient(client); protocolConfig.setCodec(codec); protocolConfig.setContextpath(contextpath); protocolConfig.setCorethreads(corethreads); protocolConfig.setDefault(isDefault); protocolConfig.setDispatcher(dispatcher); protocolConfig.setExchanger(exchanger); protocolConfig.setExtension(extension); protocolConfig.setHeartbeat(heartbeat); protocolConfig.setHost(host); protocolConfig.setIothreads(iothreads); protocolConfig.setKeepAlive(keepAlive); protocolConfig.setName(name); protocolConfig.setNetworker(networker); protocolConfig.setOptimizer(optimizer); protocolConfig.setParameters(parameters); protocolConfig.setPayload(payload); protocolConfig.setPort(port); protocolConfig.setPrompt(prompt); protocolConfig.setQueues(queues); protocolConfig.setRegister(register); protocolConfig.setSerialization(serialization); protocolConfig.setServer(server); protocolConfig.setStatus(status); protocolConfig.setTelnet(telnet); protocolConfig.setThreadpool(threadpool); protocolConfig.setThreads(threads); protocolConfig.setTransporter(transporter); return protocolConfig; }  static ProtocolBuilder newBuilder(); ProtocolBuilder id(String id); ProtocolBuilder name(String name); ProtocolBuilder host(String host); ProtocolBuilder port(Integer port); ProtocolBuilder contextpath(String contextpath); @Deprecated ProtocolBuilder path(String path); ProtocolBuilder threadpool(String threadpool); ProtocolBuilder corethreads(Integer corethreads); ProtocolBuilder threads(Integer threads); ProtocolBuilder iothreads(Integer iothreads); ProtocolBuilder queues(Integer queues); ProtocolBuilder accepts(Integer accepts); ProtocolBuilder codec(String codec); ProtocolBuilder serialization(String serialization); ProtocolBuilder charset(String charset); ProtocolBuilder payload(Integer payload); ProtocolBuilder buffer(Integer buffer); ProtocolBuilder heartbeat(Integer heartbeat); ProtocolBuilder accesslog(String accesslog); ProtocolBuilder transporter(String transporter); ProtocolBuilder exchanger(String exchanger); ProtocolBuilder dispatcher(String dispatcher); @Deprecated ProtocolBuilder dispather(String dispather); ProtocolBuilder networker(String networker); ProtocolBuilder server(String server); ProtocolBuilder client(String client); ProtocolBuilder telnet(String telnet); ProtocolBuilder prompt(String prompt); ProtocolBuilder status(String status); ProtocolBuilder register(Boolean register); ProtocolBuilder keepAlive(Boolean keepAlive); ProtocolBuilder optimizer(String optimizer); ProtocolBuilder extension(String extension); ProtocolBuilder appendParameter(String key, String value); ProtocolBuilder appendParameters(Map<String, String> appendParameters); ProtocolBuilder isDefault(Boolean isDefault); ProtocolConfig build();  }
@Test void build() { ProtocolBuilder builder = new ProtocolBuilder(); builder.name("name").host("host").port(8080).contextpath("contextpath").threadpool("mockthreadpool") .corethreads(1).threads(2).iothreads(3).queues(4).accepts(5).codec("mockcodec") .serialization("serialization").charset("utf-8").payload(6).buffer(1024).heartbeat(1000) .accesslog("accesslog").transporter("mocktransporter").exchanger("mockexchanger") .dispatcher("mockdispatcher").networker("networker").server("server").client("client") .telnet("mocktelnethandler").prompt("prompt").status("mockstatuschecker").register(true).keepAlive(false) .optimizer("optimizer").extension("extension").isDefault(true) .appendParameter("default.num", "one").id("id").prefix("prefix"); ProtocolConfig config = builder.build(); ProtocolConfig config2 = builder.build(); Assertions.assertEquals(8080, config.getPort()); Assertions.assertEquals(1, config.getCorethreads()); Assertions.assertEquals(2, config.getThreads()); Assertions.assertEquals(3, config.getIothreads()); Assertions.assertEquals(4, config.getQueues()); Assertions.assertEquals(5, config.getAccepts()); Assertions.assertEquals(6, config.getPayload()); Assertions.assertEquals(1024, config.getBuffer()); Assertions.assertEquals(1000, config.getHeartbeat()); Assertions.assertEquals("name", config.getName()); Assertions.assertEquals("host", config.getHost()); Assertions.assertEquals("contextpath", config.getContextpath()); Assertions.assertEquals("mockthreadpool", config.getThreadpool()); Assertions.assertEquals("mockcodec", config.getCodec()); Assertions.assertEquals("serialization", config.getSerialization()); Assertions.assertEquals("utf-8", config.getCharset()); Assertions.assertEquals("accesslog", config.getAccesslog()); Assertions.assertEquals("mocktransporter", config.getTransporter()); Assertions.assertEquals("mockexchanger", config.getExchanger()); Assertions.assertEquals("mockdispatcher", config.getDispatcher()); Assertions.assertEquals("networker", config.getNetworker()); Assertions.assertEquals("server", config.getServer()); Assertions.assertEquals("client", config.getClient()); Assertions.assertEquals("mocktelnethandler", config.getTelnet()); Assertions.assertEquals("prompt", config.getPrompt()); Assertions.assertEquals("mockstatuschecker", config.getStatus()); Assertions.assertEquals("optimizer", config.getOptimizer()); Assertions.assertEquals("extension", config.getExtension()); Assertions.assertTrue(config.isRegister()); Assertions.assertFalse(config.getKeepAlive()); Assertions.assertTrue(config.isDefault()); Assertions.assertTrue(config.getParameters().containsKey("default.num")); Assertions.assertEquals("one", config.getParameters().get("default.num")); Assertions.assertEquals("id", config.getId()); Assertions.assertEquals("prefix", config.getPrefix()); Assertions.assertNotSame(config, config2); }