@Test(expected = IllegalArgumentException.class) public void nonNullableUnion() throws Exception { Schema schema = SchemaBuilder.unionOf().stringType().and().intType().endUnion(); underTest.onVisit(schema, breadcrumb); }
@Override public void onVisit(Schema schema, Collection<String> breadcrumb) { if (Type.UNION == schema.getType()) { List<Schema> types = schema.getTypes(); if (types.size() != 2 || (types.get(0).getType() != NULL && types.get(1).getType() != NULL)) { String path = breadcrumb.stream().collect(joining("/", "/", "")); throw new IllegalArgumentException(String .format("Only union[any, null] or union[null, any] are supported. At path %s got %s", path, schema)); } } }
NonNullableUnionValidatingVisitor implements Visitor<Void> { @Override public void onVisit(Schema schema, Collection<String> breadcrumb) { if (Type.UNION == schema.getType()) { List<Schema> types = schema.getTypes(); if (types.size() != 2 || (types.get(0).getType() != NULL && types.get(1).getType() != NULL)) { String path = breadcrumb.stream().collect(joining("/", "/", "")); throw new IllegalArgumentException(String .format("Only union[any, null] or union[null, any] are supported. At path %s got %s", path, schema)); } } } }
NonNullableUnionValidatingVisitor implements Visitor<Void> { @Override public void onVisit(Schema schema, Collection<String> breadcrumb) { if (Type.UNION == schema.getType()) { List<Schema> types = schema.getTypes(); if (types.size() != 2 || (types.get(0).getType() != NULL && types.get(1).getType() != NULL)) { String path = breadcrumb.stream().collect(joining("/", "/", "")); throw new IllegalArgumentException(String .format("Only union[any, null] or union[null, any] are supported. At path %s got %s", path, schema)); } } }  }
NonNullableUnionValidatingVisitor implements Visitor<Void> { @Override public void onVisit(Schema schema, Collection<String> breadcrumb) { if (Type.UNION == schema.getType()) { List<Schema> types = schema.getTypes(); if (types.size() != 2 || (types.get(0).getType() != NULL && types.get(1).getType() != NULL)) { String path = breadcrumb.stream().collect(joining("/", "/", "")); throw new IllegalArgumentException(String .format("Only union[any, null] or union[null, any] are supported. At path %s got %s", path, schema)); } } }  @Override void onVisit(Schema schema, Collection<String> breadcrumb); @Override void onVisit(Field field, Collection<String> breadcrumb); @Override Void getResult(); }
NonNullableUnionValidatingVisitor implements Visitor<Void> { @Override public void onVisit(Schema schema, Collection<String> breadcrumb) { if (Type.UNION == schema.getType()) { List<Schema> types = schema.getTypes(); if (types.size() != 2 || (types.get(0).getType() != NULL && types.get(1).getType() != NULL)) { String path = breadcrumb.stream().collect(joining("/", "/", "")); throw new IllegalArgumentException(String .format("Only union[any, null] or union[null, any] are supported. At path %s got %s", path, schema)); } } }  @Override void onVisit(Schema schema, Collection<String> breadcrumb); @Override void onVisit(Field field, Collection<String> breadcrumb); @Override Void getResult();  }