diff options
author | PawelSzalapski <pawel.szalapski@nokia.com> | 2018-06-21 12:12:30 +0200 |
---|---|---|
committer | PawelSzalapski <pawel.szalapski@nokia.com> | 2018-06-24 14:18:02 +0200 |
commit | 943a47187dbb1393d720b2fdf0019d48270edb4d (patch) | |
tree | fef76ed7b3034597853ab9735f5052cab2f0d6d5 /src/main/java/org/onap/dcae/commonFunction/AnyNode.java | |
parent | b4d5236a7164b166d49cf8c0a5c15bb848e04cd6 (diff) |
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 <pawel.szalapski@nokia.com>
Change-Id: I1a4ad0c896bd32165cba654344ffc5245648c615
Diffstat (limited to 'src/main/java/org/onap/dcae/commonFunction/AnyNode.java')
-rw-r--r-- | src/main/java/org/onap/dcae/commonFunction/AnyNode.java | 24 |
1 files changed, 9 insertions, 15 deletions
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<AnyNode> asStream() { + private Stream<AnyNode> 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(); } |