/
GsonTokenScanner_DynamicEndImpl.java
137 lines (117 loc) · 4.57 KB
/
GsonTokenScanner_DynamicEndImpl.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*******************************************************************************
* Copyright (c) 2022 BestSolution.at and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v.2.0 which is available at
* https://www.eclipse.org/legal/epl-2.0.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* BestSolution.at - initial API and implementation
*******************************************************************************/
package org.eclipse.fx.code.editor.configuration.gson;
import org.eclipse.fx.code.editor.configuration.*;
import com.google.gson.JsonObject;
public final class GsonTokenScanner_DynamicEndImpl implements GsonBase, TokenScanner_DynamicEnd, TokenScanner {
public GsonTokenScanner_DynamicEndImpl(JsonObject jsonObject) {
this.beginMatch = jsonObject.has("beginMatch") ? jsonObject.get("beginMatch").getAsString() : null;
this.beginPrefix = jsonObject.has("beginPrefix") ? jsonObject.get("beginPrefix").getAsString() : null;
this.check = jsonObject.has("check") ? GsonElementFactory.createCheck(jsonObject.getAsJsonObject("check")) : null;
this.condition = jsonObject.has("condition") ? GsonElementFactory.createCondition(jsonObject.getAsJsonObject("condition")) : null;
this.endTemplate = jsonObject.has("endTemplate") ? jsonObject.get("endTemplate").getAsString() : null;
this.singleLine = jsonObject.has("singleLine") ? jsonObject.get("singleLine").getAsBoolean() : false;
}
public GsonTokenScanner_DynamicEndImpl(String beginMatch, String beginPrefix, Check check, Condition condition, String endTemplate, boolean singleLine) {
this.beginMatch = beginMatch;
this.beginPrefix = beginPrefix;
this.check = check;
this.condition = condition;
this.endTemplate = endTemplate;
this.singleLine = singleLine;
}
public JsonObject toJSONObject() {
JsonObject o = new JsonObject();
o.addProperty( "$gtype", "TokenScanner_DynamicEnd" );
o.addProperty( "beginMatch", getBeginMatch() );
o.addProperty( "beginPrefix", getBeginPrefix() );
o.add( "check", getCheck() == null ? null : ((GsonBase)getCheck()).toJSONObject() );
o.add( "condition", getCondition() == null ? null : ((GsonBase)getCondition()).toJSONObject() );
o.addProperty( "endTemplate", getEndTemplate() );
o.addProperty( "singleLine", isSingleLine() );
return o;
}
public String toString() {
return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()) + " { "
+ "beginMatch : " + beginMatch + ", "
+ "beginPrefix : " + beginPrefix + ", "
+ "check : " + (check == null ? null : check.getClass().getSimpleName() + "@" + Integer.toHexString(check.hashCode())) + ", "
+ "condition : " + (condition == null ? null : condition.getClass().getSimpleName() + "@" + Integer.toHexString(condition.hashCode())) + ", "
+ "endTemplate : " + endTemplate + ", "
+ "singleLine : " + singleLine
+" }";
}
private final String beginMatch;
public String getBeginMatch() {
return this.beginMatch;
}
private final String beginPrefix;
public String getBeginPrefix() {
return this.beginPrefix;
}
private final Check check;
public Check getCheck() {
return this.check;
}
private final Condition condition;
public Condition getCondition() {
return this.condition;
}
private final String endTemplate;
public String getEndTemplate() {
return this.endTemplate;
}
private final boolean singleLine;
public boolean isSingleLine() {
return this.singleLine;
}
public static class Builder implements TokenScanner_DynamicEnd.Builder {
private final EditorGModel instance;
public Builder(EditorGModel instance) {
this.instance = instance;
}
private String beginMatch;
public Builder beginMatch(String beginMatch) {
this.beginMatch = beginMatch;
return this;
}
private String beginPrefix;
public Builder beginPrefix(String beginPrefix) {
this.beginPrefix = beginPrefix;
return this;
}
private Check check;
public Builder check(Check check) {
this.check = check;
return this;
}
private Condition condition;
public Builder condition(Condition condition) {
this.condition = condition;
return this;
}
private String endTemplate;
public Builder endTemplate(String endTemplate) {
this.endTemplate = endTemplate;
return this;
}
private boolean singleLine;
public Builder singleLine(boolean singleLine) {
this.singleLine = singleLine;
return this;
}
public TokenScanner_DynamicEnd build() {
return new GsonTokenScanner_DynamicEndImpl(beginMatch, beginPrefix, check, condition, endTemplate, singleLine);
}
}
}