From 2c6ccbcd696b5a4bc6d6633dfb9b0b5a918b5f4f Mon Sep 17 00:00:00 2001 From: Arundathi Patil Date: Tue, 4 Sep 2018 12:30:25 +0530 Subject: DBMap.java: Fixed sonar issue Fixed sonar code-smells/issues across this file. Issue-ID: DMAAP-710 Change-Id: I49430760bd0752b6b2bad2431eeac9c41bf1cd54 Signed-off-by: Arundathi Patil --- .../java/org/onap/dmaap/dbcapi/database/DBMap.java | 28 +++++++++++----------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java b/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java index a9bf56e..6f63848 100644 --- a/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java +++ b/src/main/java/org/onap/dmaap/dbcapi/database/DBMap.java @@ -30,42 +30,42 @@ public class DBMap extends TableHandler implements Map { public DBMap(ConnectionFactory cf, Class cls, String tabname, String keyfield) throws Exception { super(cf, cls, tabname, keyfield); } - public void clear() throws UnsupportedOperationException { + public void clear() { throw new UnsupportedOperationException(); } - public boolean containsKey(Object key) throws DBException { + public boolean containsKey(Object key) { return(get(key) != null); } - public boolean containsValue(Object value) throws UnsupportedOperationException { + public boolean containsValue(Object value) { throw new UnsupportedOperationException(); } public boolean isEmpty() { return(false); } - public Set> entrySet() throws DBException { + public Set> entrySet() { return(list()); } - public Set keySet() throws DBException { - Set ret = new HashSet(); + public Set keySet() { + Set ret = new HashSet<>(); for (Map.Entry x: list()) { ret.add(x.getKey()); } return(ret); } - public void putAll(Map m) throws UnsupportedOperationException { + public void putAll(Map m) { throw new UnsupportedOperationException(); } public int size() { return(2); } - public Collection values() throws DBException { - Collection ret = new Vector(); + public Collection values() { + Collection ret = new Vector<>(); for (Map.Entry x: list()) { ret.add(x.getValue()); } return(ret); } - public C get(Object key) throws DBException { + public C get(Object key) { if (!(key instanceof String)) { return(null); } @@ -85,13 +85,13 @@ public class DBMap extends TableHandler implements Map { } }).protect(cf, (String)key)); } - public Set> list() throws DBException { + public Set> list() { return((new ConnWrapper>, Object>() { protected Set> run(Object junk) throws Exception { DBFieldHandler keyfield = fields[fields.length - 1]; ps = c.prepareStatement(liststmt); rs = ps.executeQuery(); - Set> ret = new HashSet>(); + Set> ret = new HashSet<>(); while (rs.next()) { C val = cls.newInstance(); for (DBFieldHandler f: fields) { @@ -104,7 +104,7 @@ public class DBMap extends TableHandler implements Map { } }).protect(cf, null)); } - public C put(String key, C val) throws DBException { + public C put(String key, C val) { try { fields[fields.length - 1].setKey(val, key); } catch (Exception e) { @@ -122,7 +122,7 @@ public class DBMap extends TableHandler implements Map { } }).protect(cf, val)); } - public C remove(Object key) throws DBException { + public C remove(Object key) { if (!(key instanceof String)) { return(null); } -- cgit 1.2.3-korg