Skip to content

Commit 62a4845

Browse files
committed
Simplifying code
1 parent 676edf4 commit 62a4845

File tree

2 files changed

+65
-70
lines changed

2 files changed

+65
-70
lines changed

README.md

Lines changed: 56 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -14,61 +14,62 @@ The basic method for using this library is, that you create a definition for you
1414
## Table of contents
1515

1616
<!-- TOC -->
17-
* [Installation](#installation)
18-
* [Maven](#maven)
19-
* [Running the Log Parser](#running-the-log-parser)
20-
* [Parse Definitions](#parse-definitions)
21-
* [Defining a Parsing](#defining-a-parsing)
22-
* [Defining an Entry](#defining-an-entry)
23-
* [How parsing works](#how-parsing-works)
24-
* [Anonymizing Data](#anonymizing-data)
25-
* [Code Example](#code-example)
26-
* [Import and Export of Parse Definitions](#import-and-export-of-parse-definitions)
27-
* [Importing a JSON File](#importing-a-json-file)
28-
* [Extracting Data from Logs](#extracting-data-from-logs)
29-
* [Using the Standard Method](#using-the-standard-method)
30-
* [Using the Log-Parser as an SDK](#using-the-log-parser-as-an-sdk)
31-
* [Writing your own SDK](#writing-your-own-sdk)
32-
* [Declaring a Default and Copy Constructor](#declaring-a-default-and-copy-constructor)
33-
* [Declaring the transformation Rules in setValuesFromMap](#declaring-the-transformation-rules-in-setvaluesfrommap)
34-
* [Declaring the Key](#declaring-the-key)
35-
* [Declare the HeaderMap, and ValueMap](#declare-the-headermap-and-valuemap)
36-
* [Assisting Exports](#assisting-exports)
37-
* [Code Structure](#code-structure)
38-
* [Searching and organizing log data](#searching-and-organizing-log-data)
39-
* [Search and Filter Mechanisms](#search-and-filter-mechanisms)
40-
* [Defining a Search Term](#defining-a-search-term)
41-
* [Enriching Log Data](#enriching-log-data)
42-
* [GroupBy Mechanisms](#groupby-mechanisms)
43-
* [Passing a list](#passing-a-list)
44-
* [Chaining GroupBy](#chaining-groupby)
45-
* [Comparing Log Data](#comparing-log-data)
46-
* [Creating a Differentiation Report](#creating-a-differentiation-report)
47-
* [Assertions and LogDataAssertions](#assertions-and-logdataassertions)
48-
* [Exporting Parse Results](#exporting-parse-results)
49-
* [Exporting Results to a CSV File](#exporting-results-to-a-csv-file)
50-
* [Exporting Results to an HTML File](#exporting-results-to-an-html-file)
51-
* [Exporting Results to an JSON File](#exporting-results-to-an-json-file)
52-
* [Command-line Execution of the Log-Parser](#command-line-execution-of-the-log-parser)
53-
* [Memory Guard Rails](#memory-guard-rails)
54-
* [Guard Rail Properties](#guard-rail-properties)
55-
* [File Entry Limitations](#file-entry-limitations)
56-
* [File Size Limitations](#file-size-limitations)
57-
* [Memory Limitations](#memory-limitations)
58-
* [Exporting Anomalies Report](#exporting-anomalies-report)
59-
* [Changelog](#changelog)
60-
* [1.11.3 (In-Progress)](#1113--in-progress-)
61-
* [1.11.2](#1112)
62-
* [1.11.0](#1110)
63-
* [1.0.10](#1010)
64-
* [1.0.8.2](#1082)
65-
* [1.0.8](#108)
66-
* [1.0.7](#107)
67-
* [1.0.6](#106)
68-
* [1.0.5](#105)
69-
* [1.0.4](#104)
70-
* [1.0.3](#103)
71-
* [1.0.1](#101)
17+
18+
- [Installation](#installation)
19+
- [Maven](#maven)
20+
- [Running the Log Parser](#running-the-log-parser)
21+
- [Parse Definitions](#parse-definitions)
22+
- [Defining a Parsing](#defining-a-parsing)
23+
- [Defining an Entry](#defining-an-entry)
24+
- [How parsing works](#how-parsing-works)
25+
- [Anonymizing Data](#anonymizing-data)
26+
- [Code Example](#code-example)
27+
- [Import and Export of Parse Definitions](#import-and-export-of-parse-definitions)
28+
- [Importing a JSON File](#importing-a-json-file)
29+
- [Extracting Data from Logs](#extracting-data-from-logs)
30+
- [Using the Standard Method](#using-the-standard-method)
31+
- [Using the Log-Parser as an SDK](#using-the-log-parser-as-an-sdk)
32+
- [Writing your own SDK](#writing-your-own-sdk)
33+
- [Declaring a Default and Copy Constructor](#declaring-a-default-and-copy-constructor)
34+
- [Declaring the transformation Rules in setValuesFromMap](#declaring-the-transformation-rules-in-setvaluesfrommap)
35+
- [Declaring the Key](#declaring-the-key)
36+
- [Declare the HeaderMap, and ValueMap](#declare-the-headermap-and-valuemap)
37+
- [Assisting Exports](#assisting-exports)
38+
- [Code Structure](#code-structure)
39+
- [Searching and organizing log data](#searching-and-organizing-log-data)
40+
- [Search and Filter Mechanisms](#search-and-filter-mechanisms)
41+
- [Defining a Search Term](#defining-a-search-term)
42+
- [Enriching Log Data](#enriching-log-data)
43+
- [GroupBy Mechanisms](#groupby-mechanisms)
44+
- [Passing a list](#passing-a-list)
45+
- [Chaining GroupBy](#chaining-groupby)
46+
- [Comparing Log Data](#comparing-log-data)
47+
- [Creating a Differentiation Report](#creating-a-differentiation-report)
48+
- [Assertions and LogDataAssertions](#assertions-and-logdataassertions)
49+
- [Exporting Parse Results](#exporting-parse-results)
50+
- [Exporting Results to a CSV File](#exporting-results-to-a-csv-file)
51+
- [Exporting Results to an HTML File](#exporting-results-to-an-html-file)
52+
- [Exporting Results to an JSON File](#exporting-results-to-an-json-file)
53+
- [Command-line Execution of the Log-Parser](#command-line-execution-of-the-log-parser)
54+
- [Memory Guard Rails](#memory-guard-rails)
55+
- [Guard Rail Properties](#guard-rail-properties)
56+
- [File Entry Limitations](#file-entry-limitations)
57+
- [File Size Limitations](#file-size-limitations)
58+
- [Memory Limitations](#memory-limitations)
59+
- [Exporting Anomalies Report](#exporting-anomalies-report)
60+
- [Changelog](#changelog)
61+
_ [1.11.3 (In-Progress)](#1113--in-progress-)
62+
_ [1.11.2](#1112)
63+
_ [1.11.0](#1110)
64+
_ [1.0.10](#1010)
65+
_ [1.0.8.2](#1082)
66+
_ [1.0.8](#108)
67+
_ [1.0.7](#107)
68+
_ [1.0.6](#106)
69+
_ [1.0.5](#105)
70+
_ [1.0.4](#104)
71+
_ [1.0.3](#103)
72+
_ [1.0.1](#101)
7273
<!-- TOC -->
7374

7475
## Installation

src/main/java/com/adobe/campaign/tests/logparser/utils/ParseGuardRails.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -173,21 +173,15 @@ private static boolean hasReachedFileSizeLimit(long length) {
173173
public static Map<String, Set<String>> getAnomalyReport() {
174174
Map<String, Set<String>> report = new HashMap<>();
175175

176-
if (heapLimitations.size() > 0) {
177-
report.put("heapLimitations", heapLimitations.keySet());
178-
}
179-
180-
if (memoryLimitations.size() > 0) {
181-
report.put("memoryLimitations", memoryLimitations.keySet());
182-
}
183-
184-
if (fileSizeLimitations.size() > 0) {
185-
report.put("fileSizeLimitations", fileSizeLimitations.keySet());
186-
}
187-
188-
if (entryLimitations.size() > 0) {
189-
report.put("entryLimitations", entryLimitations.keySet());
190-
}
176+
Map.of(
177+
"heapLimitations", heapLimitations,
178+
"memoryLimitations", memoryLimitations,
179+
"fileSizeLimitations", fileSizeLimitations,
180+
"entryLimitations", entryLimitations).forEach((key, map) -> {
181+
if (!map.isEmpty()) {
182+
report.put(key, map.keySet());
183+
}
184+
});
191185

192186
return report;
193187
}

0 commit comments

Comments
 (0)