AbstractInterfaceBuilder extends AbstractMethodBuilder<T, B> { @Override public void build(T instance) { super.build(instance); if (!StringUtils.isEmpty(local)) { instance.setLocal(local); } if (!StringUtils.isEmpty(stub)) { instance.setStub(stub); } if (monitor != null) { instance.setMonitor(monitor); } if (!StringUtils.isEmpty(proxy)) { instance.setProxy(proxy); } if (!StringUtils.isEmpty(cluster)) { instance.setCluster(cluster); } if (!StringUtils.isEmpty(filter)) { instance.setFilter(filter); } if (!StringUtils.isEmpty(listener)) { instance.setListener(listener); } if (!StringUtils.isEmpty(owner)) { instance.setOwner(owner); } if (connections != null) { instance.setConnections(connections); } if (!StringUtils.isEmpty(layer)) { instance.setLayer(layer); } if (application != null) { instance.setApplication(application); } if (module != null) { instance.setModule(module); } if (registries != null) { instance.setRegistries(registries); } if (!StringUtils.isEmpty(registryIds)) { instance.setRegistryIds(registryIds); } if (!StringUtils.isEmpty(onconnect)) { instance.setOnconnect(onconnect); } if (!StringUtils.isEmpty(ondisconnect)) { instance.setOndisconnect(ondisconnect); } if (metadataReportConfig != null) { instance.setMetadataReportConfig(metadataReportConfig); } if (configCenter != null) { instance.setConfigCenter(configCenter); } if (callbacks != null) { instance.setCallbacks(callbacks); } if (!StringUtils.isEmpty(scope)) { instance.setScope(scope); } if (StringUtils.isNotEmpty(tag)) { instance.setTag(tag); } }  @Deprecated B local(String local); @Deprecated B local(Boolean local); B stub(String stub); B stub(Boolean stub); B monitor(MonitorConfig monitor); B monitor(String monitor); B proxy(String proxy); B cluster(String cluster); B filter(String filter); B listener(String listener); B owner(String owner); B connections(Integer connections); B layer(String layer); B application(ApplicationConfig application); B module(ModuleConfig module); B addRegistries(List<RegistryConfig> registries); B addRegistry(RegistryConfig registry); B registryIds(String registryIds); B onconnect(String onconnect); B ondisconnect(String ondisconnect); B metadataReportConfig(MetadataReportConfig metadataReportConfig); B configCenter(ConfigCenterConfig configCenter); B callbacks(Integer callbacks); B scope(String scope); B tag(String tag); @Override void build(T instance);  }
@Test void build() { MonitorConfig monitorConfig = new MonitorConfig("123"); ApplicationConfig applicationConfig = new ApplicationConfig(); ModuleConfig moduleConfig = new ModuleConfig(); RegistryConfig registryConfig = new RegistryConfig(); MetadataReportConfig metadataReportConfig = new MetadataReportConfig(); ConfigCenterConfig configCenterConfig = new ConfigCenterConfig(); InterfaceBuilder builder = new InterfaceBuilder(); builder.id("id").prefix("prefix").local(true).stub(false).monitor("123").proxy("mockproxyfactory").cluster("mockcluster") .filter("mockfilter").listener("mockinvokerlistener").owner("owner").connections(1) .layer("layer").application(applicationConfig).module(moduleConfig) .addRegistry(registryConfig).registryIds("registryIds") .onconnect("onconnet").ondisconnect("ondisconnect") .metadataReportConfig(metadataReportConfig) .configCenter(configCenterConfig) .callbacks(2).scope("scope"); InterfaceConfig config = builder.build(); InterfaceConfig config2 = builder.build(); Assertions.assertEquals("id", config.getId()); Assertions.assertEquals("prefix", config.getPrefix()); Assertions.assertEquals("true", config.getLocal()); Assertions.assertEquals("false", config.getStub()); Assertions.assertEquals(monitorConfig, config.getMonitor()); Assertions.assertEquals("mockproxyfactory", config.getProxy()); Assertions.assertEquals("mockcluster", config.getCluster()); Assertions.assertEquals("mockfilter", config.getFilter()); Assertions.assertEquals("mockinvokerlistener", config.getListener()); Assertions.assertEquals("owner", config.getOwner()); Assertions.assertEquals(1, config.getConnections().intValue()); Assertions.assertEquals("layer", config.getLayer()); Assertions.assertEquals(applicationConfig, config.getApplication()); Assertions.assertEquals(moduleConfig, config.getModule()); Assertions.assertEquals(registryConfig, config.getRegistry()); Assertions.assertEquals("registryIds", config.getRegistryIds()); Assertions.assertEquals("onconnet", config.getOnconnect()); Assertions.assertEquals("ondisconnect", config.getOndisconnect()); Assertions.assertEquals(metadataReportConfig, config.getMetadataReportConfig()); Assertions.assertEquals(configCenterConfig, config.getConfigCenter()); Assertions.assertEquals(2, config.getCallbacks().intValue()); Assertions.assertEquals("scope", config.getScope()); Assertions.assertNotSame(config, config2); }