From 1656b02144446aeedebb3d1179e07ed99c01861c Mon Sep 17 00:00:00 2001 From: bculkin2442 Date: Mon, 10 Apr 2017 16:39:06 -0400 Subject: Warning resolution --- .../java/bjc/utils/ioutils/SimpleProperties.java | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java') diff --git a/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java b/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java index 531e8b8..f00f245 100644 --- a/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java +++ b/BJC-Utils2/src/main/java/bjc/utils/ioutils/SimpleProperties.java @@ -38,19 +38,19 @@ public class SimpleProperties implements Map { * Whether or not duplicate keys should be allowed. */ public void loadFrom(InputStream is, boolean allowDuplicates) { - try(Scanner scn = new Scanner(is)) { - while(scn.hasNextLine()) { + try (Scanner scn = new Scanner(is)) { + while (scn.hasNextLine()) { String ln = scn.nextLine().trim(); /* * Skip blank lines/comments */ - if(ln.equals("")) continue; - if(ln.startsWith("#")) continue; + if (ln.equals("")) continue; + if (ln.startsWith("#")) continue; int sepIdx = ln.indexOf(' '); - if(sepIdx == -1) { + if (sepIdx == -1) { String fmt = "Properties must be a name, a space, then the body.\n\tOffending line is '%s'"; String msg = String.format(fmt, ln); @@ -60,7 +60,7 @@ public class SimpleProperties implements Map { String name = ln.substring(0, sepIdx).trim(); String body = ln.substring(sepIdx).trim(); - if(!allowDuplicates && containsKey(name)) { + if (!allowDuplicates && containsKey(name)) { String msg = String.format("Duplicate key '%s'", name); throw new IllegalStateException(msg); @@ -77,7 +77,7 @@ public class SimpleProperties implements Map { public void outputProperties() { System.out.println("Read properties:"); - for(Entry entry : entrySet()) { + for (Entry entry : entrySet()) { System.out.printf("\t'%s'\t'%s'\n", entry.getKey(), entry.getValue()); } @@ -94,16 +94,19 @@ public class SimpleProperties implements Map { return props.isEmpty(); } + @SuppressWarnings("unlikely-arg-type") @Override public boolean containsKey(Object key) { return props.containsKey(key); } + @SuppressWarnings("unlikely-arg-type") @Override public boolean containsValue(Object value) { return props.containsValue(value); } + @SuppressWarnings("unlikely-arg-type") @Override public String get(Object key) { return props.get(key); @@ -114,6 +117,7 @@ public class SimpleProperties implements Map { return props.put(key, value); } + @SuppressWarnings("unlikely-arg-type") @Override public String remove(Object key) { return props.remove(key); @@ -153,4 +157,4 @@ public class SimpleProperties implements Map { public int hashCode() { return props.hashCode(); } -} +} \ No newline at end of file -- cgit v1.2.3