|
| 1 | +/* |
| 2 | + * Copyright 2018-Present The CloudEvents Authors |
| 3 | + * <p> |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * <p> |
| 8 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * <p> |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + * |
| 16 | + */ |
| 17 | + |
| 18 | +package io.cloudevents.core.format; |
| 19 | + |
| 20 | +import io.cloudevents.CloudEvent; |
| 21 | +import io.cloudevents.CloudEventData; |
| 22 | +import io.cloudevents.rw.CloudEventDataMapper; |
| 23 | + |
| 24 | +import javax.annotation.ParametersAreNonnullByDefault; |
| 25 | +import java.util.Collections; |
| 26 | +import java.util.Set; |
| 27 | + |
| 28 | +/** |
| 29 | + * <p>A construct that aggregates a two-part identifier of file formats and format contents transmitted on the Internet. |
| 30 | + * |
| 31 | + * <p>The two parts of a {@code ContentType} are its <em>type</em> and a <em>subtype</em>; separated by a forward slash ({@code /}). |
| 32 | + * |
| 33 | + * <p>The constants enumerated by {@code ContentType} correspond <em>only</em> to the specialized formats supported by the Java™ SDK for CloudEvents. |
| 34 | + * |
| 35 | + * @see io.cloudevents.core.format.EventFormat |
| 36 | + */ |
| 37 | +@ParametersAreNonnullByDefault |
| 38 | +public enum ContentType { |
| 39 | + |
| 40 | + /** |
| 41 | + * Content type associated with the JSON event format |
| 42 | + */ |
| 43 | + JSON("application/cloudevents+json"), |
| 44 | + /** |
| 45 | + * The content type for transports sending cloudevents in the protocol buffer format. |
| 46 | + */ |
| 47 | + PROTO("application/cloudevents+protobuf"), |
| 48 | + /** |
| 49 | + * The content type for transports sending cloudevents in XML format. |
| 50 | + */ |
| 51 | + XML("application/cloudevents+xml"); |
| 52 | + |
| 53 | + private String value; |
| 54 | + |
| 55 | + private ContentType(String value) { this.value = value; } |
| 56 | + |
| 57 | + /** |
| 58 | + * Return a string consisting of the slash-delimited ({@code /}) two-part identifier for this {@code enum} constant. |
| 59 | + */ |
| 60 | + public String value() { return value; } |
| 61 | + |
| 62 | + /** |
| 63 | + * Return a string consisting of the slash-delimited ({@code /}) two-part identifier for this {@code enum} constant. |
| 64 | + */ |
| 65 | + @Override |
| 66 | + public String toString() { return value(); } |
| 67 | + |
| 68 | +} |
0 commit comments