-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pull request #255: RUM-9570 Events Spec 1.2
Merge in OP/openkit-java from feature/RUM-9570-openkit-java-update-json-serialization-of-special-numeric-values-for-events to main * commit 'd864e3bde1f733b565b2a7fe46b0713f4ff900e4': RUM-9570 Changing special pattern cases RUM-9570 Adding special pattern cases RUM-9570 Changing isFinite call RUM-9570 Removed unused import RUM-9570 Events Spec 1.2 GitOrigin-RevId: 65f5a02564a270fddc0c727d622e02e538b1af83
- Loading branch information
1 parent
ed2274a
commit 34f68c7
Showing
8 changed files
with
363 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
60 changes: 60 additions & 0 deletions
60
src/main/java/com/dynatrace/openkit/core/util/EventPayloadBuilderUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright 2018-2021 Dynatrace LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package com.dynatrace.openkit.core.util; | ||
|
||
import com.dynatrace.openkit.core.objects.EventPayloadBuilder; | ||
import com.dynatrace.openkit.util.json.objects.JSONArrayValue; | ||
import com.dynatrace.openkit.util.json.objects.JSONNumberValue; | ||
import com.dynatrace.openkit.util.json.objects.JSONObjectValue; | ||
import com.dynatrace.openkit.util.json.objects.JSONValue; | ||
|
||
import java.util.Iterator; | ||
|
||
public class EventPayloadBuilderUtil { | ||
|
||
private EventPayloadBuilderUtil() { | ||
} | ||
|
||
private static boolean isObjectContainingNonFiniteNumericValues(JSONObjectValue jsonObject) { | ||
for(String key: jsonObject.keySet()) { | ||
if(isItemContainingNonFiniteNumericValues(jsonObject.get(key))) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
private static boolean isArrayContainingNonFiniteNumericValues(JSONArrayValue jsonArrayValue) { | ||
Iterator<JSONValue> it = jsonArrayValue.iterator(); | ||
|
||
while(it.hasNext()) { | ||
if(isItemContainingNonFiniteNumericValues(it.next())) { | ||
return true; | ||
} | ||
} | ||
|
||
return false; | ||
} | ||
|
||
public static boolean isItemContainingNonFiniteNumericValues(JSONValue jsonValue) { | ||
return (jsonValue.isObject() && isObjectContainingNonFiniteNumericValues((JSONObjectValue) jsonValue)) | ||
|| (jsonValue.isArray() && isArrayContainingNonFiniteNumericValues((JSONArrayValue) jsonValue)) | ||
|| (jsonValue.isNumber() && !((JSONNumberValue) jsonValue).isFinite()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.