Skip to content

Commit 2722eb9

Browse files
committed
revamping write method to improve code clearity
1 parent 58ff0ac commit 2722eb9

File tree

18 files changed

+59
-78
lines changed

18 files changed

+59
-78
lines changed

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/AvailabilityData.java

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -232,17 +232,12 @@ protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOExc
232232
{
233233
super.serializeContent(writer);
234234
writer.write("ver", ver);
235-
236-
writer.write("id", id, 64, true);
237-
238-
writer.write("name", name, 1024, true);
239-
235+
writer.writeRequired("id", id, 64);
236+
writer.writeRequired("name", name, 1024);
240237
writer.write("duration", duration);
241-
242238
writer.write("success", success);
243-
244-
writer.write("runLocation", runLocation, 1024, false);
245-
writer.write("message", message, 8192, false);
239+
writer.write("runLocation", runLocation, 1024);
240+
writer.write("message", message, 8192);
246241
writer.write("properties", properties);
247242
writer.write("measurements", measurements);
248243
}

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/Base.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,29 +43,29 @@ public class Base
4343
* Backing field for property BaseType.
4444
*/
4545
private String baseType;
46-
46+
4747
/**
4848
* Initializes a new instance of the Base class.
4949
*/
5050
public Base()
5151
{
5252
this.InitializeFields();
5353
}
54-
54+
5555
/**
5656
* Gets the BaseType property.
5757
*/
5858
public String getBaseType() {
5959
return this.baseType;
6060
}
61-
61+
6262
/**
6363
* Sets the BaseType property.
6464
*/
6565
public void setBaseType(String value) {
6666
this.baseType = value;
6767
}
68-
68+
6969

7070
/**
7171
* Serializes the beginning of this object to the passed in writer.
@@ -84,13 +84,13 @@ public void serialize(JsonTelemetryDataSerializer writer) throws IOException
8484
*/
8585
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
8686
{
87-
writer.write("baseType", baseType, 1000, false);
87+
writer.writeRequired("baseType", baseType, 1000);
8888
}
89-
89+
9090
/**
9191
* Optionally initializes fields for the current context.
9292
*/
9393
protected void InitializeFields() {
94-
94+
9595
}
9696
}

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/DataPoint.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,9 @@ public void serialize(JsonTelemetryDataSerializer writer) throws IOException
198198
*/
199199
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
200200
{
201-
writer.write("name", name, 1024, true);
202-
201+
writer.writeRequired("name", name, 1024);
203202
writer.write("kind", kind);
204203
writer.write("value", value);
205-
206204
writer.write("count", count);
207205
writer.write("min", min);
208206
writer.write("max", max);

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/Domain.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,10 @@
3232
import com.microsoft.applicationinsights.telemetry.Duration;
3333
import com.microsoft.applicationinsights.telemetry.JsonTelemetryDataSerializer;
3434
import com.google.common.base.Preconditions;
35-
import org.apache.http.annotation.Obsolete;
3635

3736
/**
3837
* Data contract class Domain.
3938
*/
40-
@Obsolete
4139
public class Domain
4240
implements JsonSerializable
4341
{

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/Envelope.java

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,13 @@ public void serialize(JsonTelemetryDataSerializer writer) throws IOException
221221
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
222222
{
223223
writer.write("ver", ver);
224-
writer.write("name", name, 1024, true);
225-
226-
writer.write("time", time, 64, true);
227-
228-
if (this.sampleRate > 0.0d)
229-
writer.write("sampleRate", sampleRate);
230-
writer.write("seq", seq, 64, false);
231-
writer.write("iKey", iKey, 40, false);
224+
writer.writeRequired("name", name, 1024);
225+
writer.writeRequired("time", time, 64);
226+
if (this.sampleRate > 0.0d) {
227+
writer.write("sampleRate", sampleRate);
228+
}
229+
writer.write("seq", seq, 64);
230+
writer.write("iKey", iKey, 40);
232231
writer.write("tags", tags);
233232
writer.write("data", data);
234233
}

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/EventData.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,7 @@ protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOExc
137137
{
138138
super.serializeContent(writer);
139139
writer.write("ver", ver);
140-
141-
writer.write("name", name, 512, true);
142-
140+
writer.writeRequired("name", name, 512);
143141
writer.write("properties", properties);
144142
writer.write("measurements", measurements);
145143
}

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/ExceptionData.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,9 @@ protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOExc
178178
{
179179
super.serializeContent(writer);
180180
writer.write("ver", ver);
181-
182181
writer.write("exceptions", exceptions);
183-
184182
writer.write("severityLevel", severityLevel);
185-
writer.write("problemId", problemId, 1024, false);
183+
writer.write("problemId", problemId, 1024);
186184
writer.write("properties", properties);
187185
writer.write("measurements", measurements);
188186
}

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/ExceptionDetails.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -203,12 +203,10 @@ protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOExc
203203
{
204204
writer.write("id", id);
205205
writer.write("outerId", outerId);
206-
writer.write("typeName", typeName, 1024, true);
207-
208-
writer.write("message", message, 32768, true);
209-
206+
writer.writeRequired("typeName", typeName, 1024);
207+
writer.writeRequired("message", message, 32768);
210208
writer.write("hasFullStack", hasFullStack);
211-
writer.write("stack", stack, 32768, false);
209+
writer.write("stack", stack, 32768);
212210
writer.write("parsedStack", parsedStack);
213211
}
214212

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/MessageData.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,7 @@ protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOExc
134134
{
135135
super.serializeContent(writer);
136136
writer.write("ver", ver);
137-
138-
writer.write("message", message, 32768, true);
139-
137+
writer.writeRequired("message", message, 32768);
140138
writer.write("severityLevel", severityLevel);
141139
writer.write("properties", properties);
142140
}

core/src/main/java/com/microsoft/applicationinsights/internal/schemav2/PageViewData.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ public void setDuration(Duration value) {
9292
protected void serializeContent(JsonTelemetryDataSerializer writer) throws IOException
9393
{
9494
super.serializeContent(writer);
95-
writer.write("url", url, 2048, false);
95+
writer.write("url", url, 2048);
9696
writer.write("duration", duration);
9797
}
9898

0 commit comments

Comments
 (0)