@Override public boolean equals(final Object other) { if (this == other) return true; if (!(other instanceof DefaultEdge)) return false; final DefaultEdge that = (DefaultEdge) other; return _from.equals(that._from) && _role.equals(that._role) && _to.equals(that._to); }
@Override public boolean equals(final Object other) { if (this == other) return true; if (!(other instanceof DefaultEdge)) return false; final DefaultEdge that = (DefaultEdge) other; return _from.equals(that._from) && _role.equals(that._role) && _to.equals(that._to); }
/** * {@inheritDoc} */ @Override public Node getNeighbor(final Node node) { if (_from.equals(node)) return _to; else if (_to.equals(node)) return _from; else return null; }
/** * {@inheritDoc} */ @Override public Node getNeighbor(final Node node) { if (_from.equals(node)) return _to; else if (_to.equals(node)) return _from; else return null; }
public Edge getExactEdge(final Individual from, final Role role, final Node to) { for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().equals(role)) && (to == null || to.equals(e.getTo()))) return e; return null; }
public Edge getExactEdge(final Individual from, final Role role, final Node to) { for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().equals(role)) && (to == null || to.equals(e.getTo()))) return e; return null; }
/** * Similar to {@link #hasEdge(Individual, Role, Node)} but does not consider subproperty hierarchy for matching so only exact predicate matches are * considered. * * @param from * @param role * @param to * @return true if contains an edge that match */ public boolean hasExactEdge(final Individual from, final Role role, final Node to) { for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().equals(role)) && (to == null || to.equals(e.getTo()))) return true; return false; }
/** * Similar to {@link #hasEdge(Individual, Role, Node)} but does not consider subproperty hierarchy for matching so only exact predicate matches are * considered. * * @param from * @param role * @param to * @return true if contains an edge that match */ public boolean hasExactEdge(final Individual from, final Role role, final Node to) { for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().equals(role)) && (to == null || to.equals(e.getTo()))) return true; return false; }
/** * Checks if this list contains an edge matching the given subject, predicate and object. A null parameter is treated as a wildcard matching every value and * predicates are matched by considering the subproperty hierarchy, i.e. passing the parameter <code>sup</code> to this function will return * <code>true</code> if an edge with subproperty <code>sub</code> exists. * * @param from * @param role * @param to * @return true if contains an edge that match */ public boolean hasEdge(final Individual from, final Role role, final Node to) { for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().isSubRoleOf(role)) && (to == null || to.equals(e.getTo()))) return true; return false; }
/** * Checks if this list contains an edge matching the given subject, predicate and object. A null parameter is treated as a wildcard matching every value and * predicates are matched by considering the subproperty hierarchy, i.e. passing the parameter <code>sup</code> to this function will return * <code>true</code> if an edge with subproperty <code>sub</code> exists. * * @param from * @param role * @param to * @return true if contains an edge that match */ public boolean hasEdge(final Individual from, final Role role, final Node to) { for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().isSubRoleOf(role)) && (to == null || to.equals(e.getTo()))) return true; return false; }
private EdgeList findEdges(final Role role, final Individual from, final Node to) { final EdgeList result = new EdgeList(); for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().isSubRoleOf(role)) && (to == null || to.equals(e.getTo()))) result.addEdge(e); return result; }
/** * Returns the roles that points to the given _individual from its parent. * * @param ind _individual to check * @return the roles that points to the given _individual from its parent */ public static Set<Role> getIncomingRoles(final Individual ind) { Set<Role> rolesToBlocked = null; for (final Edge e : ind.getInEdges()) if (e.getFrom().equals(ind.getParent())) if (rolesToBlocked == null) rolesToBlocked = e.getRole().getSuperRoles(); else if (!rolesToBlocked.contains(e.getRole())) { rolesToBlocked = SetUtils.create(rolesToBlocked); rolesToBlocked.addAll(e.getRole().getSuperRoles()); } return rolesToBlocked; }
/** * Returns the roles that points to the given _individual from its parent. * * @param ind _individual to check * @return the roles that points to the given _individual from its parent */ public static Set<Role> getIncomingRoles(final Individual ind) { Set<Role> rolesToBlocked = null; for (final Edge e : ind.getInEdges()) if (e.getFrom().equals(ind.getParent())) if (rolesToBlocked == null) rolesToBlocked = e.getRole().getSuperRoles(); else if (!rolesToBlocked.contains(e.getRole())) { rolesToBlocked = SetUtils.create(rolesToBlocked); rolesToBlocked.addAll(e.getRole().getSuperRoles()); } return rolesToBlocked; }
private EdgeList findEdges(final Role role, final Individual from, final Node to) { final EdgeList result = new EdgeList(); for (final Edge e : this) if ((from == null || from.equals(e.getFrom())) && (role == null || e.getRole().isSubRoleOf(role)) && (to == null || to.equals(e.getTo()))) result.addEdge(e); return result; }
protected Edge getParentEdge(final Individual ind) { Edge result = null; Role role = null; final Individual parent = ind.getParent(); for (final Edge e : ind.getInEdges()) if (e.getFrom().equals(parent)) if (role == null) { role = e.getRole(); result = e; } else if (e.getRole().isSubRoleOf(role)) { role = e.getRole(); result = e; } assert result != null; return result; }
protected Edge getParentEdge(final Individual ind) { Edge result = null; Role role = null; final Individual parent = ind.getParent(); for (final Edge e : ind.getInEdges()) if (e.getFrom().equals(parent)) if (role == null) { role = e.getRole(); result = e; } else if (e.getRole().isSubRoleOf(role)) { role = e.getRole(); result = e; } assert result != null; return result; }
protected boolean isDirectlyBlockedByDescendant(final BlockingContext cxt) { if (cxt._blocked.getParent().equals(cxt._blocker)) return false; if (!cxt._blocker.isRoot() && isDirectlyBlockedBy(cxt)) { cxt._blocked.setBlocked(true); _logger.finer(() -> cxt._blocked + " _blocked by " + cxt._blocker); return true; } final Individual blocker = cxt._blocker; for (final Edge e : blocker.getOutEdges()) { final Node child = e.getTo(); if (cxt.moveBlockerDown(child)) { if (isDirectlyBlockedByDescendant(cxt) || cxt._blocker.isRoot()) return true; cxt.moveBlockerUp(); } } return false; }
protected boolean isDirectlyBlockedByDescendant(final BlockingContext cxt) { if (cxt._blocked.getParent().equals(cxt._blocker)) return false; if (!cxt._blocker.isRoot() && isDirectlyBlockedBy(cxt)) { cxt._blocked.setBlocked(true); _logger.finer(() -> cxt._blocked + " _blocked by " + cxt._blocker); return true; } final Individual blocker = cxt._blocker; for (final Edge e : blocker.getOutEdges()) { final Node child = e.getTo(); if (cxt.moveBlockerDown(child)) { if (isDirectlyBlockedByDescendant(cxt) || cxt._blocker.isRoot()) return true; cxt.moveBlockerUp(); } } return false; }
public void checkReflexivitySymmetry(final Individual subj, final Role pred, final Individual obj, final DependencySet dsParam) { DependencySet ds = dsParam; if (pred.isAsymmetric() && obj.hasRSuccessor(pred, subj)) { final EdgeList edges = obj.getEdgesTo(subj, pred); ds = ds.union(edges.get(0).getDepends(), _abox.doExplanation()); if (OpenlletOptions.USE_TRACING) ds = ds.union(pred.getExplainAsymmetric(), _abox.doExplanation()); _abox.setClash(Clash.unexplained(subj, ds, "Antisymmetric property " + pred)); } else if (subj.equals(obj)) if (pred.isIrreflexive()) _abox.setClash(Clash.unexplained(subj, ds.union(pred.getExplainIrreflexive(), _abox.doExplanation()), "Irreflexive property " + pred)); else { final ATerm notSelfP = ATermUtils.makeNot(ATermUtils.makeSelf(pred.getName())); if (subj.hasType(notSelfP)) _abox.setClash(Clash.unexplained(subj, ds.union(subj.getDepends(notSelfP), _abox.doExplanation()), "Local irreflexive property " + pred)); } }
public void checkReflexivitySymmetry(final Individual subj, final Role pred, final Individual obj, final DependencySet dsParam) { DependencySet ds = dsParam; if (pred.isAsymmetric() && obj.hasRSuccessor(pred, subj)) { final EdgeList edges = obj.getEdgesTo(subj, pred); ds = ds.union(edges.get(0).getDepends(), _abox.doExplanation()); if (OpenlletOptions.USE_TRACING) ds = ds.union(pred.getExplainAsymmetric(), _abox.doExplanation()); _abox.setClash(Clash.unexplained(subj, ds, "Antisymmetric property " + pred)); } else if (subj.equals(obj)) if (pred.isIrreflexive()) _abox.setClash(Clash.unexplained(subj, ds.union(pred.getExplainIrreflexive(), _abox.doExplanation()), "Irreflexive property " + pred)); else { final ATerm notSelfP = ATermUtils.makeNot(ATermUtils.makeSelf(pred.getName())); if (subj.hasType(notSelfP)) _abox.setClash(Clash.unexplained(subj, ds.union(subj.getDepends(notSelfP), _abox.doExplanation()), "Local irreflexive property " + pred)); } }