diff --git a/src/main/java/org/apache/commons/collections4/comparators/sequence/SequencesComparator.java b/src/main/java/org/apache/commons/collections4/comparators/sequence/SequencesComparator.java index 2fd6e1937..09da0c665 100644 --- a/src/main/java/org/apache/commons/collections4/comparators/sequence/SequencesComparator.java +++ b/src/main/java/org/apache/commons/collections4/comparators/sequence/SequencesComparator.java @@ -90,6 +90,25 @@ public class SequencesComparator { vUp = new int[size]; } + /** + * Get the {@link EditScript} object. + *

+ * It is guaranteed that the objects embedded in the {@link InsertCommand + * insert commands} come from the second sequence and that the objects + * embedded in either the {@link DeleteCommand delete commands} or + * {@link KeepCommand keep commands} come from the first sequence. This can + * be important if subclassing is used for some elements in the first + * sequence and the equals method is specialized. + * + * @return the edit script resulting from the comparison of the two + * sequences + */ + public EditScript getScript() { + final EditScript script = new EditScript(); + buildScript(0, sequence1.size(), 0, sequence2.size(), script); + return script; + } + /** * Build a snake. * @@ -250,22 +269,58 @@ public class SequencesComparator { } /** - * Get the {@link EditScript} object. - *

- * It is guaranteed that the objects embedded in the {@link InsertCommand - * insert commands} come from the second sequence and that the objects - * embedded in either the {@link DeleteCommand delete commands} or - * {@link KeepCommand keep commands} come from the first sequence. This can - * be important if subclassing is used for some elements in the first - * sequence and the equals method is specialized. - * - * @return the edit script resulting from the comparison of the two - * sequences + * This class is a simple placeholder to hold the end part of a path + * under construction in a {@link SequencesComparator SequencesComparator}. */ - public EditScript getScript() { - final EditScript script = new EditScript(); - buildScript(0, sequence1.size(), 0, sequence2.size(), script); - return script; - } + private static class Snake { + /** Start index. */ + private final int start; + + /** End index. */ + private final int end; + + /** Diagonal number. */ + private final int diag; + + /** + * Simple constructor. Creates a new instance of Snake with specified indices. + * + * @param start start index of the snake + * @param end end index of the snake + * @param diag diagonal number + */ + public Snake(final int start, final int end, final int diag) { + this.start = start; + this.end = end; + this.diag = diag; + } + + /** + * Get the start index of the snake. + * + * @return start index of the snake + */ + public int getStart() { + return start; + } + + /** + * Get the end index of the snake. + * + * @return end index of the snake + */ + public int getEnd() { + return end; + } + + /** + * Get the diagonal number of the snake. + * + * @return diagonal number of the snake + */ + public int getDiag() { + return diag; + } + } } diff --git a/src/main/java/org/apache/commons/collections4/comparators/sequence/Snake.java b/src/main/java/org/apache/commons/collections4/comparators/sequence/Snake.java deleted file mode 100644 index 2589a580d..000000000 --- a/src/main/java/org/apache/commons/collections4/comparators/sequence/Snake.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.apache.commons.collections4.comparators.sequence; - -/** - * This class is a simple placeholder to hold the end part of a path - * under construction in a {@link SequencesComparator SequencesComparator}. - *

- * A snake is an internal structure used in Eugene W. Myers algorithm - * ( - * An O(ND) Difference Algorithm and Its Variations). - * - * @since 4.0 - * @version $Id$ - */ -public class Snake { - - /** Start index. */ - private final int start; - - /** End index. */ - private final int end; - - /** Diagonal number. */ - private final int diag; - - /** - * Simple constructor. Creates a new instance of Snake with default indices. - */ - public Snake() { - start = -1; - end = -1; - diag = 0; - } - - /** - * Simple constructor. Creates a new instance of Snake with specified indices. - * - * @param start start index of the snake - * @param end end index of the snake - * @param diag diagonal number - */ - public Snake(final int start, final int end, final int diag) { - this.start = start; - this.end = end; - this.diag = diag; - } - - /** - * Get the start index of the snake. - * - * @return start index of the snake - */ - public int getStart() { - return start; - } - - /** - * Get the end index of the snake. - * - * @return end index of the snake - */ - public int getEnd() { - return end; - } - - /** - * Get the diagonal number of the snake. - * - * @return diagonal number of the snake - */ - public int getDiag() { - return diag; - } - -}