Skip to content

Commit 0a465fa

Browse files
committed
Improved: Rewrite ‘EntityDataLoadContainer#isPropertySet’
(OFBIZ-11070) Use a boolean expression instead of a conditional. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1860836 13f79535-47bb-0310-9956-ffa450edef68
1 parent 7cd1a2b commit 0a465fa

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

framework/entityext/src/main/java/org/apache/ofbiz/entityext/data/EntityDataLoadContainer.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -191,22 +191,16 @@ private void loadDataForDelegator(Map<String, String> loadDataProps, Configurati
191191
}
192192
}
193193

194-
/*
195-
* If the user passed a flag, then make sure to set it to true if it has no
196-
* value or its value is the string "true".
194+
/**
195+
* Checks if a key is associated with either the string {@code "true"} or {@code null}.
197196
*
198-
* key=true -> true
199-
* key -> true
200-
* key=false -> false
201-
* (no-key) -> false
197+
* @param props the map associating keys to values
198+
* @param key the key to look for in {@code props}
199+
* @return {@code true} if {@code key} is associated with {@code "true"} or {@code null} in {@code props}.
202200
*/
203-
private boolean isPropertySet(Map<String, String> props, String key) {
201+
private static boolean isPropertySet(Map<String, String> props, String key) {
204202
String value = props.get(key);
205-
if (props.containsKey(key) && (value == null || "true".equalsIgnoreCase(value))) {
206-
return true;
207-
} else {
208-
return false;
209-
}
203+
return props.containsKey(key) && (value == null || "true".equalsIgnoreCase(value));
210204
}
211205

212206
/*

0 commit comments

Comments
 (0)