summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure
diff options
context:
space:
mode:
authorMichael Lando <ml636r@att.com>2018-07-29 16:13:45 +0300
committerMichael Lando <ml636r@att.com>2018-07-29 16:20:34 +0300
commit5b593496b8f1b8e8be8d7d2dbcc223332e65a49b (patch)
tree2f9dfc45191e723da69cf74be7829784e9741b94 /common-app-api/src/main/java/org/openecomp/sdc/common/datastructure
parent9200382f2ce7b4bb729aa287d0878004b2d2b4f9 (diff)
re base code
Change-Id: I12a5ca14a6d8a87e9316b9ff362eb131105f98a5 Issue-ID: SDC-1566 Signed-off-by: Michael Lando <ml636r@att.com>
Diffstat (limited to 'common-app-api/src/main/java/org/openecomp/sdc/common/datastructure')
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java (renamed from common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java)4
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java21
-rw-r--r--common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java41
3 files changed, 26 insertions, 40 deletions
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java
index 0dd15073da..06b2452d82 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKeysEnum.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/AuditingFieldsKey.java
@@ -22,7 +22,7 @@ package org.openecomp.sdc.common.datastructure;
import java.util.Date;
-public enum AuditingFieldsKeysEnum {
+public enum AuditingFieldsKey {
// General
AUDIT_TIMESTAMP(Date.class, "TIMESTAMP"),
AUDIT_ACTION(String.class, "ACTION"),
@@ -95,7 +95,7 @@ public enum AuditingFieldsKeysEnum {
private Class<?> clazz;
private String displayName;
- AuditingFieldsKeysEnum(Class<?> clazz, String displayName) {
+ AuditingFieldsKey(Class<?> clazz, String displayName) {
this.clazz = clazz;
this.displayName = displayName;
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java
index 55b9f7f87f..d31f8227dc 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEvent.java
@@ -20,18 +20,12 @@
package org.openecomp.sdc.common.datastructure;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Formatter;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
import org.codehaus.jettison.json.JSONException;
import org.codehaus.jettison.json.JSONObject;
+import java.text.SimpleDateFormat;
+import java.util.*;
+
/**
* Extending this class enforces the objects of implementing classes to have a
* timestamp, so that like in logstash, we can derive the index name for those
@@ -42,15 +36,16 @@ import org.codehaus.jettison.json.JSONObject;
*/
public class ESTimeBasedEvent {
+ protected SimpleDateFormat simpleDateFormat;
protected static String dateFormatPattern = "yyyy-MM-dd HH:mm:ss.SSS z";
protected String timestamp;
- protected Map<String, Object> fields = new HashMap<String, Object>();
+ protected Map<String, Object> fields = new HashMap<>();
public ESTimeBasedEvent() {
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
+ simpleDateFormat = new SimpleDateFormat(dateFormatPattern);
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
this.timestamp = simpleDateFormat.format(new Date());
- fields.put(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp);
+ fields.put(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName(), this.timestamp);
}
@@ -64,7 +59,7 @@ public class ESTimeBasedEvent {
while (keys.hasNext()) {
String key = (String) keys.next();
event.fields.put(key, gsonObj.get(key));
- if (key.equals(AuditingFieldsKeysEnum.AUDIT_TIMESTAMP.getDisplayName())) {
+ if (key.equals(AuditingFieldsKey.AUDIT_TIMESTAMP.getDisplayName())) {
event.timestamp = (String) gsonObj.get(key);
}
}
diff --git a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java
index 64266f5985..3f6fb4c298 100644
--- a/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java
+++ b/common-app-api/src/main/java/org/openecomp/sdc/common/datastructure/FunctionalInterfaces.java
@@ -20,28 +20,21 @@
package org.openecomp.sdc.common.datastructure;
+import fj.F;
+import fj.data.Either;
+import org.apache.commons.lang3.math.NumberUtils;
+import org.openecomp.sdc.common.log.wrappers.Logger;
+
import java.io.Serializable;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
+import java.util.concurrent.*;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;
-import org.apache.commons.lang3.math.NumberUtils;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import fj.F;
-import fj.data.Either;
-
/**
* Class For Functional interfaces And Functional Methods
*
@@ -51,7 +44,7 @@ import fj.data.Either;
public class FunctionalInterfaces {
private static final int DEFAULT_REDO_INTERVAL_TIME_MS = 50;
private static final int DEFAULT_MAX_WAIT_TIME_MS = 10000;
- private static final Logger LOGGER = LoggerFactory.getLogger(FunctionalInterfaces.class);
+ private static final Logger LOGGER = Logger.getLogger(FunctionalInterfaces.class.getName());
/**
* This is an interface of a List that implements Serializable
@@ -183,8 +176,7 @@ public class FunctionalInterfaces {
*/
public static <R, E extends Exception> R swallowException(SupplierThrows<R, E> methodToRun) {
try {
- final R result = methodToRun.get();
- return result;
+ return methodToRun.get();
} catch (Exception e) {
throw new FunctionalAttException(e);
}
@@ -510,15 +502,14 @@ public class FunctionalInterfaces {
}
public static <T> F<T, Boolean> convertToFunction(Consumer<T> consumer) {
- F<T, Boolean> func = t -> {
- try {
- consumer.accept(t);
- return true;
- } catch (Exception e) {
- return false;
- }
- };
- return func;
+ return t -> {
+ try {
+ consumer.accept(t);
+ return true;
+ } catch (Exception e) {
+ return false;
+ }
+ };
}
}