Skip to content

Commit

Permalink
Merge pull request #9246 from MishaDemianenko/3.2-private-constructor…
Browse files Browse the repository at this point in the history
…s-utility-classes

Add private constructors to utility classes.
  • Loading branch information
MishaDemianenko committed May 4, 2017
2 parents 68783d5 + 208a291 commit 5bfa413
Show file tree
Hide file tree
Showing 253 changed files with 1,074 additions and 250 deletions.
Expand Up @@ -483,4 +483,8 @@ String msg()
return msg;
}
}

private Neo4jPack()
{
}
}
Expand Up @@ -29,6 +29,10 @@
/** Takes execution plans and converts them to the subset of types used in the Neo4j type system */
class ExecutionPlanConverter
{
private ExecutionPlanConverter()
{
}

public static Map<String, Object> convert( ExecutionPlanDescription plan )
{
Map<String, Object> out = new HashMap<>();
Expand Down
Expand Up @@ -21,6 +21,10 @@

public class Records
{
private Records()
{
}

public static Record record( final Object ... fields )
{
return new ImmutableRecord( fields );
Expand Down
Expand Up @@ -22,6 +22,10 @@
import org.hamcrest.BaseMatcher;
import org.hamcrest.Description;
import org.hamcrest.Matcher;

import java.util.Arrays;
import java.util.regex.Pattern;

import org.neo4j.bolt.security.auth.AuthenticationException;
import org.neo4j.bolt.v1.runtime.BoltConnectionFatality;
import org.neo4j.bolt.v1.runtime.BoltStateMachine;
Expand All @@ -31,12 +35,7 @@
import org.neo4j.function.ThrowingBiConsumer;
import org.neo4j.kernel.api.exceptions.Status;

import java.util.Arrays;
import java.util.regex.Pattern;

import static java.lang.String.format;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
import static org.neo4j.bolt.v1.messaging.BoltResponseMessage.FAILURE;
Expand All @@ -47,6 +46,10 @@

public class BoltMatchers
{
private BoltMatchers()
{
}

public static Matcher<RecordedBoltResponse> succeeded()
{
return new BaseMatcher<RecordedBoltResponse>()
Expand Down
Expand Up @@ -21,14 +21,13 @@

import java.util.Collections;

import org.neo4j.graphdb.Node;
import org.neo4j.bolt.v1.messaging.infrastructure.ValueNode;
import org.neo4j.graphdb.Node;

import static java.util.Arrays.asList;

import static org.neo4j.bolt.v1.messaging.example.Support.NO_LABELS;
import static org.neo4j.graphdb.Label.label;
import static org.neo4j.helpers.collection.MapUtil.map;
import static org.neo4j.bolt.v1.messaging.example.Support.NO_LABELS;

public class Nodes
{
Expand All @@ -49,4 +48,7 @@ public class Nodes
NO_LABELS,
map( "name", "Dave" ) );

private Nodes()
{
}
}
Expand Up @@ -19,12 +19,9 @@
*/
package org.neo4j.bolt.v1.messaging.example;

import org.neo4j.graphdb.Path;
import org.neo4j.bolt.v1.messaging.infrastructure.ValuePath;
import org.neo4j.graphdb.Path;

import static org.neo4j.bolt.v1.messaging.example.Support.nodes;
import static org.neo4j.bolt.v1.messaging.example.Support.relationships;
import static org.neo4j.bolt.v1.messaging.example.Support.sequence;
import static org.neo4j.bolt.v1.messaging.example.Nodes.ALICE;
import static org.neo4j.bolt.v1.messaging.example.Nodes.BOB;
import static org.neo4j.bolt.v1.messaging.example.Nodes.CAROL;
Expand All @@ -34,6 +31,9 @@
import static org.neo4j.bolt.v1.messaging.example.Relationships.CAROL_DISLIKES_BOB;
import static org.neo4j.bolt.v1.messaging.example.Relationships.CAROL_MARRIED_TO_DAVE;
import static org.neo4j.bolt.v1.messaging.example.Relationships.DAVE_WORKS_FOR_DAVE;
import static org.neo4j.bolt.v1.messaging.example.Support.nodes;
import static org.neo4j.bolt.v1.messaging.example.Support.relationships;
import static org.neo4j.bolt.v1.messaging.example.Support.sequence;

/*
* This class contains a number of paths used for testing, all based on
Expand Down Expand Up @@ -105,4 +105,7 @@ public class Paths
PATH_WITH_LOOP,
};

private Paths()
{
}
}
Expand Up @@ -19,16 +19,16 @@
*/
package org.neo4j.bolt.v1.messaging.example;

import org.neo4j.bolt.v1.messaging.infrastructure.ValueRelationship;
import org.neo4j.graphdb.Relationship;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.bolt.v1.messaging.infrastructure.ValueRelationship;

import static org.neo4j.helpers.collection.MapUtil.map;
import static org.neo4j.bolt.v1.messaging.example.Support.NO_PROPERTIES;
import static org.neo4j.bolt.v1.messaging.example.Nodes.ALICE;
import static org.neo4j.bolt.v1.messaging.example.Nodes.BOB;
import static org.neo4j.bolt.v1.messaging.example.Nodes.CAROL;
import static org.neo4j.bolt.v1.messaging.example.Nodes.DAVE;
import static org.neo4j.bolt.v1.messaging.example.Support.NO_PROPERTIES;
import static org.neo4j.helpers.collection.MapUtil.map;

public class Relationships
{
Expand Down Expand Up @@ -58,4 +58,7 @@ public class Relationships
new ValueRelationship( 44L, DAVE.getId(), DAVE.getId(), WORKS_FOR,
NO_PROPERTIES );

private Relationships()
{
}
}
Expand Up @@ -37,6 +37,10 @@ public class Support
public static final List<Label> NO_LABELS = new ArrayList<>();
public static final Map<String, Object> NO_PROPERTIES = new HashMap<>();

private Support()
{
}

// Collect labels from a Node
public static Collection<Label> labels( Node node )
{
Expand Down
Expand Up @@ -61,6 +61,9 @@

public class MessageMatchers
{
private MessageMatchers()
{
}

public static Matcher<List<ResponseMessage>> equalsMessages( final Matcher<ResponseMessage>... messageMatchers )
{
Expand Down
Expand Up @@ -42,6 +42,10 @@ public class MachineRoom
static final Map<String, Object> EMPTY_PARAMS = emptyMap();
static final String USER_AGENT = "BoltStateMachineTest/0.0";

private MachineRoom()
{
}

public static BoltStateMachine newMachine()
{
return new BoltStateMachine( mock( BoltStateMachineSPI.class, RETURNS_MOCKS ), null, Clock.systemUTC() );
Expand Down
Expand Up @@ -31,6 +31,10 @@

public class StreamMatchers
{
private StreamMatchers()
{
}

public static Matcher<Record> eqRecord( final Matcher<?>... expectedFieldValues )
{
return new TypeSafeMatcher<Record>()
Expand Down
Expand Up @@ -43,6 +43,10 @@

public class TransportTestUtil
{
private TransportTestUtil()
{
}

public static byte[] dechunk( byte[] chunked ) throws IOException
{
ByteBuffer in = ByteBuffer.wrap( chunked );
Expand Down
Expand Up @@ -38,6 +38,10 @@
/** Helper to chunk up serialized data for testing */
public class Chunker
{
private Chunker()
{
}

public static byte[] chunk( int maxChunkSize, byte[][] messages ) throws IOException
{
final ByteBuffer outputBuffer = ByteBuffer.allocate( 1024 * 8 );
Expand Down
Expand Up @@ -46,6 +46,11 @@

public final class Iterables
{

private Iterables()
{
}

@SuppressWarnings( "unchecked" )
public static <T> Iterable<T> empty()
{
Expand Down
Expand Up @@ -36,6 +36,10 @@

public class Util
{
private Util()
{
}

public static Path canonicalPath( Path path ) throws IllegalArgumentException
{
return canonicalPath( path.toFile() );
Expand Down
Expand Up @@ -24,14 +24,11 @@
*/
public final class IOFunctions
{
private static final IOFunction IDENTITY = new IOFunction()
private static final IOFunction IDENTITY = value -> value;

private IOFunctions()
{
@Override
public Object apply( Object value )
{
return value;
}
};
}

@SuppressWarnings( "unchecked" )
public static <T> IOFunction<T,T> identity()
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.time.Clock;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
Expand All @@ -44,9 +45,13 @@ public class Predicates

private static final Predicate FALSE = item -> false;

private static final Predicate NOT_NULL = item -> item != null;
private static final Predicate NOT_NULL = Objects::nonNull;
private static final int DEFAULT_POLL_INTERVAL = 20;

private Predicates()
{
}

@SuppressWarnings( "unchecked" )
public static <T> Predicate<T> alwaysTrue()
{
Expand Down
Expand Up @@ -22,7 +22,6 @@
import java.util.concurrent.TimeUnit;
import java.util.function.BooleanSupplier;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.function.Supplier;

import static java.lang.System.currentTimeMillis;
Expand All @@ -32,6 +31,10 @@
*/
public final class Suppliers
{
private Suppliers()
{
}

/**
* Creates a {@link Supplier} that returns a single object
*
Expand Down

This file was deleted.

This file was deleted.

0 comments on commit 5bfa413

Please sign in to comment.