Skip to content
Permalink
Browse files

Improved: Inline ‘UtilGenerics#checkSet’

(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 17da80d72d3cf7bf7937bd60fc5a3c5b56168d00
@@ -989,7 +989,7 @@ public static void addRoleToUser(Delegator delegator, LocalDispatcher dispatcher
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);
@@ -1029,7 +1029,7 @@ public static void addRoleToUser(Delegator delegator, LocalDispatcher dispatcher
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);
@@ -1103,7 +1103,7 @@ public static void addRoleToUser(Delegator delegator, LocalDispatcher dispatcher

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);
@@ -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);
@@ -1520,7 +1520,7 @@ public static String updateTypeAndFile(GenericValue dataResource, Map<String, Ob
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);
@@ -180,7 +180,7 @@ public void clear() {

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

@Override
@@ -168,7 +168,7 @@
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);

@@ -920,7 +920,7 @@ private static boolean hasPermission(String orderTypeId, String partyId, Generic
}

// 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");
@@ -385,7 +385,7 @@ private static boolean applyQuantityBreak(Map<String, ? extends Object> context,
// 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);
@@ -21,7 +21,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;

public final class UtilGenerics {

@@ -81,8 +80,4 @@ private UtilGenerics() {}
}
return checkMap(object);
}

public static <T> Set<T> checkSet(Object object) {
return cast(object);
}
}
@@ -389,7 +389,7 @@ public static String collectionToString(Collection<? extends Object> values, Str
}

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);
@@ -398,7 +398,7 @@ public static String collectionToString(Collection<? extends Object> values, Str
}

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);
@@ -360,7 +360,7 @@ public static Object get(SimpleHash args, String key) {
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);
}

0 comments on commit 17da80d

Please sign in to comment.
You can’t perform that action at this time.