Skip to content

Commit

Permalink
Improved: Inline ‘UtilGenerics#checkSet’
Browse files Browse the repository at this point in the history
(OFBIZ-11141)


git-svn-id: https://svn.apache.org/repos/asf/ofbiz/ofbiz-framework/trunk@1863499 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mthl committed Jul 20, 2019
1 parent 2f12b17 commit 17da80d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 17 deletions.
Expand Up @@ -989,7 +989,7 @@ public static Map<String, Object> updatePageType(DispatchContext dctx, Map<Strin
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Map<String, Object> results = new HashMap<>();
Locale locale = (Locale) context.get("locale");
Set<String> visitedSet = UtilGenerics.checkSet(context.get("visitedSet"));
Set<String> visitedSet = UtilGenerics.cast(context.get("visitedSet"));
if (visitedSet == null) {
visitedSet = new HashSet<>();
context.put("visitedSet", visitedSet);
Expand Down Expand Up @@ -1029,7 +1029,7 @@ public static Map<String, Object> resetToOutlineMode(DispatchContext dctx, Map<S
Map<String, Object> context = UtilMisc.makeMapWritable(rcontext);
Map<String, Object> results = new HashMap<>();
Locale locale = (Locale) context.get("locale");
Set<String> visitedSet = UtilGenerics.checkSet(context.get("visitedSet"));
Set<String> visitedSet = UtilGenerics.cast(context.get("visitedSet"));
if (visitedSet == null) {
visitedSet = new HashSet<>();
context.put("visitedSet", visitedSet);
Expand Down Expand Up @@ -1103,7 +1103,7 @@ public static Map<String, Object> clearContentAssocDataResourceViewCache(Dispatc

public static void updatePageNodeChildren(GenericValue content, Map<String, Object> context) throws GenericEntityException {
String contentId = content.getString("contentId");
Set<String> visitedSet = UtilGenerics.checkSet(context.get("visitedSet"));
Set<String> visitedSet = UtilGenerics.cast(context.get("visitedSet"));
if (visitedSet == null) {
visitedSet = new HashSet<>();
context.put("visitedSet", visitedSet);
Expand All @@ -1126,7 +1126,7 @@ public static void updatePageNodeChildren(GenericValue content, Map<String, Obje

public static void updateOutlineNodeChildren(GenericValue content, boolean forceOutline, Map<String, Object> context) throws GenericEntityException {
String contentId = content.getString("contentId");
Set<String> visitedSet = UtilGenerics.checkSet(context.get("visitedSet"));
Set<String> visitedSet = UtilGenerics.cast(context.get("visitedSet"));
if (visitedSet == null) {
visitedSet = new HashSet<>();
context.put("visitedSet", visitedSet);
Expand Down Expand Up @@ -1520,7 +1520,7 @@ public static Map<String, Object> followNodeChildrenMethod(GenericValue content,
String contentId = content.getString("contentId");
List<String> contentAssocTypeIdList = UtilGenerics.checkList(context.get("contentAssocTypeIdList"));
Locale locale = (Locale) context.get("locale");
Set<String> visitedSet = UtilGenerics.checkSet(context.get("visitedSet"));
Set<String> visitedSet = UtilGenerics.cast(context.get("visitedSet"));
if (visitedSet == null) {
visitedSet = new HashSet<>();
context.put("visitedSet", visitedSet);
Expand Down
Expand Up @@ -180,7 +180,7 @@ public void clear() {

@Override
public Set<Object> keySet() {
return UtilGenerics.checkSet(mapKeySet);
return UtilGenerics.cast(mapKeySet);
}

@Override
Expand Down
Expand Up @@ -168,7 +168,7 @@ public static Map<String, Object> buildSurveyFromPdf(DispatchContext dctx, Map<S
PdfObject typeValue = null;
PdfObject tuValue = null;

Set<PdfName> dictKeys = UtilGenerics.checkSet(dict.getKeys());
Set<PdfName> dictKeys = UtilGenerics.cast(dict.getKeys());
for (PdfName dictKeyName : dictKeys) {
PdfObject dictObject = dict.get(dictKeyName);

Expand Down
Expand Up @@ -920,7 +920,7 @@ public static Map<String, Object> createOrder(DispatchContext ctx, Map<String, ?
}

// store the orderProductPromoCodes
Set<String> orderProductPromoCodes = UtilGenerics.checkSet(context.get("orderProductPromoCodes"));
Set<String> orderProductPromoCodes = UtilGenerics.cast(context.get("orderProductPromoCodes"));
if (UtilValidate.isNotEmpty(orderProductPromoCodes)) {
for (String productPromoCodeId : orderProductPromoCodes) {
GenericValue orderProductPromoCode = delegator.makeValue("OrderProductPromoCode");
Expand Down
Expand Up @@ -385,7 +385,7 @@ public static Map<String, Object> calcShipmentCostEstimate(DispatchContext dctx,
// add the feature quantities
BigDecimal quantity = (BigDecimal) itemMap.get("quantity");
if (itemMap.containsKey("featureSet")) {
Set<String> featureSet = UtilGenerics.checkSet(itemMap.get("featureSet"));
Set<String> featureSet = UtilGenerics.cast(itemMap.get("featureSet"));
if (UtilValidate.isNotEmpty(featureSet)) {
for (String featureId: featureSet) {
BigDecimal featureQuantity = shippableFeatureMap.get(featureId);
Expand Down
Expand Up @@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class UtilGenerics {

Expand Down Expand Up @@ -81,8 +80,4 @@ public static <K, V> Map<K, V> checkMap(Object object, Class<K> keyType, Class<V
}
return checkMap(object);
}

public static <T> Set<T> checkSet(Object object) {
return cast(object);
}
}
Expand Up @@ -389,7 +389,7 @@ public static <K, V> void addToListInMap(V element, Map<K, Object> theMap, K lis
}

public static <K, V> void addToSetInMap(V element, Map<K, Set<V>> theMap, K setKey) {
Set<V> theSet = UtilGenerics.checkSet(theMap.get(setKey));
Set<V> theSet = UtilGenerics.cast(theMap.get(setKey));
if (theSet == null) {
theSet = new LinkedHashSet<>();
theMap.put(setKey, theSet);
Expand All @@ -398,7 +398,7 @@ public static <K, V> void addToSetInMap(V element, Map<K, Set<V>> theMap, K setK
}

public static <K, V> void addToSortedSetInMap(V element, Map<K, Set<V>> theMap, K setKey) {
Set<V> theSet = UtilGenerics.checkSet(theMap.get(setKey));
Set<V> theSet = UtilGenerics.cast(theMap.get(setKey));
if (theSet == null) {
theSet = new TreeSet<>();
theMap.put(setKey, theSet);
Expand Down
Expand Up @@ -360,7 +360,7 @@ public static Map<String, Object> createEnvironmentMap(Environment env) {
Map<String, Object> templateRoot = new HashMap<>();
Set<String> varNames = null;
try {
varNames = UtilGenerics.checkSet(env.getKnownVariableNames());
varNames = UtilGenerics.cast(env.getKnownVariableNames());
} catch (TemplateModelException e1) {
Debug.logError(e1, "Error getting FreeMarker variable names, will not put pass current context on to sub-content", module);
}
Expand Down

0 comments on commit 17da80d

Please sign in to comment.