|
1 |
| -/* |
2 |
| - * SPDX-License-Identifier: Apache-1.1 |
3 |
| - * |
4 |
| - * ==================================================================== |
5 |
| - * The Apache Software License, Version 1.1 |
6 |
| - * |
7 |
| - * Copyright (c) 1999-2003 The Apache Software Foundation. |
8 |
| - * Copyright (c) 2010 Dmitry Naumenko ([email protected]) |
9 |
| - * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils |
10 |
| - * All rights reserved. |
11 |
| - * |
12 |
| - * Redistribution and use in source and binary forms, with or without |
13 |
| - * modification, are permitted provided that the following conditions |
14 |
| - * are met: |
15 |
| - * |
16 |
| - * 1. Redistributions of source code must retain the above copyright |
17 |
| - * notice, this list of conditions and the following disclaimer. |
18 |
| - * |
19 |
| - * 2. Redistributions in binary form must reproduce the above copyright |
20 |
| - * notice, this list of conditions and the following disclaimer in |
21 |
| - * the documentation and/or other materials provided with the |
22 |
| - * distribution. |
23 |
| - * |
24 |
| - * 3. The end-user documentation included with the redistribution, if |
25 |
| - * any, must include the following acknowledgement: |
26 |
| - * "This product includes software developed by the |
27 |
| - * Apache Software Foundation (http://www.apache.org/)." |
28 |
| - * Alternately, this acknowledgement may appear in the software itself, |
29 |
| - * if and wherever such third-party acknowledgements normally appear. |
30 |
| - * |
31 |
| - * 4. The names "The Jakarta Project", "Commons", and "Apache Software |
32 |
| - * Foundation" must not be used to endorse or promote products derived |
33 |
| - * from this software without prior written permission. For written |
34 |
| - * permission, please contact [email protected]. |
35 |
| - * |
36 |
| - * 5. Products derived from this software may not be called "Apache" |
37 |
| - * nor may "Apache" appear in their names without prior written |
38 |
| - * permission of the Apache Software Foundation. |
39 |
| - * |
40 |
| - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
41 |
| - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
42 |
| - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
43 |
| - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR |
44 |
| - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
45 |
| - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
46 |
| - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
47 |
| - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
48 |
| - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
49 |
| - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
50 |
| - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
51 |
| - * SUCH DAMAGE. |
52 |
| - * ==================================================================== |
53 |
| - * |
54 |
| - * This software consists of voluntary contributions made by many |
55 |
| - * individuals on behalf of the Apache Software Foundation. For more |
56 |
| - * information on the Apache Software Foundation, please see |
57 |
| - * <http://www.apache.org/>. |
58 |
| - */ |
59 |
| - |
60 |
| -package difflib; |
61 |
| - |
62 |
| -import java.io.Serializable; |
63 |
| -import java.util.Comparator; |
64 |
| - |
65 |
| -/** |
66 |
| - * @author mksenzov |
67 |
| - * @param <?> The type of the compared elements in the 'lines'. |
68 |
| - */ |
69 |
| -public class DeltaComparator implements Comparator<Delta<?>>, Serializable { |
70 |
| - private static final long serialVersionUID = 1L; |
71 |
| - public static final Comparator<Delta<?>> INSTANCE = new DeltaComparator(); |
72 |
| - |
73 |
| - private DeltaComparator() { |
74 |
| - } |
75 |
| - |
76 |
| - public int compare(final Delta<?> a, final Delta<?> b) { |
77 |
| - final int posA = a.getOriginal().getPosition(); |
78 |
| - final int posB = b.getOriginal().getPosition(); |
79 |
| - if (posA > posB) { |
80 |
| - return 1; |
81 |
| - } else if (posA < posB) { |
82 |
| - return -1; |
83 |
| - } |
84 |
| - return 0; |
85 |
| - } |
86 |
| -} |
| 1 | +/* |
| 2 | + * SPDX-License-Identifier: Apache-1.1 |
| 3 | + * |
| 4 | + * ==================================================================== |
| 5 | + * The Apache Software License, Version 1.1 |
| 6 | + * |
| 7 | + * Copyright (c) 1999-2003 The Apache Software Foundation. |
| 8 | + * Copyright (c) 2010 Dmitry Naumenko ([email protected]) |
| 9 | + * Copyright (c) 2015-2016 Brenden Kromhout and contributors to java-diff-utils |
| 10 | + * All rights reserved. |
| 11 | + * |
| 12 | + * Redistribution and use in source and binary forms, with or without |
| 13 | + * modification, are permitted provided that the following conditions |
| 14 | + * are met: |
| 15 | + * |
| 16 | + * 1. Redistributions of source code must retain the above copyright |
| 17 | + * notice, this list of conditions and the following disclaimer. |
| 18 | + * |
| 19 | + * 2. Redistributions in binary form must reproduce the above copyright |
| 20 | + * notice, this list of conditions and the following disclaimer in |
| 21 | + * the documentation and/or other materials provided with the |
| 22 | + * distribution. |
| 23 | + * |
| 24 | + * 3. The end-user documentation included with the redistribution, if |
| 25 | + * any, must include the following acknowledgement: |
| 26 | + * "This product includes software developed by the |
| 27 | + * Apache Software Foundation (http://www.apache.org/)." |
| 28 | + * Alternately, this acknowledgement may appear in the software itself, |
| 29 | + * if and wherever such third-party acknowledgements normally appear. |
| 30 | + * |
| 31 | + * 4. The names "The Jakarta Project", "Commons", and "Apache Software |
| 32 | + * Foundation" must not be used to endorse or promote products derived |
| 33 | + * from this software without prior written permission. For written |
| 34 | + * permission, please contact [email protected]. |
| 35 | + * |
| 36 | + * 5. Products derived from this software may not be called "Apache" |
| 37 | + * nor may "Apache" appear in their names without prior written |
| 38 | + * permission of the Apache Software Foundation. |
| 39 | + * |
| 40 | + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED |
| 41 | + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 42 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 43 | + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR |
| 44 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 45 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 46 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF |
| 47 | + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 48 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 49 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 50 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 51 | + * SUCH DAMAGE. |
| 52 | + * ==================================================================== |
| 53 | + * |
| 54 | + * This software consists of voluntary contributions made by many |
| 55 | + * individuals on behalf of the Apache Software Foundation. For more |
| 56 | + * information on the Apache Software Foundation, please see |
| 57 | + * <http://www.apache.org/>. |
| 58 | + */ |
| 59 | + |
| 60 | +package difflib; |
| 61 | + |
| 62 | +import java.io.Serializable; |
| 63 | +import java.util.Comparator; |
| 64 | + |
| 65 | +/** |
| 66 | + * @author mksenzov |
| 67 | + * @param <?> The type of the compared elements in the 'lines'. |
| 68 | + */ |
| 69 | +public class DeltaComparator implements Comparator<Delta<?>>, Serializable { |
| 70 | + private static final long serialVersionUID = 1L; |
| 71 | + public static final Comparator<Delta<?>> INSTANCE = new DeltaComparator(); |
| 72 | + |
| 73 | + private DeltaComparator() { |
| 74 | + } |
| 75 | + |
| 76 | + public int compare(final Delta<?> a, final Delta<?> b) { |
| 77 | + final int posA = a.getOriginal().getPosition(); |
| 78 | + final int posB = b.getOriginal().getPosition(); |
| 79 | + if (posA > posB) { |
| 80 | + return 1; |
| 81 | + } else if (posA < posB) { |
| 82 | + return -1; |
| 83 | + } |
| 84 | + return 0; |
| 85 | + } |
| 86 | +} |
0 commit comments