@Override public boolean equals(Object o) { if (this == o) { return true; } if (o instanceof Model) { Model model = (Model) o; return ModelUtil.equals(this, model); } return false; }
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if the first model is a subset of the second model. */ public static boolean isSubset(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { // Filter duplicates Set<Statement> set1 = new LinkedHashSet<Statement>(); Iterators.addAll(model1.iterator(), set1); Set<Statement> set2 = new LinkedHashSet<Statement>(); Iterators.addAll(model2.iterator(), set2); return isSubset(set1, set2); }
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if the first model is a subset of the second model. */ public static boolean isSubset(Set<? extends Statement> model1, Set<? extends Statement> model2) { // Compare the number of statements in both sets if (model1.size() > model2.size()) { return false; } return isSubsetInternal(model1, model2); }
Statement st1 = model1.get(idx); List<Statement> matchingStats = findMatchingStatements(st1, model2, bNodeMapping); result = matchModels(model1, model2, newBNodeMapping, idx + 1);
private static boolean isSubsetInternal(Set<? extends Statement> model1, Set<? extends Statement> model2) { // try to create a full blank node mapping return matchModels(model1, model2); }
private static List<Statement> findMatchingStatements(Statement st, Iterable<? extends Statement> model, Map<BNode, BNode> bNodeMapping) { List<Statement> result = new ArrayList<Statement>(); for (Statement modelSt : model) { if (statementsMatch(st, modelSt, bNodeMapping)) { // All components possibly match result.add(modelSt); } } return result; }
Statement st1 = model1.get(idx); List<Statement> matchingStats = findMatchingStatements(st1, model2, bNodeMapping); result = matchModels(model1, model2, newBNodeMapping, idx + 1);
private static boolean isSubsetInternal(Set<? extends Statement> model1, Set<? extends Statement> model2) { // try to create a full blank node mapping return matchModels(model1, model2); }
private static List<Statement> findMatchingStatements(Statement st, Iterable<? extends Statement> model, Map<BNode, BNode> bNodeMapping) { List<Statement> result = new ArrayList<Statement>(); for (Statement modelSt : model) { if (statementsMatch(st, modelSt, bNodeMapping)) { // All components possibly match result.add(modelSt); } } return result; }
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if they are equal. Models are equal if they contain the same * set of statements. Blank node IDs are not relevant for model equality, * they are mapped from one model to the other by using the attached * properties. */ public static boolean equals(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { // Filter duplicates Set<Statement> set1 = new LinkedHashSet<Statement>(); Iterators.addAll(model1.iterator(), set1); Set<Statement> set2 = new LinkedHashSet<Statement>(); Iterators.addAll(model2.iterator(), set2); return equals(set1, set2); }
Statement st1 = model1.get(idx); List<Statement> matchingStats = findMatchingStatements(st1, model2, bNodeMapping); result = matchModels(model1, model2, newBNodeMapping, idx + 1);
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if the first model is a subset of the second model. */ public static boolean isSubset(Set<? extends Statement> model1, Set<? extends Statement> model2) { // Compare the number of statements in both sets if (model1.size() > model2.size()) { return false; } return isSubsetInternal(model1, model2); }
private static boolean isSubsetInternal(Set<? extends Statement> model1, Set<? extends Statement> model2) { // try to create a full blank node mapping return matchModels(model1, model2); }
private static List<Statement> findMatchingStatements(Statement st, Iterable<? extends Statement> model, Map<BNode, BNode> bNodeMapping) { List<Statement> result = new ArrayList<Statement>(); for (Statement modelSt : model) { if (statementsMatch(st, modelSt, bNodeMapping)) { // All components possibly match result.add(modelSt); } } return result; }
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if the first model is a subset of the second model. */ public static boolean isSubset(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { // Filter duplicates Set<Statement> set1 = new LinkedHashSet<Statement>(); Iterators.addAll(model1.iterator(), set1); Set<Statement> set2 = new LinkedHashSet<Statement>(); Iterators.addAll(model2.iterator(), set2); return isSubset(set1, set2); }
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if they are equal. Models are equal if they contain the * same set of statements. Blank node IDs are not relevant for model * equality, they are mapped from one model to the other by using the * attached properties. */ public static boolean equals(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { // Filter duplicates Set<Statement> set1 = new LinkedHashSet<Statement>(); Iterators.addAll(model1.iterator(), set1); Set<Statement> set2 = new LinkedHashSet<Statement>(); Iterators.addAll(model2.iterator(), set2); return equals(set1, set2); }
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if they are equal. Models are equal if they contain the same * set of statements. Blank node IDs are not relevant for model equality, * they are mapped from one model to the other by using the attached * properties. */ public static boolean equals(Set<? extends Statement> model1, Set<? extends Statement> model2) { // Compare the number of statements in both sets if (model1.size() != model2.size()) { return false; } return isSubsetInternal(model1, model2); }
private static boolean matchModels(Set<? extends Statement> model1, Set<? extends Statement> model2) { // Compare statements without blank nodes first, save the rest for later List<Statement> model1BNodes = new ArrayList<Statement>(model1.size()); for (Statement st : model1) { if (st.getSubject() instanceof BNode || st.getObject() instanceof BNode) { model1BNodes.add(st); } else { if (!model2.contains(st)) { return false; } } } return matchModels(model1BNodes, model2, new HashMap<BNode, BNode>(), 0); }
/** * Compares two models, defined by two statement collections, and returns * <tt>true</tt> if the first model is a subset of the second model. */ public static boolean isSubset(Iterable<? extends Statement> model1, Iterable<? extends Statement> model2) { // Filter duplicates Set<Statement> set1 = new LinkedHashSet<Statement>(); Iterators.addAll(model1.iterator(), set1); Set<Statement> set2 = new LinkedHashSet<Statement>(); Iterators.addAll(model2.iterator(), set2); return isSubset(set1, set2); }
public static boolean equals(GraphResult result1, GraphResult result2) throws StoreException { Set<? extends Statement> graph1 = result1.asSet(); Set<? extends Statement> graph2 = result1.asSet(); return ModelUtil.equals(graph1, graph2); }