@Override public boolean equals(Object obj) { if (!(obj instanceof MappingNode)) { return false; } MappingNode target = (MappingNode) obj; return this.compareTo(target) == 0; }
@Override public boolean equals(Object obj) { if (!(obj instanceof MappingNode)) { return false; } MappingNode target = (MappingNode) obj; return this.compareTo(target) == 0; }
/** * 检查整个树的状况,尽可能报告可能存在的问题 * * @param tree * @param parent * @param prefix */ private void check(MappingNode tree, MappingNode parent, String prefix) { MappingNode child = parent.getLeftMostChild(); MappingNode sibling = null; while (child != null) { if (sibling != null) { if (child.compareTo(sibling) == 0) { logger.error("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'; here is the mapping tree, " + "you can find the conflict in it:\n" + PrinteHelper.list(tree)); throw new IllegalArgumentException("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'"); } } check(tree, child, prefix + child.getMapping().getDefinition()); sibling = child; child = child.getSibling(); } } }
/** * 检查整个树的状况,尽可能报告可能存在的问题 * * @param tree * @param parent * @param prefix */ private void check(MappingNode tree, MappingNode parent, String prefix) { MappingNode child = parent.getLeftMostChild(); MappingNode sibling = null; while (child != null) { if (sibling != null) { if (child.compareTo(sibling) == 0) { logger.error("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'; here is the mapping tree, " + "you can find the conflict in it:\n" + PrinteHelper.list(tree)); throw new IllegalArgumentException("mapping conflicts: '" + child.getMapping().getDefinition() + "' conflicts with '" + sibling.getMapping().getDefinition() + "' in '" + prefix + "'"); } } check(tree, child, prefix + child.getMapping().getDefinition()); sibling = child; child = child.getSibling(); } } }