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 | package Torello.Browser.JsonAST;
import Torello.Java.ReadOnly.ReadOnlyList;
import Torello.Java.ReadOnly.ReadOnlyArrayList;
import Torello.Java.Additional.Ret4;
import Torello.JSON.ReadJSON;
import Torello.JSON.ReadBoxedJSON;
import Torello.JSON.RJArrIntoStream;
import Torello.JSON.JFlag;
import javax.json.JsonObject;
import javax.json.JsonArray;
/**
* Contains three helper functions, which help construct the nodes of an AST Tree.
* To see these features, make sure to click the "View Hilited Source" button, and review the
* code for this class.
*/
@Torello.JavaDoc.Annotations.StaticFunctional
@Torello.JavaDoc.Annotations.JDHeaderBackgroundImg(EmbedTagFileID="CONSTRUCTOR_JDHBI")
public class Helper$Misc
{
private Helper$Misc() { }
static ReadOnlyList<PropName> getPropNames(final JsonObject jo)
{
// The complete list of Json-Properties contained by this object (at the top level)
final java.util.Set<String> propNamesSet = jo.keySet();
return new ReadOnlyArrayList<>(
propNamesSet,
(String name) -> PropName.valueOf(name.toUpperCase()),
propNamesSet.size()
);
}
static
Ret4<String, Boolean, Boolean, Boolean>
getDescAndFlags
(final JsonObject jo)
{
// getString(JsonObject jo, String propertyName, boolean isOptional, boolean throwOnNull)
final String tempDescStr = ReadJSON.getString(jo, "description", true, true);
final String description = (tempDescStr == null) ? "-" : tempDescStr;
final int f = JFlag.RETURN_DEFVAL_ON_MISSING;
// getBoolean(JsonObject jo, String propertyName, int FLAGS, boolean defaultValue)
final boolean optional = ReadBoxedJSON.getBoolean(jo, "optional", f, false);
final boolean experimental = ReadBoxedJSON.getBoolean(jo, "experimental", f, false);
final boolean deprecated = ReadBoxedJSON.getBoolean(jo, "deprecated", f, false);
return new Ret4<>(description, optional, experimental, deprecated);
}
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
// Possible 'dependencies' String-Array (they are domain names)
// *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
//
// getJsonArray
// (JsonObject jo, String propertyName, boolean isOptional, boolean throwOnNull)
static ReadOnlyList<String> depAsStrs(final JsonObject jo)
{
final JsonArray depJsonArray =
ReadJSON.getJsonArray(jo, "dependencies", true, true);
return (depJsonArray == null)
? ReadOnlyArrayList.emptyROAL()
// strArr(JsonArray ja, String defaultValue, int FLAGS)
: RJArrIntoStream
.strArr(depJsonArray, null, 0)
.sorted(String::compareTo)
.collect(ReadOnlyArrayList.streamCollector());
}
}
|