Rename extension (#339)
* Fixed broken links Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> * Renamed Extension to CloudEventExtension Signed-off-by: Francesco Guardiani <francescoguard@gmail.com> Co-authored-by: slinkydeveloper <slinkydeveloper@users.noreply.github.com>
This commit is contained in:
parent
12eee4da6e
commit
e523bfbfbf
|
|
@ -23,10 +23,10 @@ import javax.annotation.ParametersAreNonnullByDefault;
|
|||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Materialized CloudEvent Extension interface to read/write the extension attributes key/values.
|
||||
* Materialized CloudEvent extension interface to read/write the extension attributes key/values.
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public interface Extension {
|
||||
public interface CloudEventExtension {
|
||||
|
||||
/**
|
||||
* Fill this materialized extension with values from a {@link CloudEventExtensions} implementation.
|
||||
|
|
@ -192,7 +192,7 @@ public interface CloudEventBuilder extends CloudEventWriter<CloudEvent> {
|
|||
* @param extension materialized extension to set in the builder
|
||||
* @return self
|
||||
*/
|
||||
CloudEventBuilder withExtension(@Nonnull Extension extension);
|
||||
CloudEventBuilder withExtension(@Nonnull CloudEventExtension extension);
|
||||
|
||||
/**
|
||||
* Remove from the the builder the provided extension key, if any
|
||||
|
|
@ -208,7 +208,7 @@ public interface CloudEventBuilder extends CloudEventWriter<CloudEvent> {
|
|||
* @param extension materialized extension to remove from the builder
|
||||
* @return self
|
||||
*/
|
||||
CloudEventBuilder withoutExtension(@Nonnull Extension extension);
|
||||
CloudEventBuilder withoutExtension(@Nonnull CloudEventExtension extension);
|
||||
|
||||
/**
|
||||
* Build the event
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
package io.cloudevents.core.extensions;
|
||||
|
||||
import io.cloudevents.CloudEventExtensions;
|
||||
import io.cloudevents.Extension;
|
||||
import io.cloudevents.CloudEventExtension;
|
||||
import io.cloudevents.core.extensions.impl.ExtensionUtils;
|
||||
|
||||
import java.net.URI;
|
||||
|
|
@ -31,7 +31,7 @@ import java.util.Set;
|
|||
*
|
||||
* @see <a href=https://github.com/cloudevents/spec/blob/v1.0/extensions/dataref.md>https://github.com/cloudevents/spec/blob/v1.0/extensions/dataref.md</a>
|
||||
*/
|
||||
public final class DatarefExtension implements Extension {
|
||||
public final class DatarefExtension implements CloudEventExtension {
|
||||
|
||||
/**
|
||||
* The key of the {@code dataref} extension
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
package io.cloudevents.core.extensions;
|
||||
|
||||
import io.cloudevents.CloudEventExtensions;
|
||||
import io.cloudevents.Extension;
|
||||
import io.cloudevents.CloudEventExtension;
|
||||
import io.cloudevents.core.extensions.impl.ExtensionUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -28,7 +28,7 @@ import java.util.*;
|
|||
*
|
||||
* @see <a href="https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md">https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md</a>
|
||||
*/
|
||||
public final class DistributedTracingExtension implements Extension {
|
||||
public final class DistributedTracingExtension implements CloudEventExtension {
|
||||
|
||||
/**
|
||||
* The key of the {@code traceparent} extension
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
package io.cloudevents.core.extensions.impl;
|
||||
|
||||
import io.cloudevents.Extension;
|
||||
import io.cloudevents.CloudEventExtension;
|
||||
|
||||
/**
|
||||
* Collection of utilities to deal with materialized extensions
|
||||
|
|
@ -28,11 +28,11 @@ public final class ExtensionUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param clazz the {@link Extension} class
|
||||
* @param clazz the {@link CloudEventExtension} class
|
||||
* @param key the invalid key
|
||||
* @return an {@link IllegalArgumentException} when trying to access a key of the extension not existing.
|
||||
*/
|
||||
public static IllegalArgumentException generateInvalidKeyException(Class<? extends Extension> clazz, String key) {
|
||||
public static IllegalArgumentException generateInvalidKeyException(Class<? extends CloudEventExtension> clazz, String key) {
|
||||
return new IllegalArgumentException(clazz.getName() + " doesn't expect the attribute key \"" + key + "\"");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ package io.cloudevents.core.impl;
|
|||
import io.cloudevents.CloudEvent;
|
||||
import io.cloudevents.CloudEventContext;
|
||||
import io.cloudevents.CloudEventData;
|
||||
import io.cloudevents.Extension;
|
||||
import io.cloudevents.CloudEventExtension;
|
||||
import io.cloudevents.core.builder.CloudEventBuilder;
|
||||
import io.cloudevents.core.data.BytesCloudEventData;
|
||||
import io.cloudevents.rw.CloudEventRWException;
|
||||
|
|
@ -147,12 +147,12 @@ public abstract class BaseCloudEventBuilder<SELF extends BaseCloudEventBuilder<S
|
|||
}
|
||||
|
||||
@Override
|
||||
public SELF withoutExtension(@Nonnull Extension extension) {
|
||||
public SELF withoutExtension(@Nonnull CloudEventExtension extension) {
|
||||
extension.getKeys().forEach(this::withoutExtension);
|
||||
return self;
|
||||
}
|
||||
|
||||
public SELF withExtension(@Nonnull Extension extension) {
|
||||
public SELF withExtension(@Nonnull CloudEventExtension extension) {
|
||||
for (String key : extension.getKeys()) {
|
||||
Object value = extension.getValue(key);
|
||||
if (value != null) {
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
package io.cloudevents.core.provider;
|
||||
|
||||
import io.cloudevents.CloudEventExtensions;
|
||||
import io.cloudevents.Extension;
|
||||
import io.cloudevents.CloudEventExtension;
|
||||
import io.cloudevents.core.extensions.DatarefExtension;
|
||||
import io.cloudevents.core.extensions.DistributedTracingExtension;
|
||||
import io.cloudevents.lang.Nullable;
|
||||
|
|
@ -30,7 +30,7 @@ import java.util.function.Supplier;
|
|||
/**
|
||||
* Singleton to materialize CloudEvent extensions as POJOs.
|
||||
* <p>
|
||||
* You can materialize an {@link Extension} POJO with {@code ExtensionProvider.getInstance().parseExtension(DistributedTracingExtension.class, event)}.
|
||||
* You can materialize an {@link CloudEventExtension} POJO with {@code ExtensionProvider.getInstance().parseExtension(DistributedTracingExtension.class, event)}.
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public final class ExtensionProvider {
|
||||
|
|
@ -59,10 +59,10 @@ public final class ExtensionProvider {
|
|||
* Register a new extension type.
|
||||
*
|
||||
* @param <T> the type of the extension
|
||||
* @param extensionClass the class implementing {@link Extension}
|
||||
* @param extensionClass the class implementing {@link CloudEventExtension}
|
||||
* @param factory the empty arguments factory
|
||||
*/
|
||||
public <T extends Extension> void registerExtension(Class<T> extensionClass, Supplier<T> factory) {
|
||||
public <T extends CloudEventExtension> void registerExtension(Class<T> extensionClass, Supplier<T> factory) {
|
||||
this.extensionFactories.put(extensionClass, factory);
|
||||
}
|
||||
|
||||
|
|
@ -70,16 +70,16 @@ public final class ExtensionProvider {
|
|||
* Parse an extension from the {@link CloudEventExtensions}, materializing the corresponding POJO.
|
||||
*
|
||||
* @param <T> the type of the extension
|
||||
* @param extensionClass the class implementing {@link Extension}
|
||||
* @param extensionClass the class implementing {@link CloudEventExtension}
|
||||
* @param eventExtensions the event extensions to read
|
||||
* @return the parsed extension
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@Nullable
|
||||
public <T extends Extension> T parseExtension(Class<T> extensionClass, CloudEventExtensions eventExtensions) {
|
||||
public <T extends CloudEventExtension> T parseExtension(Class<T> extensionClass, CloudEventExtensions eventExtensions) {
|
||||
Supplier<?> factory = extensionFactories.get(extensionClass);
|
||||
if (factory != null) {
|
||||
Extension ext = (Extension) factory.get();
|
||||
CloudEventExtension ext = (CloudEventExtension) factory.get();
|
||||
ext.readFrom(eventExtensions);
|
||||
return (T) ext;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,7 +61,5 @@ core module.
|
|||
|
||||
## Other interfaces
|
||||
|
||||
- `Extension` represents a _materialized_ in-memory representation of a
|
||||
CloudEvent extension
|
||||
- `SpecVersion` is an enum of CloudEvents' specification versions supported by
|
||||
this SDK version.
|
||||
- `CloudEventExtension` represents a _materialized_ in-memory representation of a CloudEvent extension
|
||||
- `SpecVersion` is an enum of CloudEvents' specification versions supported by this SDK version.
|
||||
|
|
|
|||
Loading…
Reference in New Issue