Further code review
Project: http://git-wip-us.apache.org/repos/asf/jena/repo Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/d4d7baf1 Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/d4d7baf1 Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/d4d7baf1 Branch: refs/heads/master Commit: d4d7baf1e546fab28a9099bfae80513848b2d3a0 Parents: 237d338 Author: ajs6f <[email protected]> Authored: Sun Oct 23 14:38:08 2016 -0400 Committer: ajs6f <[email protected]> Committed: Sun Oct 30 14:12:32 2016 -0400 ---------------------------------------------------------------------- .../sparql/engine/iterator/QueryIterTopN.java | 1 - .../jena/atlas/lib/ReverseComparator.java | 44 ---------- .../java/org/apache/jena/atlas/lib/TS_Lib.java | 1 - .../jena/atlas/lib/TestReverseComparator.java | 91 -------------------- .../querybuilder/handlers/SelectHandler.java | 2 +- 5 files changed, 1 insertion(+), 138 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/jena/blob/d4d7baf1/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIterTopN.java ---------------------------------------------------------------------- diff --git a/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIterTopN.java b/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIterTopN.java index 9abe980..137790d 100644 --- a/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIterTopN.java +++ b/jena-arq/src/main/java/org/apache/jena/sparql/engine/iterator/QueryIterTopN.java @@ -28,7 +28,6 @@ import java.util.PriorityQueue ; import org.apache.jena.atlas.iterator.Iter ; import org.apache.jena.atlas.iterator.IteratorDelayedInitialization ; -import org.apache.jena.atlas.lib.ReverseComparator ; import org.apache.jena.query.Query ; import org.apache.jena.query.QueryExecException ; import org.apache.jena.query.SortCondition ; http://git-wip-us.apache.org/repos/asf/jena/blob/d4d7baf1/jena-base/src/main/java/org/apache/jena/atlas/lib/ReverseComparator.java ---------------------------------------------------------------------- diff --git a/jena-base/src/main/java/org/apache/jena/atlas/lib/ReverseComparator.java b/jena-base/src/main/java/org/apache/jena/atlas/lib/ReverseComparator.java deleted file mode 100644 index 0dd6f8d..0000000 --- a/jena-base/src/main/java/org/apache/jena/atlas/lib/ReverseComparator.java +++ /dev/null @@ -1,44 +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.jena.atlas.lib; - -import java.util.Comparator ; - -/** - *Comparator that compares the other way round to its sub-comparator - * @param <T> - * - * @deprecated Prefer {@link Comparator#reversed()} - */ -@Deprecated -public class ReverseComparator<T> implements Comparator<T> -{ - private final Comparator<T> comparator ; - - public ReverseComparator(Comparator<T> comparator) - { - this.comparator = comparator ; - } - - @Override - public int compare(T o1, T o2) - { - return comparator.compare(o2, o1) ; - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/d4d7baf1/jena-base/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java ---------------------------------------------------------------------- diff --git a/jena-base/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java b/jena-base/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java index f0e0f3c..2dc8888 100644 --- a/jena-base/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java +++ b/jena-base/src/test/java/org/apache/jena/atlas/lib/TS_Lib.java @@ -44,7 +44,6 @@ import org.junit.runners.Suite ; , TestXMLLib.class , TestAlarmClock.class , TestRefLong.class - , TestReverseComparator.class , TestTrie.class , TestFilenameProcessing.class , TestNumberUtils.class http://git-wip-us.apache.org/repos/asf/jena/blob/d4d7baf1/jena-base/src/test/java/org/apache/jena/atlas/lib/TestReverseComparator.java ---------------------------------------------------------------------- diff --git a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestReverseComparator.java b/jena-base/src/test/java/org/apache/jena/atlas/lib/TestReverseComparator.java deleted file mode 100644 index 80b9c0d..0000000 --- a/jena-base/src/test/java/org/apache/jena/atlas/lib/TestReverseComparator.java +++ /dev/null @@ -1,91 +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.jena.atlas.lib; - - -import java.util.ArrayList ; -import java.util.Arrays ; -import java.util.Collections ; -import java.util.Comparator ; -import java.util.List ; - -import org.apache.jena.atlas.junit.BaseTest ; -import org.apache.jena.atlas.lib.ReverseComparator ; -import org.junit.Test ; - -public class TestReverseComparator extends BaseTest -{ - static Comparator<String> normal = new Comparator<String>() - { - @Override - public int compare(String o1, String o2) - { - return o1.compareTo(o2); - } - }; - - static Comparator<String> reverse = new ReverseComparator<>(normal); - - - static Comparator<String> maxMin = new Comparator<String>() - { - @Override - public int compare(String o1, String o2) - { - int value = o1.compareTo(o2); - if (value > 0) - return Integer.MAX_VALUE; - else if (value < 0) - return Integer.MIN_VALUE; - else - return 0; - } - }; - - static Comparator<String> reverseMaxMin = new ReverseComparator<>(maxMin); - - static List<String> items = Arrays.asList("a", "b", "c", "d"); - static List<String> itemsReverse = Arrays.asList("d", "c", "b", "a"); - - @Test public void reverse_01() - { - List<String> modified = new ArrayList<>(items); - Collections.sort(modified, reverse); - - test(itemsReverse, modified); - } - - @Test public void reverse_02() - { - List<String> modified = new ArrayList<>(items); - Collections.sort(modified, reverseMaxMin); - - test(itemsReverse, modified); - } - - private void test(List<?> expected, List<?> actual) - { - assertEquals(expected.size(), actual.size()); - - for (int i=0; i<expected.size(); i++) - { - assertEquals(expected.get(i), actual.get(i)) ; - } - } -} http://git-wip-us.apache.org/repos/asf/jena/blob/d4d7baf1/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java ---------------------------------------------------------------------- diff --git a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java index 4013096..a42f305 100644 --- a/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java +++ b/jena-extras/jena-querybuilder/src/main/java/org/apache/jena/arq/querybuilder/handlers/SelectHandler.java @@ -120,7 +120,7 @@ public class SelectHandler implements Handler { * @throws QueryParseException * on error */ - private static Expr parseExpr(String s) throws QueryParseException { + private Expr parseExpr(String s) throws QueryParseException { try { ARQParser parser = new ARQParser(new StringReader("SELECT " + s)); parser.setQuery(new Query());
