From 943a47187dbb1393d720b2fdf0019d48270edb4d Mon Sep 17 00:00:00 2001 From: PawelSzalapski Date: Thu, 21 Jun 2018 12:12:30 +0200 Subject: Remove dead code from VESCollector Many things there are unused or have inproper modifiers, spelling etc. I run static analysis tool (Intellij code inspect) and clear those things up. It will be easier to maintain now. No actual behavior changes were done. Issue-ID: DCAEGEN2-526 Signed-off-by: PawelSzalapski Change-Id: I1a4ad0c896bd32165cba654344ffc5245648c615 --- .../java/org/onap/dcae/commonFunction/AnyNode.java | 24 ++++++++-------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/main/java/org/onap/dcae/commonFunction/AnyNode.java') diff --git a/src/main/java/org/onap/dcae/commonFunction/AnyNode.java b/src/main/java/org/onap/dcae/commonFunction/AnyNode.java index b09a17a0..267c87a9 100644 --- a/src/main/java/org/onap/dcae/commonFunction/AnyNode.java +++ b/src/main/java/org/onap/dcae/commonFunction/AnyNode.java @@ -45,27 +45,21 @@ import java.util.stream.StreamSupport; * @author koblosz */ public class AnyNode { - private static final Logger LOGGER = LoggerFactory.getLogger(AnyNode.class); - private Object obj; + private final Object obj; + private static final Logger log = LoggerFactory.getLogger(AnyNode.class); - /** - * @param filePath - * @return - * @throws IOException - */ public static AnyNode parse(String filePath) throws IOException { try (FileReader fr = new FileReader(filePath)) { - JSONTokener tokener = new JSONTokener(fr); - return new AnyNode(new JSONObject(tokener)); + return new AnyNode(new JSONObject(new JSONTokener(fr))); } catch (FileNotFoundException | JSONException e1) { - LOGGER.error("Could not find or parse file under path %s due to: %s", filePath, e1.toString()); + log.error("Could not find or parse file under path %s due to: %s", filePath, e1.toString()); e1.printStackTrace(); throw e1; } } /** - * Returns keyset of underlying object. It is assumed that underlying object is of type org.json.JSONObject. + * Returns key set of underlying object. It is assumed that underlying object is of type org.json.JSONObject. * * @return Set of string keys present in underlying JSONObject */ @@ -131,12 +125,12 @@ public class AnyNode { AnyNode result = null; try { result = get(key); - } catch (JSONException ex) { + } catch (JSONException ignored) { } return Optional.ofNullable(result); } - public JSONObject asJsonObject() { + private JSONObject asJsonObject() { return (JSONObject) this.obj; } @@ -159,14 +153,14 @@ public class AnyNode { /** * Converts this object to stream of underlying objects wrapped with AnyNode class. It is assumed that this is of type JSONArray. */ - public Stream asStream() { + private Stream asStream() { return StreamSupport.stream(((JSONArray) this.obj).spliterator(), false).map(AnyNode::new); } /** * Checks if specified key is present in this. It is assumed that this is of type JSONObject. */ - public boolean hasKey(String key) { + boolean hasKey(String key) { return getAsOptional(key).isPresent(); } -- cgit 1.2.3-korg