@Test public void build2() { List<String> categoryList = new ArrayList<>(); categoryList.add("test_category_1"); categoryList.add(null); categoryList.add("test_category_2"); categoryList.add(""); Publisher publisher = new Publisher.Builder() .setId("test_id") .setName("test_name") .setDomain("test_domain") .addCategory("test_category") .addCategories(categoryList) .build(); publisher.build(builder); Context.App.Publisher protoPublisher = builder.getPub(); assertNotNull(protoPublisher); assertEquals("test_id", protoPublisher.getId()); assertEquals("test_name", protoPublisher.getName()); assertEquals("test_domain", protoPublisher.getDomain()); assertNotNull(protoPublisher.getCatList()); assertEquals(3, protoPublisher.getCatList().size()); assertEquals("test_category", protoPublisher.getCatList().get(0)); assertEquals("test_category_1", protoPublisher.getCatList().get(1)); assertEquals("test_category_2", protoPublisher.getCatList().get(2)); }
void build(Context.App.Builder builder) { Context.App.Publisher.Builder publisherBuilder = Context.App.Publisher.newBuilder(); if (id != null) { publisherBuilder.setId(id); } if (name != null) { publisherBuilder.setName(name); } if (domain != null) { publisherBuilder.setDomain(domain); } if (categories != null) { publisherBuilder.addAllCat(categories); } builder.setPub(publisherBuilder.build()); }
Publisher { void build(Context.App.Builder builder) { Context.App.Publisher.Builder publisherBuilder = Context.App.Publisher.newBuilder(); if (id != null) { publisherBuilder.setId(id); } if (name != null) { publisherBuilder.setName(name); } if (domain != null) { publisherBuilder.setDomain(domain); } if (categories != null) { publisherBuilder.addAllCat(categories); } builder.setPub(publisherBuilder.build()); } }
Publisher { void build(Context.App.Builder builder) { Context.App.Publisher.Builder publisherBuilder = Context.App.Publisher.newBuilder(); if (id != null) { publisherBuilder.setId(id); } if (name != null) { publisherBuilder.setName(name); } if (domain != null) { publisherBuilder.setDomain(domain); } if (categories != null) { publisherBuilder.addAllCat(categories); } builder.setPub(publisherBuilder.build()); } private  Publisher(@Nullable String id,
                      @Nullable String name,
                      @Nullable String domain,
                      @Nullable List<String> categories); }
Publisher { void build(Context.App.Builder builder) { Context.App.Publisher.Builder publisherBuilder = Context.App.Publisher.newBuilder(); if (id != null) { publisherBuilder.setId(id); } if (name != null) { publisherBuilder.setName(name); } if (domain != null) { publisherBuilder.setDomain(domain); } if (categories != null) { publisherBuilder.addAllCat(categories); } builder.setPub(publisherBuilder.build()); } private  Publisher(@Nullable String id,
                      @Nullable String name,
                      @Nullable String domain,
                      @Nullable List<String> categories);  }
Publisher { void build(Context.App.Builder builder) { Context.App.Publisher.Builder publisherBuilder = Context.App.Publisher.newBuilder(); if (id != null) { publisherBuilder.setId(id); } if (name != null) { publisherBuilder.setName(name); } if (domain != null) { publisherBuilder.setDomain(domain); } if (categories != null) { publisherBuilder.addAllCat(categories); } builder.setPub(publisherBuilder.build()); } private  Publisher(@Nullable String id,
                      @Nullable String name,
                      @Nullable String domain,
                      @Nullable List<String> categories);   }