-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from cloudevents/v1
Support for Spec v1.0
- Loading branch information
Showing
45 changed files
with
3,603 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* 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.v1; | ||
|
||
import java.util.Collection; | ||
import java.util.Objects; | ||
|
||
import io.cloudevents.Attributes; | ||
import io.cloudevents.CloudEvent; | ||
import io.cloudevents.extensions.ExtensionFormat; | ||
import io.cloudevents.fun.ExtensionFormatAccessor; | ||
|
||
/** | ||
* | ||
* @author fabiojose | ||
* @version 1.0 | ||
*/ | ||
public class Accessor { | ||
|
||
/** | ||
* To get access the set of {@link ExtensionFormat} inside the | ||
* event. | ||
* | ||
* <br> | ||
* <br> | ||
* This method follow the signature of | ||
* {@link ExtensionFormatAccessor#extensionsOf(CloudEvent)} | ||
* | ||
* @param cloudEvent | ||
* @throws IllegalArgumentException When argument is not an instance | ||
* of {@link CloudEventImpl} | ||
*/ | ||
@SuppressWarnings({"unchecked", "rawtypes"}) | ||
public static <A extends Attributes, T> Collection<ExtensionFormat> | ||
extensionsOf(CloudEvent<A, T> cloudEvent) { | ||
Objects.requireNonNull(cloudEvent); | ||
|
||
if(cloudEvent instanceof CloudEventImpl) { | ||
CloudEventImpl impl = (CloudEventImpl)cloudEvent; | ||
return impl.getExtensionsFormats(); | ||
} | ||
|
||
throw new IllegalArgumentException("Invalid instance type: " | ||
+ cloudEvent.getClass()); | ||
} | ||
} |
Oops, something went wrong.