-
Notifications
You must be signed in to change notification settings - Fork 9
/
AttributeType.java
84 lines (64 loc) · 2.07 KB
/
AttributeType.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package com.czertainly.api.model.common.attribute.v2;
import com.czertainly.api.model.common.enums.IPlatformEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.Arrays;
/**
* This class defines Attribute types.
*/
@Schema(enumAsRef = true)
public enum AttributeType implements IPlatformEnum {
DATA(Constants.DATA, "Data"),
GROUP(Constants.GROUP, "Group"),
INFO(Constants.INFO, "Info"),
META(Constants.META, "Metadata"),
CUSTOM(Constants.CUSTOM, "Custom");
private static final AttributeType[] VALUES;
static {
VALUES = values();
}
private final String code;
private final String label;
private final String description;
AttributeType(String code, String label) {
this(code, label,null);
}
AttributeType(String code, String label, String description) {
this.code = code;
this.label = label;
this.description = description;
}
@Override
@JsonValue
public String getCode() {
return this.code;
}
@Override
public String getLabel() {
return this.label;
}
@Override
public String getDescription() {
return this.description;
}
@JsonCreator
public static AttributeType fromCode(String code) {
return Arrays.stream(VALUES)
.filter(e -> e.code.equals(code))
.findFirst()
.orElseThrow(() -> new IllegalArgumentException(String.format("Unsupported attribute type %s.", code)));
}
private static class Constants {
/** Data Attributes **/
private static final String DATA = "data";
/** Group Attributes **/
private static final String GROUP = "group";
/** Info Attributes **/
private static final String INFO = "info";
/** Custom Attributes **/
private static final String CUSTOM = "custom";
/** Meta Data Attributes **/
private static final String META = "meta";
}
}