27
27
package gov .nist .secauto .metaschema .databind .io ;
28
28
29
29
import gov .nist .secauto .metaschema .core .util .CollectionUtil ;
30
- import gov .nist .secauto .metaschema .core .util .ObjectUtils ;
31
30
32
31
import java .util .Arrays ;
32
+ import java .util .HashSet ;
33
33
import java .util .List ;
34
34
import java .util .Locale ;
35
35
import java .util .Set ;
@@ -45,20 +45,22 @@ public enum Format {
45
45
/**
46
46
* The <a href="https://www.w3.org/XML/">Extensible Markup Language</a> format.
47
47
*/
48
- XML (Set . of ( ".xml" )),
48
+ XML (".xml" , Set . of ( )),
49
49
/**
50
50
* The <a href="https://www.json.org/">JavaScript Object Notation</a> format.
51
51
*/
52
- JSON (Set . of ( ".json" )),
52
+ JSON (".json" , Set . of ( )),
53
53
/**
54
54
* The <a href="https://yaml.org/">YAML Ain't Markup Language</a> format.
55
55
*/
56
- YAML (Set . of ( ".yml " , ".yaml " ));
56
+ YAML (".yaml " , Set . of ( ".yml " ));
57
57
58
58
private static final List <String > NAMES ;
59
59
60
60
@ NonNull
61
- private final Set <String > defaultExtensions ;
61
+ private final String defaultExtension ;
62
+ @ NonNull
63
+ private final Set <String > recognizedExtensions ;
62
64
63
65
static {
64
66
NAMES = Arrays .stream (values ())
@@ -76,8 +78,24 @@ public static List<String> names() {
76
78
return NAMES ;
77
79
}
78
80
79
- Format (Set <String > defaultExtensions ) {
80
- this .defaultExtensions = CollectionUtil .unmodifiableSet (ObjectUtils .requireNonNull (defaultExtensions ));
81
+ Format (@ NonNull String defaultExtension , Set <String > otherExtensions ) {
82
+ this .defaultExtension = defaultExtension ;
83
+
84
+ Set <String > recognizedExtensions = new HashSet <>();
85
+ recognizedExtensions .add (defaultExtension );
86
+ recognizedExtensions .addAll (otherExtensions );
87
+
88
+ this .recognizedExtensions = CollectionUtil .unmodifiableSet (recognizedExtensions );
89
+ }
90
+
91
+ /**
92
+ * Get the default extension to use for the format.
93
+ *
94
+ * @return the default extension
95
+ */
96
+ @ NonNull
97
+ public Set <String > getRecognizedExtensions () {
98
+ return recognizedExtensions ;
81
99
}
82
100
83
101
/**
@@ -86,7 +104,7 @@ public static List<String> names() {
86
104
* @return the default extension
87
105
*/
88
106
@ NonNull
89
- public Set < String > getDefaultExtension () {
90
- return defaultExtensions ;
107
+ public String getDefaultExtension () {
108
+ return defaultExtension ;
91
109
}
92
110
}
0 commit comments