getting the builder instance of the builder() method

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-08-26 21:54:16 -03:00
parent 3cecb769f1
commit d040bcef32
6 changed files with 24 additions and 22 deletions

View File

@ -125,7 +125,7 @@ public class BinaryMarshaller<P, T, A extends Attributes> {
final ExtensionFormat tracing = new DistributedTracingExtension.Format(dt);
final CloudEventImpl<String> ce =
new CloudEventBuilder<String>()
CloudEventBuilder.<String>builder()
.withId("x10")
.withSource(URI.create("/source"))
.withType("event-type")

View File

@ -58,6 +58,8 @@ public class CloudEventBuilder<T> implements EventBuilder<T, AttributesImpl> {
private final Set<ExtensionFormat> extensions = new HashSet<>();
private CloudEventBuilder() {}
private static Validator getValidator() {
if(null== VALIDATOR) {
VALIDATOR = Validation.buildDefaultValidatorFactory().getValidator();

View File

@ -124,7 +124,7 @@ public class CloudEventImpl<T> implements CloudEvent<AttributesImpl, T> {
@JsonProperty("contenttype") String contenttype,
@JsonProperty("data") T data) {
return new CloudEventBuilder<T>()
return CloudEventBuilder.<T>builder()
.withId(id)
.withSource(source)
.withType(type)

View File

@ -36,7 +36,7 @@ public class CustomEventTypesTest {
// given
final Map<String, Object> storagePayload = (MAPPER.readValue(Thread.currentThread().getContextClassLoader().getResourceAsStream("pvc.json"), Map.class));
final CloudEventImpl<Map<String, Object>> storageCloudEventWrapper = new CloudEventBuilder<Map<String, Object>>()
final CloudEventImpl<Map<String, Object>> storageCloudEventWrapper = CloudEventBuilder.<Map<String, Object>>builder()
.withType("ProvisioningSucceeded")
.withSource(URI.create("/scheduler"))
.withId(UUID.randomUUID().toString())

View File

@ -47,7 +47,7 @@ public class CloudEventBuilderTest {
expectedEx.expectMessage("invalid payload: 'id' must not be blank");
// act
new CloudEventBuilder<Object>()
CloudEventBuilder.<Object>builder()
.withSource(URI.create("/test"))
.withType("type")
.build();
@ -60,7 +60,7 @@ public class CloudEventBuilderTest {
expectedEx.expectMessage("invalid payload: 'id' must not be blank");
// act
new CloudEventBuilder<Object>()
CloudEventBuilder.<Object>builder()
.withId("")
.withSource(URI.create("/test"))
.withType("type")
@ -74,7 +74,7 @@ public class CloudEventBuilderTest {
expectedEx.expectMessage("invalid payload: 'type' must not be blank");
// act
new CloudEventBuilder<Object>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/test"))
.build();
@ -87,7 +87,7 @@ public class CloudEventBuilderTest {
expectedEx.expectMessage("invalid payload: 'type' must not be blank");
// act
new CloudEventBuilder<Object>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/test"))
.withType("")
@ -101,7 +101,7 @@ public class CloudEventBuilderTest {
expectedEx.expectMessage("invalid payload: 'source' must not be null");
// act
new CloudEventBuilder<Object>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withType("type")
.build();
@ -111,7 +111,7 @@ public class CloudEventBuilderTest {
public void should_have_id() {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -125,7 +125,7 @@ public class CloudEventBuilderTest {
public void should_have_source() {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -139,7 +139,7 @@ public class CloudEventBuilderTest {
public void should_have_type() {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -153,7 +153,7 @@ public class CloudEventBuilderTest {
public void should_have_specversion() {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -170,7 +170,7 @@ public class CloudEventBuilderTest {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -189,7 +189,7 @@ public class CloudEventBuilderTest {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -208,7 +208,7 @@ public class CloudEventBuilderTest {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -227,7 +227,7 @@ public class CloudEventBuilderTest {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -250,7 +250,7 @@ public class CloudEventBuilderTest {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")
@ -276,7 +276,7 @@ public class CloudEventBuilderTest {
// act
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("id")
.withSource(URI.create("/source"))
.withType("type")

View File

@ -49,7 +49,7 @@ public class CloudEventJacksonTest {
public void should_encode_right_with_minimal_attrs() {
// setup
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("x10")
.withSource(URI.create("/source"))
.withType("event-type")
@ -74,7 +74,7 @@ public class CloudEventJacksonTest {
public void should_have_optional_attrs() {
// setup
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("x10")
.withSource(URI.create("/source"))
.withType("event-type")
@ -103,7 +103,7 @@ public class CloudEventJacksonTest {
final ExtensionFormat tracing = new DistributedTracingExtension.Format(dt);
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("x10")
.withSource(URI.create("/source"))
.withType("event-type")
@ -124,7 +124,7 @@ public class CloudEventJacksonTest {
public void should_not_serialize_attributes_element() {
// setup
CloudEventImpl<Object> ce =
new CloudEventBuilder<>()
CloudEventBuilder.<Object>builder()
.withId("x10")
.withSource(URI.create("/source"))
.withType("event-type")