|
| 1 | +/* |
| 2 | + * Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. |
| 3 | + * This product includes software developed at Datadog (https://www.datadoghq.com/). |
| 4 | + * Copyright 2019-Present Datadog, Inc. |
| 5 | + */ |
| 6 | + |
| 7 | +package com.datadog.api.client.v2.model; |
| 8 | + |
| 9 | +import com.datadog.api.client.ModelEnum; |
| 10 | +import com.fasterxml.jackson.annotation.JsonCreator; |
| 11 | +import com.fasterxml.jackson.core.JsonGenerator; |
| 12 | +import com.fasterxml.jackson.core.JsonProcessingException; |
| 13 | +import com.fasterxml.jackson.databind.SerializerProvider; |
| 14 | +import com.fasterxml.jackson.databind.annotation.JsonSerialize; |
| 15 | +import com.fasterxml.jackson.databind.ser.std.StdSerializer; |
| 16 | +import java.io.IOException; |
| 17 | +import java.util.Arrays; |
| 18 | +import java.util.HashSet; |
| 19 | +import java.util.Set; |
| 20 | + |
| 21 | +/** Resource type, always set to <code>dataset</code>. */ |
| 22 | +@JsonSerialize(using = DatasetType.DatasetTypeSerializer.class) |
| 23 | +public class DatasetType extends ModelEnum<String> { |
| 24 | + |
| 25 | + private static final Set<String> allowedValues = new HashSet<String>(Arrays.asList("dataset")); |
| 26 | + |
| 27 | + public static final DatasetType DATASET = new DatasetType("dataset"); |
| 28 | + |
| 29 | + DatasetType(String value) { |
| 30 | + super(value, allowedValues); |
| 31 | + } |
| 32 | + |
| 33 | + public static class DatasetTypeSerializer extends StdSerializer<DatasetType> { |
| 34 | + public DatasetTypeSerializer(Class<DatasetType> t) { |
| 35 | + super(t); |
| 36 | + } |
| 37 | + |
| 38 | + public DatasetTypeSerializer() { |
| 39 | + this(null); |
| 40 | + } |
| 41 | + |
| 42 | + @Override |
| 43 | + public void serialize(DatasetType value, JsonGenerator jgen, SerializerProvider provider) |
| 44 | + throws IOException, JsonProcessingException { |
| 45 | + jgen.writeObject(value.value); |
| 46 | + } |
| 47 | + } |
| 48 | + |
| 49 | + @JsonCreator |
| 50 | + public static DatasetType fromValue(String value) { |
| 51 | + return new DatasetType(value); |
| 52 | + } |
| 53 | +} |
0 commit comments