Skip to content

Commit 9211c98

Browse files
authored
Simplify get(object, path) method in lodash plugin.
1 parent ac4e44e commit 9211c98

File tree

2 files changed

+4
-14
lines changed
  • lodash-plugin/src

2 files changed

+4
-14
lines changed

lodash-plugin/src/main/java/com/github/underscore/lodash/$.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,7 +1223,7 @@ public static List<String> stringToPath(final String string) {
12231223
}
12241224

12251225
@SuppressWarnings("unchecked")
1226-
public static <T> T baseGet(final Map<String, Object> object, final String path) {
1226+
private static <T> T baseGet(final Map<String, Object> object, final String path) {
12271227
final List<String> paths = stringToPath(path);
12281228
int index = 0;
12291229
final int length = paths.size();
@@ -1246,11 +1246,7 @@ public static <T> T baseGet(final Map<String, Object> object, final String path)
12461246
}
12471247

12481248
public static <T> T get(final Map<String, Object> object, final String path) {
1249-
if (object == null) {
1250-
return null;
1251-
}
1252-
final T result = baseGet(object, path);
1253-
return result;
1249+
return baseGet(object, path);
12541250
}
12551251

12561252
public static class JsonStringBuilder {

lodash-plugin/src/test/java/com/github/underscore/lodash/LodashTest.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -446,15 +446,9 @@ public void get() {
446446
@Test
447447
public void getNull() {
448448
assertNull($.<String>get((Map<String, Object>) null, "a[0].b.c"));
449-
}
450-
451-
@SuppressWarnings("unchecked")
452-
@Test
453-
public void baseGetNull() {
454-
assertNull($.<String>baseGet((Map<String, Object>) null, "a[0].b.c"));
455-
assertNull($.<String>baseGet(new LinkedHashMap<String, Object>() { {
449+
assertNull($.<String>get(new LinkedHashMap<String, Object>() { {
456450
put("b", LodashTest.class); } }, "a[0].b.c"));
457-
assertNull($.<String>baseGet(new LinkedHashMap<String, Object>() { {
451+
assertNull($.<String>get(new LinkedHashMap<String, Object>() { {
458452
put("a", LodashTest.class); } }, "a[0].b.c"));
459453
}
460454

0 commit comments

Comments
 (0)