summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2021-03-22 15:33:06 +0000
committerChristophe Closset <christophe.closset@intl.att.com>2021-03-24 06:59:47 +0000
commitd378c37fbd1ecec7b43394926f1ca32a695e07de (patch)
tree5c8a085f8732f980d871d966ac49361644efa698 /openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api
parenta6ae7294ecd336d7e88f915710b08e2658eaee00 (diff)
Reformat openecomp-be
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Issue-ID: SDC-3449 Change-Id: I13e02322f8e00820cc5a1d85752caaeda9bf10d1
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/ErrorMessageCode.java4
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java17
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java41
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java12
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java45
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java155
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java13
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java91
8 files changed, 167 insertions, 211 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/ErrorMessageCode.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/ErrorMessageCode.java
index ac31bd4a1e..8fa2494fed 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/ErrorMessageCode.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/ErrorMessageCode.java
@@ -22,10 +22,10 @@ package org.openecomp.core.validation;
import java.util.Objects;
public final class ErrorMessageCode {
+
private final String messageCode;
public ErrorMessageCode(String messageCode) {
-
this.messageCode = messageCode;
}
@@ -46,9 +46,7 @@ public final class ErrorMessageCode {
if (o == null || getClass() != o.getClass()) {
return false;
}
-
ErrorMessageCode that = (ErrorMessageCode) o;
-
return Objects.equals(this.messageCode, that.messageCode);
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java
index 9f75a08051..0408f64447 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/api/ValidationManager.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,21 +17,18 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.validation.api;
-
-import org.openecomp.core.validation.types.GlobalValidationContext;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-
import java.util.List;
import java.util.Map;
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
public interface ValidationManager {
- Map<String, List<ErrorMessage>> validate();
+ Map<String, List<ErrorMessage>> validate();
- void addFile(String fileName, byte[] validationContent);
+ void addFile(String fileName, byte[] validationContent);
- void updateGlobalContext(GlobalValidationContext globalContext);
+ void updateGlobalContext(GlobalValidationContext globalContext);
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java
index e3ed721fdd..4c1ed2173e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/errors/ErrorMessagesFormatBuilder.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,32 +17,29 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.validation.errors;
-
import org.openecomp.core.validation.ErrorMessageCode;
public class ErrorMessagesFormatBuilder {
- private static final String MESSAGE_PATTERN = "[%s]: %s";
- public static String getErrorWithParameters(String error, Object... params) {
- return String.format(error, params);
- }
- /**
- * Formatted message with error code.
- *
- * @param messageCode error code.
- * @param errorMessage error message.
- * @param params parameters used in formatting message.
- * @return formatted message string.
- */
- public static String getErrorWithParameters(ErrorMessageCode messageCode,
- String errorMessage, String... params) {
- String message = getErrorWithParameters(errorMessage, params);
+ private static final String MESSAGE_PATTERN = "[%s]: %s";
- return ( null != messageCode && null != messageCode.getMessageCode() ) ?
- String.format(MESSAGE_PATTERN, messageCode.getMessageCode(), message) : message;
- }
+ public static String getErrorWithParameters(String error, Object... params) {
+ return String.format(error, params);
+ }
+ /**
+ * Formatted message with error code.
+ *
+ * @param messageCode error code.
+ * @param errorMessage error message.
+ * @param params parameters used in formatting message.
+ * @return formatted message string.
+ */
+ public static String getErrorWithParameters(ErrorMessageCode messageCode, String errorMessage, String... params) {
+ String message = getErrorWithParameters(errorMessage, params);
+ return (null != messageCode && null != messageCode.getMessageCode()) ? String.format(MESSAGE_PATTERN, messageCode.getMessageCode(), message)
+ : message;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java
index 36beab10cf..3aac95f733 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/factory/ValidationManagerFactory.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,17 +17,15 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.validation.factory;
import org.openecomp.core.factory.api.AbstractComponentFactory;
import org.openecomp.core.factory.api.AbstractFactory;
import org.openecomp.core.validation.api.ValidationManager;
-
public abstract class ValidationManagerFactory extends AbstractComponentFactory<ValidationManager> {
- public static ValidationManagerFactory getInstance() {
- return AbstractFactory.getInstance(ValidationManagerFactory.class);
- }
+ public static ValidationManagerFactory getInstance() {
+ return AbstractFactory.getInstance(ValidationManagerFactory.class);
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java
index 3bc760c805..9b8e53744c 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/FileValidationContext.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,38 +17,35 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.validation.types;
-
import java.io.ByteArrayInputStream;
import java.io.InputStream;
-
public class FileValidationContext {
- private String fileName;
- private MessageContainer messageContainer = new MessageContainer();
- private byte[] content;
- public FileValidationContext(String fileName, byte[] fileContent) {
- this.fileName = fileName;
- this.content = fileContent;
- }
+ private String fileName;
+ private MessageContainer messageContainer = new MessageContainer();
+ private byte[] content;
+ public FileValidationContext(String fileName, byte[] fileContent) {
+ this.fileName = fileName;
+ this.content = fileContent;
+ }
- MessageContainer getMessageContainer() {
- return this.messageContainer;
- }
+ MessageContainer getMessageContainer() {
+ return this.messageContainer;
+ }
- public InputStream getContent() {
- return new ByteArrayInputStream(content);
- }
+ public InputStream getContent() {
+ return new ByteArrayInputStream(content);
+ }
- public String getFileName() {
- return this.fileName;
- }
+ public String getFileName() {
+ return this.fileName;
+ }
- public boolean isEmpty() {
- return content == null || content.length == 0;
- }
+ public boolean isEmpty() {
+ return content == null || content.length == 0;
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
index 42ea681b1b..b5ebf11240 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/GlobalValidationContext.java
@@ -13,15 +13,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.openecomp.core.validation.types;
-import org.apache.commons.collections4.CollectionUtils;
-import org.openecomp.core.validation.ErrorMessageCode;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.logging.api.Logger;
-import org.openecomp.sdc.logging.api.LoggerFactory;
-
import java.io.InputStream;
import java.util.Collection;
import java.util.HashMap;
@@ -29,95 +22,89 @@ import java.util.Map;
import java.util.Optional;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
+import org.apache.commons.collections4.CollectionUtils;
+import org.openecomp.core.validation.ErrorMessageCode;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.logging.api.Logger;
+import org.openecomp.sdc.logging.api.LoggerFactory;
public class GlobalValidationContext {
- private static final Logger LOGGER = LoggerFactory.getLogger(GlobalValidationContext.class);
- private final Map<String, FileValidationContext> fileContextMap = new HashMap<>();
- private final Map<String, MessageContainer> messageContainerMap = new HashMap<>();
- private ErrorMessageCode messageCode;
+ private static final Logger LOGGER = LoggerFactory.getLogger(GlobalValidationContext.class);
+ private final Map<String, FileValidationContext> fileContextMap = new HashMap<>();
+ private final Map<String, MessageContainer> messageContainerMap = new HashMap<>();
+ private ErrorMessageCode messageCode;
- public ErrorMessageCode getMessageCode() {
- return messageCode;
- }
-
- public void setMessageCode(ErrorMessageCode messageCode) {
- this.messageCode = messageCode;
- }
-
-
- /**
- * Add message.
- *
- * @param fileName the file name
- * @param level the level
- * @param message the message
- */
- public void addMessage(String fileName, ErrorLevel level, String message) {
-
- LOGGER.debug("'{}' [{}] in file '{}' ", message, level, fileName);
-
- if (fileContextMap.containsKey(fileName)) {
- fileContextMap.get(fileName).getMessageContainer().getMessageBuilder()
- .setMessage(level.toString() + ": " + message).setLevel(level).create();
- } else {
- MessageContainer messageContainer;
- synchronized (this) {
- messageContainer = messageContainerMap.computeIfAbsent(fileName, k -> new MessageContainer());
- }
- messageContainer.getMessageBuilder().setMessage(level.toString() + ": " + message)
- .setLevel(level).create();
+ public ErrorMessageCode getMessageCode() {
+ return messageCode;
}
- }
- /**
- * Gets file content.
- *
- * @param fileName the file name
- * @return the file content
- */
- public Optional<InputStream> getFileContent(String fileName) {
- FileValidationContext fileContext = fileContextMap.get(fileName);
- if (fileContext == null || fileContext.isEmpty()) {
- return Optional.empty();
+ public void setMessageCode(ErrorMessageCode messageCode) {
+ this.messageCode = messageCode;
}
- return Optional.of(fileContext.getContent());
- }
- public void addFileContext(String fileName, byte[] fileContent) {
- fileContextMap.put(fileName, new FileValidationContext(fileName, fileContent));
- }
+ /**
+ * Add message.
+ *
+ * @param fileName the file name
+ * @param level the level
+ * @param message the message
+ */
+ public void addMessage(String fileName, ErrorLevel level, String message) {
+ LOGGER.debug("'{}' [{}] in file '{}' ", message, level, fileName);
+ if (fileContextMap.containsKey(fileName)) {
+ fileContextMap.get(fileName).getMessageContainer().getMessageBuilder().setMessage(level.toString() + ": " + message).setLevel(level)
+ .create();
+ } else {
+ MessageContainer messageContainer;
+ synchronized (this) {
+ messageContainer = messageContainerMap.computeIfAbsent(fileName, k -> new MessageContainer());
+ }
+ messageContainer.getMessageBuilder().setMessage(level.toString() + ": " + message).setLevel(level).create();
+ }
+ }
- /**
- * Gets context message containers.
- *
- * @return the context message containers
- */
- public Map<String, MessageContainer> getContextMessageContainers() {
+ /**
+ * Gets file content.
+ *
+ * @param fileName the file name
+ * @return the file content
+ */
+ public Optional<InputStream> getFileContent(String fileName) {
+ FileValidationContext fileContext = fileContextMap.get(fileName);
+ if (fileContext == null || fileContext.isEmpty()) {
+ return Optional.empty();
+ }
+ return Optional.of(fileContext.getContent());
+ }
- Map<String, MessageContainer> contextMessageContainer = new HashMap<>();
- fileContextMap.entrySet().stream().filter(entry -> CollectionUtils
- .isNotEmpty(entry.getValue().getMessageContainer().getErrorMessageList())).forEach(
- entry -> contextMessageContainer.put(
- entry.getKey(), entry.getValue()
- .getMessageContainer()));
- messageContainerMap.entrySet().stream()
- .filter(entry -> CollectionUtils.isNotEmpty(entry.getValue().getErrorMessageList()))
- .forEach(entry -> contextMessageContainer.put(entry.getKey(), entry.getValue()));
- return contextMessageContainer;
- }
+ public void addFileContext(String fileName, byte[] fileContent) {
+ fileContextMap.put(fileName, new FileValidationContext(fileName, fileContent));
+ }
- public Map<String, FileValidationContext> getFileContextMap() {
- return fileContextMap;
- }
+ /**
+ * Gets context message containers.
+ *
+ * @return the context message containers
+ */
+ public Map<String, MessageContainer> getContextMessageContainers() {
+ Map<String, MessageContainer> contextMessageContainer = new HashMap<>();
+ fileContextMap.entrySet().stream().filter(entry -> CollectionUtils.isNotEmpty(entry.getValue().getMessageContainer().getErrorMessageList()))
+ .forEach(entry -> contextMessageContainer.put(entry.getKey(), entry.getValue().getMessageContainer()));
+ messageContainerMap.entrySet().stream().filter(entry -> CollectionUtils.isNotEmpty(entry.getValue().getErrorMessageList()))
+ .forEach(entry -> contextMessageContainer.put(entry.getKey(), entry.getValue()));
+ return contextMessageContainer;
+ }
- public Collection<String> files(BiPredicate<String, GlobalValidationContext> func) {
- return fileContextMap.keySet().stream().filter(t -> func.test(t, this))
- .collect(Collectors.toList());
- }
+ public Map<String, FileValidationContext> getFileContextMap() {
+ return fileContextMap;
+ }
- public Collection<String> getFiles() {
- return this.getFileContextMap().keySet();
- }
+ public Collection<String> files(BiPredicate<String, GlobalValidationContext> func) {
+ return fileContextMap.keySet().stream().filter(t -> func.test(t, this)).collect(Collectors.toList());
+ }
+ public Collection<String> getFiles() {
+ return this.getFileContextMap().keySet();
+ }
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java
index eb57672315..bbe6247b76 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/types/MessageContainer.java
@@ -17,15 +17,13 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.validation.types;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
public class MessageContainer {
@@ -40,16 +38,13 @@ public class MessageContainer {
}
/**
- * Gets error message list by level.
- * Only this level, not this level and above
+ * Gets error message list by level. Only this level, not this level and above
*
* @param level the level
* @return the error message list by level
*/
public List<ErrorMessage> getErrorMessageListByLevel(ErrorLevel level) {
- return errorMessageList.stream()
- .filter(message -> message.getLevel().equals(level))
- .collect(Collectors.toList());
+ return errorMessageList.stream().filter(message -> message.getLevel().equals(level)).collect(Collectors.toList());
}
public class MessageBuilder {
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java
index aab83837b8..e5ee3f2e95 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-api/src/main/java/org/openecomp/core/validation/util/MessageContainerUtil.java
@@ -7,9 +7,9 @@
* 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.
@@ -17,69 +17,56 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-
package org.openecomp.core.validation.util;
-import org.openecomp.sdc.datatypes.error.ErrorLevel;
-import org.openecomp.sdc.datatypes.error.ErrorMessage;
-
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-
+import org.openecomp.sdc.datatypes.error.ErrorLevel;
+import org.openecomp.sdc.datatypes.error.ErrorMessage;
public class MessageContainerUtil {
- /**
- * Gets message by level.
- *
- * @param level the level
- * @param messages the messages
- * @return the message by level
- */
- public static Map<String, List<ErrorMessage>> getMessageByLevel(ErrorLevel level,
- Map<String, List<ErrorMessage>>
- messages) {
- if (messages == null) {
- return null;
- }
- Map<String, List<ErrorMessage>> filteredMessages = new HashMap<>();
- messages.entrySet().forEach(
- entry -> entry.getValue().stream().filter(message -> message.getLevel().equals(level))
- .forEach(message -> addMessage(entry.getKey(), message, filteredMessages
- )));
- return filteredMessages;
- }
- private static void addMessage(String fileName, ErrorMessage message,
- Map<String, List<ErrorMessage>> messages) {
- List<ErrorMessage> messageList = messages.computeIfAbsent(fileName, k -> new ArrayList<>());
- messageList.add(message);
- }
+ /**
+ * Gets message by level.
+ *
+ * @param level the level
+ * @param messages the messages
+ * @return the message by level
+ */
+ public static Map<String, List<ErrorMessage>> getMessageByLevel(ErrorLevel level, Map<String, List<ErrorMessage>> messages) {
+ if (messages == null) {
+ return null;
+ }
+ Map<String, List<ErrorMessage>> filteredMessages = new HashMap<>();
+ messages.entrySet().forEach(entry -> entry.getValue().stream().filter(message -> message.getLevel().equals(level))
+ .forEach(message -> addMessage(entry.getKey(), message, filteredMessages)));
+ return filteredMessages;
+ }
- public static String getErrorMessagesListAsString(Map<String, List<ErrorMessage>> messages) {
- StringBuilder concatErrorMessage = new StringBuilder();
+ private static void addMessage(String fileName, ErrorMessage message, Map<String, List<ErrorMessage>> messages) {
+ List<ErrorMessage> messageList = messages.computeIfAbsent(fileName, k -> new ArrayList<>());
+ messageList.add(message);
+ }
- for (Map.Entry<String, List<ErrorMessage>> errorMessageEntry : messages.entrySet()) {
- appendErrorMessageAsString(concatErrorMessage, errorMessageEntry.getKey(),
- errorMessageEntry.getValue());
+ public static String getErrorMessagesListAsString(Map<String, List<ErrorMessage>> messages) {
+ StringBuilder concatErrorMessage = new StringBuilder();
+ for (Map.Entry<String, List<ErrorMessage>> errorMessageEntry : messages.entrySet()) {
+ appendErrorMessageAsString(concatErrorMessage, errorMessageEntry.getKey(), errorMessageEntry.getValue());
+ }
+ return concatErrorMessage.toString();
}
- return concatErrorMessage.toString();
- }
- private static void appendErrorMessageAsString(StringBuilder concatErrorMessage,
- String fileName,
- List<ErrorMessage> errorMessageList) {
- for (ErrorMessage errorMessage : errorMessageList) {
- addErrorMessage(concatErrorMessage, fileName, errorMessage);
+ private static void appendErrorMessageAsString(StringBuilder concatErrorMessage, String fileName, List<ErrorMessage> errorMessageList) {
+ for (ErrorMessage errorMessage : errorMessageList) {
+ addErrorMessage(concatErrorMessage, fileName, errorMessage);
+ }
}
- }
- private static void addErrorMessage(StringBuilder concatErrorMessage,
- String fileName,
- ErrorMessage errorMessage) {
- concatErrorMessage.append(fileName).append(" : ");
- concatErrorMessage.append(errorMessage.getMessage());
- concatErrorMessage.append("\n");
- }
+ private static void addErrorMessage(StringBuilder concatErrorMessage, String fileName, ErrorMessage errorMessage) {
+ concatErrorMessage.append(fileName).append(" : ");
+ concatErrorMessage.append(errorMessage.getMessage());
+ concatErrorMessage.append("\n");
+ }
}