/** * * * @param inout the map being changed in place - may be null * @param addition the mappings about to be added * @return the provided map or null if the merge was incompatible */ public static <X, Y> Map<X, Y> mergeInPlaceIfCompatible(Map<X, Y> inout, Map<X, Y> addition) { Map<X, Y> result = null; if(inout != null && addition != null) { boolean isCompatible = org.aksw.commons.collections.MapUtils.isPartiallyCompatible(inout, addition); if(isCompatible) { inout.putAll(addition); result = inout; } } return result; }
/** * * * @param base the map being changed in place - may be null * @param addition the mappings about to be added * @return the provided map or null if the merge was incompatible */ public static <X, Y> Map<X, Y> mergeIfCompatible(Map<X, Y> base, Map<X, Y> addition) { Map<X, Y> result = null; if(base != null && addition != null) { boolean isCompatible = org.aksw.commons.collections.MapUtils.isPartiallyCompatible(base, addition); if(isCompatible) { result = new HashMap<X, Y>(); result.putAll(base); result.putAll(addition); } } return result; }
public static Map<Var, Var> validate(Quad sourceQuad, Quad targetQuad, Map<Var, Var> partialSolution) { //boolean result = false; Map<Var, Var> result = Utils2.createVarMap(sourceQuad, targetQuad); if(result != null) { boolean isCompatible = MapUtils.isPartiallyCompatible(result, partialSolution); if(isCompatible) { result.putAll(partialSolution); } } return result; }
boolean isCompatible = MapUtils.isPartiallyCompatible(cand, result); if(!isCompatible) { result = null;