io.streamthoughts.jikkou.kafka.reporter.ce.CloudEventEntityBuilder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jikkou-provider-kafka Show documentation
Show all versions of jikkou-provider-kafka Show documentation
Integration between Apache Kafka and Jikkou
The newest version!
/*
* SPDX-License-Identifier: Apache-2.0
* Copyright (c) The original authors
*
* Licensed under the Apache Software License version 2.0, available at http://www.apache.org/licenses/LICENSE-2.0
*/
package io.streamthoughts.jikkou.kafka.reporter.ce;
import java.time.ZonedDateTime;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;
public final class CloudEventEntityBuilder extends CloudEventAttributes {
private T data;
private final List extensions;
public static CloudEventEntityBuilder newBuilder() {
return new CloudEventEntityBuilder<>();
}
/** Creates a new {@link CloudEventEntityBuilder} instance. */
private CloudEventEntityBuilder() {
super();
this.extensions = new LinkedList<>();
}
/** @see CloudEventAttributes#id() */
public CloudEventEntityBuilder withId(final String id) {
this.id = id;
return this;
}
/** @see CloudEventAttributes#type() */
public CloudEventEntityBuilder withType(final String type) {
this.type = type;
return this;
}
/** @see CloudEventAttributes#source() */
public CloudEventEntityBuilder withSource(final String source) {
this.source = source;
return this;
}
/** @see CloudEventAttributes#source() */
public CloudEventEntityBuilder withSubject(final String subject) {
this.subject = subject;
return this;
}
/** @see CloudEventAttributes#specVersion() */
public CloudEventEntityBuilder withSpecVersion(final String specVersion) {
this.specVersion = specVersion;
return this;
}
/** @see CloudEventAttributes#time() */
public CloudEventEntityBuilder withTime(final ZonedDateTime time) {
this.time = time;
return this;
}
/** @see CloudEventAttributes#dataContentType() */
public CloudEventEntityBuilder withDataContentType(final String dataContentType) {
this.dataContentType = dataContentType;
return this;
}
public CloudEventEntityBuilder withData(final T data) {
this.data = data;
return this;
}
public CloudEventEntityBuilder withExtension(final CloudEventExtension extension) {
this.extensions.add(extension);
return this;
}
/**
* Builds a new cloud event entity
*
* @return a new {@link CloudEventEntity} instance.
*/
public CloudEventEntity build() {
return new CloudEventEntity<>(this, extensions, data);
}
/** {@inheritDoc} */
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
if (!super.equals(o)) return false;
CloudEventEntityBuilder> that = (CloudEventEntityBuilder>) o;
return Objects.equals(data, that.data) && Objects.equals(extensions, that.extensions);
}
/** {@inheritDoc} */
@Override
public int hashCode() {
return Objects.hash(super.hashCode(), data, extensions);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy