From 4ed8be2512f5ebba156ca1ed42108a40f2d4f175 Mon Sep 17 00:00:00 2001 From: Davide Grohmann Date: Tue, 8 Dec 2015 17:33:26 +0100 Subject: [PATCH] Remove IntPredicates --- .../org/neo4j/function/IntPredicates.java | 53 ---------------- .../org/neo4j/tooling/ImportToolTest.java | 60 +++++++++---------- .../primitive/PrimitiveIntCollections.java | 1 - 3 files changed, 30 insertions(+), 84 deletions(-) delete mode 100644 community/function/src/main/java/org/neo4j/function/IntPredicates.java diff --git a/community/function/src/main/java/org/neo4j/function/IntPredicates.java b/community/function/src/main/java/org/neo4j/function/IntPredicates.java deleted file mode 100644 index 1210324a16378..0000000000000 --- a/community/function/src/main/java/org/neo4j/function/IntPredicates.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2002-2015 "Neo Technology," - * Network Engine for Objects in Lund AB [http://neotechnology.com] - * - * This file is part of Neo4j. - * - * Neo4j is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package org.neo4j.function; - -import java.util.function.IntPredicate; - -/** - * Constructors for basic {@link IntPredicate} types - * @deprecated This class relies on deprecated interfaces, and will be retrofitted to work with the {@code java.util.function} interfaces in 3.0. - */ -public final class IntPredicates -{ - private static final IntPredicate TRUE = value -> true; - - private static final IntPredicate FALSE = value -> false; - - /** - * A predicate that is always true - * - * @return true - */ - public static IntPredicate alwaysTrue() - { - return TRUE; - } - - /** - * A predicate that is always false - * - * @return false - */ - public static IntPredicate alwaysFalse() - { - return FALSE; - } -} diff --git a/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java b/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java index d7d50ef6af68d..894420dfb3677 100644 --- a/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java +++ b/community/import-tool/src/test/java/org/neo4j/tooling/ImportToolTest.java @@ -70,7 +70,6 @@ import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -import static org.neo4j.function.IntPredicates.alwaysTrue; import static org.neo4j.graphdb.Label.label; import static org.neo4j.graphdb.RelationshipType.withName; import static org.neo4j.helpers.ArrayUtil.join; @@ -88,6 +87,7 @@ public class ImportToolTest { private static final int RELATIONSHIP_COUNT = 10_000; private static final int NODE_COUNT = 100; + private static final IntPredicate TRUE = i -> true; @Rule public final EmbeddedDatabaseRule dbRule = new EmbeddedDatabaseRule( getClass() ).startLazily(); @@ -125,8 +125,8 @@ public void shouldImportWithAsManyDefaultsAsAvailable() throws Exception // WHEN importTool( "--into", dbRule.getStoreDirAbsolutePath(), - "--nodes", nodeData( true, config, nodeIds, alwaysTrue() ).getAbsolutePath(), - "--relationships", relationshipData( true, config, nodeIds, alwaysTrue(), true ).getAbsolutePath() ); + "--nodes", nodeData( true, config, nodeIds, TRUE ).getAbsolutePath(), + "--relationships", relationshipData( true, config, nodeIds, TRUE, true ).getAbsolutePath() ); // THEN verifyData(); @@ -146,10 +146,10 @@ public void shouldImportWithHeadersBeingInSeparateFiles() throws Exception "--array-delimiter", String.valueOf( config.arrayDelimiter() ), "--nodes", nodeHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - nodeData( false, config, nodeIds, alwaysTrue() ).getAbsolutePath(), + nodeData( false, config, nodeIds, TRUE ).getAbsolutePath(), "--relationships", relationshipHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - relationshipData( false, config, nodeIds, alwaysTrue(), true ).getAbsolutePath() ); + relationshipData( false, config, nodeIds, TRUE, true ).getAbsolutePath() ); // THEN verifyData(); @@ -171,10 +171,10 @@ public void shouldFailIfHeaderHasLessColumnsThanData() throws Exception "--delimiter", "TAB", "--array-delimiter", String.valueOf( config.arrayDelimiter() ), "--nodes", nodeHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - nodeData( false, config, nodeIds, alwaysTrue(), Charset.defaultCharset(), extraColumns ) + nodeData( false, config, nodeIds, TRUE, Charset.defaultCharset(), extraColumns ) .getAbsolutePath(), "--relationships", relationshipHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - relationshipData( false, config, nodeIds, alwaysTrue(), true ).getAbsolutePath() ); + relationshipData( false, config, nodeIds, TRUE, true ).getAbsolutePath() ); fail( "Should have thrown exception" ); } @@ -203,10 +203,10 @@ public void shouldWarnIfHeaderHasLessColumnsThanDataWhenToldTo() throws Exceptio "--delimiter", "TAB", "--array-delimiter", String.valueOf( config.arrayDelimiter() ), "--nodes", nodeHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - nodeData( false, config, nodeIds, alwaysTrue(), Charset.defaultCharset(), extraColumns ) + nodeData( false, config, nodeIds, TRUE, Charset.defaultCharset(), extraColumns ) .getAbsolutePath(), "--relationships", relationshipHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - relationshipData( false, config, nodeIds, alwaysTrue(), true ).getAbsolutePath() ); + relationshipData( false, config, nodeIds, TRUE, true ).getAbsolutePath() ); // THEN String badContents = FileUtils.readTextFile( bad, Charset.defaultCharset() ); @@ -275,7 +275,7 @@ public void shouldImportSplitInputFiles() throws Exception nodeData( false, config, nodeIds, lines( NODE_COUNT * 3 / 4, NODE_COUNT ) ).getAbsolutePath(), "--relationships", relationshipHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - relationshipData( false, config, nodeIds, alwaysTrue(), true ).getAbsolutePath() ); + relationshipData( false, config, nodeIds, TRUE, true ).getAbsolutePath() ); // THEN verifyData(); @@ -339,7 +339,7 @@ public void shouldImportOnlyNodes() throws Exception // WHEN importTool( "--into", dbRule.getStoreDirAbsolutePath(), - "--nodes", nodeData( true, config, nodeIds, alwaysTrue() ).getAbsolutePath() ); + "--nodes", nodeData( true, config, nodeIds, TRUE ).getAbsolutePath() ); // no relationships // THEN @@ -376,11 +376,11 @@ public void shouldImportGroupsOfOverlappingIds() throws Exception importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--nodes", nodeHeader( config, groupOne ) + MULTI_FILE_DELIMITER + - nodeData( false, config, groupOneNodeIds, alwaysTrue() ), + nodeData( false, config, groupOneNodeIds, TRUE ), "--nodes", nodeHeader( config, groupTwo ) + MULTI_FILE_DELIMITER + - nodeData( false, config, groupTwoNodeIds, alwaysTrue() ), + nodeData( false, config, groupTwoNodeIds, TRUE ), "--relationships", relationshipHeader( config, groupOne, groupTwo, true ) + MULTI_FILE_DELIMITER + - relationshipData( false, config, rels.iterator(), alwaysTrue(), true ) ); + relationshipData( false, config, rels.iterator(), TRUE, true ) ); // THEN GraphDatabaseService db = dbRule.getGraphDatabaseService(); @@ -412,9 +412,9 @@ public void shouldNotBeAbleToMixSpecifiedAndUnspecifiedGroups() throws Exception importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--nodes", nodeHeader( config, "MyGroup" ).getAbsolutePath() + MULTI_FILE_DELIMITER + - nodeData( false, config, groupOneNodeIds, alwaysTrue() ).getAbsolutePath(), + nodeData( false, config, groupOneNodeIds, TRUE ).getAbsolutePath(), "--nodes", nodeHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + - nodeData( false, config, groupTwoNodeIds, alwaysTrue() ).getAbsolutePath() ); + nodeData( false, config, groupTwoNodeIds, TRUE ).getAbsolutePath() ); fail( "Should have failed" ); } catch ( Exception e ) @@ -434,10 +434,10 @@ public void shouldImportWithoutTypeSpecifiedInRelationshipHeaderbutWithDefaultTy // WHEN importTool( "--into", dbRule.getStoreDirAbsolutePath(), - "--nodes", nodeData( true, config, nodeIds, alwaysTrue() ).getAbsolutePath(), + "--nodes", nodeData( true, config, nodeIds, TRUE ).getAbsolutePath(), // there will be no :TYPE specified in the header of the relationships below "--relationships:" + type, - relationshipData( true, config, nodeIds, alwaysTrue(), false ).getAbsolutePath() ); + relationshipData( true, config, nodeIds, TRUE, false ).getAbsolutePath() ); // THEN verifyData(); @@ -515,7 +515,7 @@ public void shouldLogRelationshipsReferringToMissingNode() throws Exception // GIVEN List nodeIds = asList( "a", "b", "c" ); Configuration config = Configuration.COMMAS; - File nodeData = nodeData( true, config, nodeIds, alwaysTrue() ); + File nodeData = nodeData( true, config, nodeIds, TRUE ); List relationships = Arrays.asList( // header line 1 of file1 relationship( "a", "b", "TYPE", "aa" ), // line 2 of file1 @@ -551,7 +551,7 @@ public void shouldFailIfTooManyBadRelationships() throws Exception // GIVEN List nodeIds = asList( "a", "b", "c" ); Configuration config = Configuration.COMMAS; - File nodeData = nodeData( true, config, nodeIds, alwaysTrue() ); + File nodeData = nodeData( true, config, nodeIds, TRUE ); List relationships = Arrays.asList( // header line 1 of file1 relationship( "a", "b", "TYPE" ), // line 2 of file1 @@ -587,7 +587,7 @@ public void shouldBeAbleToDisableSkippingOfBadRelationships() throws Exception // GIVEN List nodeIds = asList( "a", "b", "c" ); Configuration config = Configuration.COMMAS; - File nodeData = nodeData( true, config, nodeIds, alwaysTrue() ); + File nodeData = nodeData( true, config, nodeIds, TRUE ); List relationships = Arrays.asList( // header line 1 of file1 @@ -629,8 +629,8 @@ public void shouldHandleAdditiveLabelsWithSpaces() throws Exception importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--nodes:My First Label:My Other Label", - nodeData( true, config, nodeIds, alwaysTrue() ).getAbsolutePath(), - "--relationships", relationshipData( true, config, nodeIds, alwaysTrue(), true ).getAbsolutePath() ); + nodeData( true, config, nodeIds, TRUE ).getAbsolutePath(), + "--relationships", relationshipData( true, config, nodeIds, TRUE, true ).getAbsolutePath() ); // THEN verifyData( node -> { @@ -651,8 +651,8 @@ public void shouldImportFromInputDataEncodedWithSpecificCharset() throws Excepti importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--input-encoding", charset.name(), - "--nodes", nodeData( true, config, nodeIds, alwaysTrue(), charset ).getAbsolutePath(), - "--relationships", relationshipData( true, config, nodeIds, alwaysTrue(), true, charset ) + "--nodes", nodeData( true, config, nodeIds, TRUE, charset ).getAbsolutePath(), + "--relationships", relationshipData( true, config, nodeIds, TRUE, true, charset ) .getAbsolutePath() ); // THEN @@ -672,7 +672,7 @@ public void shouldDisallowImportWithoutNodesInput() throws Exception importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--relationships", - relationshipData( true, config, nodeIds, alwaysTrue(), true ).getAbsolutePath() ); + relationshipData( true, config, nodeIds, TRUE, true ).getAbsolutePath() ); fail( "Should have failed" ); } catch ( IllegalArgumentException e ) @@ -693,9 +693,9 @@ public void shouldBeAbleToImportAnonymousNodes() throws Exception // WHEN importTool( "--into", dbRule.getStoreDirAbsolutePath(), - "--nodes", nodeData( true, config, nodeIds, alwaysTrue() ).getAbsolutePath(), + "--nodes", nodeData( true, config, nodeIds, TRUE ).getAbsolutePath(), "--relationships", relationshipData( true, config, relationshipData.iterator(), - alwaysTrue(), true ).getAbsolutePath() ); + TRUE, true ).getAbsolutePath() ); // THEN GraphDatabaseService db = dbRule.getGraphDatabaseService(); @@ -775,9 +775,9 @@ private void shouldPrintReferenceLinkAsPartOfErrorMessage( List nodeIds, // WHEN importTool( "--into", dbRule.getStoreDirAbsolutePath(), - "--nodes", nodeData( true, config, nodeIds, alwaysTrue() ).getAbsolutePath(), + "--nodes", nodeData( true, config, nodeIds, TRUE ).getAbsolutePath(), "--relationships", relationshipData( true, config, relationshipDataLines, - alwaysTrue(), true ).getAbsolutePath() ); + TRUE, true ).getAbsolutePath() ); fail( " Should fail during import." ); } catch ( Exception e ) diff --git a/community/primitive-collections/src/main/java/org/neo4j/collection/primitive/PrimitiveIntCollections.java b/community/primitive-collections/src/main/java/org/neo4j/collection/primitive/PrimitiveIntCollections.java index 6432924936499..0daa7892d7fe0 100644 --- a/community/primitive-collections/src/main/java/org/neo4j/collection/primitive/PrimitiveIntCollections.java +++ b/community/primitive-collections/src/main/java/org/neo4j/collection/primitive/PrimitiveIntCollections.java @@ -25,7 +25,6 @@ import java.util.function.IntPredicate; import org.neo4j.collection.primitive.base.Empty; -import org.neo4j.function.IntPredicates; import org.neo4j.function.primitive.FunctionFromPrimitiveInt; import org.neo4j.function.primitive.PrimitiveIntPredicate;