The method for Accessor, license and use of new ExtensionFormat

Signed-off-by: Fabio José <fabiojose@gmail.com>
This commit is contained in:
Fabio José 2019-08-26 17:36:13 -03:00
parent 66adbdada5
commit c3a94c90d1
1 changed files with 32 additions and 6 deletions

View File

@ -1,3 +1,18 @@
/**
* Copyright 2019 The CloudEvents Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.cloudevents.v02;
import java.net.URI;
@ -20,7 +35,8 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import io.cloudevents.CloudEvent;
import io.cloudevents.ExtensionFormat;
import io.cloudevents.extensions.ExtensionFormat;
import io.cloudevents.extensions.InMemoryFormat;
/**
* The event implementation
@ -39,6 +55,8 @@ public class CloudEventImpl<T> implements CloudEvent<AttributesImpl, T> {
@NotNull
private final Map<String, Object> extensions;
private final Set<ExtensionFormat> extensionsFormats;
CloudEventImpl(AttributesImpl attributes, T data,
Set<ExtensionFormat> extensions) {
@ -47,11 +65,19 @@ public class CloudEventImpl<T> implements CloudEvent<AttributesImpl, T> {
this.data = data;
this.extensions = extensions
.stream()
.collect(Collectors
.toMap(ExtensionFormat::getKey,
ExtensionFormat::getExtension));
this.extensions = extensions.stream()
.map(ExtensionFormat::memory)
.collect(Collectors.toMap(InMemoryFormat::getKey,
InMemoryFormat::getValue));
this.extensionsFormats = extensions;
}
/**
* Used by the {@link Accessor} to access the set of {@link ExtensionFormat}
*/
Set<ExtensionFormat> getExtensionsFormats() {
return extensionsFormats;
}
@JsonUnwrapped