Skip to content

Commit

Permalink
Add spotless-maven-plugin for Java formatting (#1227) (#1234)
Browse files Browse the repository at this point in the history
* Add spotless-maven-plugin for Java formatting

This update introduces similar updates to Neo4j server.

* Add .gitattributes
  • Loading branch information
injectives committed May 31, 2022
1 parent 0084fc6 commit 9bab06b
Show file tree
Hide file tree
Showing 854 changed files with 37,910 additions and 46,413 deletions.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.java eol=lf
*.xml eol=lf

3 changes: 1 addition & 2 deletions driver/src/main/java/org/neo4j/driver/AccessMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@
* While any {@link AccessMode} will be ignored while running transactions via a driver towards a single server.
* As the single server serves both read and write operations at the same time.
*/
public enum AccessMode
{
public enum AccessMode {
/**
* Use this for transactions that requires a read server in a cluster
*/
Expand Down
5 changes: 1 addition & 4 deletions driver/src/main/java/org/neo4j/driver/AuthToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,4 @@
* @see GraphDatabase#driver(String, AuthToken)
* @since 1.0
*/
public interface AuthToken
{

}
public interface AuthToken {}
107 changes: 48 additions & 59 deletions driver/src/main/java/org/neo4j/driver/AuthTokens.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@
*/
package org.neo4j.driver;

import java.util.Map;
import java.util.Objects;

import org.neo4j.driver.internal.security.InternalAuthToken;

import static java.util.Collections.singletonMap;
import static org.neo4j.driver.Values.value;
import static org.neo4j.driver.internal.security.InternalAuthToken.CREDENTIALS_KEY;
Expand All @@ -32,15 +27,18 @@
import static org.neo4j.driver.internal.security.InternalAuthToken.SCHEME_KEY;
import static org.neo4j.driver.internal.util.Iterables.newHashMapWithSize;

import java.util.Map;
import java.util.Objects;
import org.neo4j.driver.internal.security.InternalAuthToken;

/**
* This is a listing of the various methods of authentication supported by this
* driver. The scheme used must be supported by the Neo4j Instance you are connecting
* to.
* @see GraphDatabase#driver(String, AuthToken)
* @since 1.0
*/
public class AuthTokens
{
public class AuthTokens {
/**
* The basic authentication scheme, using a username and a password.
* @param username this is the "principal", identifying who this token represents
Expand All @@ -49,9 +47,8 @@ public class AuthTokens
* @see GraphDatabase#driver(String, AuthToken)
* @throws NullPointerException when either username or password is {@code null}
*/
public static AuthToken basic( String username, String password )
{
return basic( username, password, null );
public static AuthToken basic(String username, String password) {
return basic(username, password, null);
}

/**
Expand All @@ -63,20 +60,18 @@ public static AuthToken basic( String username, String password )
* @see GraphDatabase#driver(String, AuthToken)
* @throws NullPointerException when either username or password is {@code null}
*/
public static AuthToken basic( String username, String password, String realm )
{
Objects.requireNonNull( username, "Username can't be null" );
Objects.requireNonNull( password, "Password can't be null" );
public static AuthToken basic(String username, String password, String realm) {
Objects.requireNonNull(username, "Username can't be null");
Objects.requireNonNull(password, "Password can't be null");

Map<String,Value> map = newHashMapWithSize( 4 );
map.put( SCHEME_KEY, value( "basic" ) );
map.put( PRINCIPAL_KEY, value( username ) );
map.put( CREDENTIALS_KEY, value( password ) );
if ( realm != null )
{
map.put( REALM_KEY, value( realm ) );
Map<String, Value> map = newHashMapWithSize(4);
map.put(SCHEME_KEY, value("basic"));
map.put(PRINCIPAL_KEY, value(username));
map.put(CREDENTIALS_KEY, value(password));
if (realm != null) {
map.put(REALM_KEY, value(realm));
}
return new InternalAuthToken( map );
return new InternalAuthToken(map);
}

/**
Expand All @@ -87,14 +82,13 @@ public static AuthToken basic( String username, String password, String realm )
* @throws NullPointerException when token is {@code null}
* @see GraphDatabase#driver(String, AuthToken)
*/
public static AuthToken bearer( String token )
{
Objects.requireNonNull( token, "Token can't be null" );
public static AuthToken bearer(String token) {
Objects.requireNonNull(token, "Token can't be null");

Map<String,Value> map = newHashMapWithSize( 2 );
map.put( SCHEME_KEY, value( "bearer" ) );
map.put( CREDENTIALS_KEY, value( token ) );
return new InternalAuthToken( map );
Map<String, Value> map = newHashMapWithSize(2);
map.put(SCHEME_KEY, value("bearer"));
map.put(CREDENTIALS_KEY, value(token));
return new InternalAuthToken(map);
}

/**
Expand All @@ -106,15 +100,14 @@ public static AuthToken bearer( String token )
* @see GraphDatabase#driver(String, AuthToken)
* @since 1.3
*/
public static AuthToken kerberos( String base64EncodedTicket )
{
Objects.requireNonNull( base64EncodedTicket, "Ticket can't be null" );
public static AuthToken kerberos(String base64EncodedTicket) {
Objects.requireNonNull(base64EncodedTicket, "Ticket can't be null");

Map<String,Value> map = newHashMapWithSize( 3 );
map.put( SCHEME_KEY, value( "kerberos" ) );
map.put( PRINCIPAL_KEY, value( "" ) ); // This empty string is required for backwards compatibility.
map.put( CREDENTIALS_KEY, value( base64EncodedTicket ) );
return new InternalAuthToken( map );
Map<String, Value> map = newHashMapWithSize(3);
map.put(SCHEME_KEY, value("kerberos"));
map.put(PRINCIPAL_KEY, value("")); // This empty string is required for backwards compatibility.
map.put(CREDENTIALS_KEY, value(base64EncodedTicket));
return new InternalAuthToken(map);
}

/**
Expand All @@ -127,9 +120,8 @@ public static AuthToken kerberos( String base64EncodedTicket )
* @see GraphDatabase#driver(String, AuthToken)
* @throws NullPointerException when either principal, credentials or scheme is {@code null}
*/
public static AuthToken custom( String principal, String credentials, String realm, String scheme)
{
return custom( principal, credentials, realm, scheme, null );
public static AuthToken custom(String principal, String credentials, String realm, String scheme) {
return custom(principal, credentials, realm, scheme, null);
}

/**
Expand All @@ -143,25 +135,23 @@ public static AuthToken custom( String principal, String credentials, String rea
* @see GraphDatabase#driver(String, AuthToken)
* @throws NullPointerException when either principal, credentials or scheme is {@code null}
*/
public static AuthToken custom( String principal, String credentials, String realm, String scheme, Map<String, Object> parameters)
{
Objects.requireNonNull( principal, "Principal can't be null" );
Objects.requireNonNull( credentials, "Credentials can't be null" );
Objects.requireNonNull( scheme, "Scheme can't be null" );
public static AuthToken custom(
String principal, String credentials, String realm, String scheme, Map<String, Object> parameters) {
Objects.requireNonNull(principal, "Principal can't be null");
Objects.requireNonNull(credentials, "Credentials can't be null");
Objects.requireNonNull(scheme, "Scheme can't be null");

Map<String,Value> map = newHashMapWithSize( 5 );
map.put( SCHEME_KEY, value( scheme ) );
map.put( PRINCIPAL_KEY, value( principal ) );
map.put( CREDENTIALS_KEY, value( credentials ) );
if ( realm != null )
{
map.put( REALM_KEY, value( realm ) );
Map<String, Value> map = newHashMapWithSize(5);
map.put(SCHEME_KEY, value(scheme));
map.put(PRINCIPAL_KEY, value(principal));
map.put(CREDENTIALS_KEY, value(credentials));
if (realm != null) {
map.put(REALM_KEY, value(realm));
}
if ( parameters != null )
{
map.put( PARAMETERS_KEY, value( parameters ) );
if (parameters != null) {
map.put(PARAMETERS_KEY, value(parameters));
}
return new InternalAuthToken( map );
return new InternalAuthToken(map);
}

/**
Expand All @@ -170,8 +160,7 @@ public static AuthToken custom( String principal, String credentials, String rea
* @return an authentication token that can be used to connect to Neo4j instances with auth disabled
* @see GraphDatabase#driver(String, AuthToken)
*/
public static AuthToken none()
{
return new InternalAuthToken( singletonMap( SCHEME_KEY, value( "none" ) ) );
public static AuthToken none() {
return new InternalAuthToken(singletonMap(SCHEME_KEY, value("none")));
}
}
9 changes: 3 additions & 6 deletions driver/src/main/java/org/neo4j/driver/Bookmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
package org.neo4j.driver;

import java.util.Set;

import org.neo4j.driver.internal.InternalBookmark;

/**
Expand All @@ -33,8 +32,7 @@
*
* To opt out of this mechanism for unrelated units of work, applications can use multiple sessions.
*/
public interface Bookmark
{
public interface Bookmark {
/**
* Returns a read-only set of bookmark strings that this bookmark instance identifies.
* @return a read-only set of bookmark strings that this bookmark instance identifies.
Expand All @@ -46,9 +44,8 @@ public interface Bookmark
* @param values values obtained from a previous bookmark.
* @return A bookmark.
*/
static Bookmark from( Set<String> values )
{
return InternalBookmark.parse( values );
static Bookmark from(Set<String> values) {
return InternalBookmark.parse(values);
}

/**
Expand Down

0 comments on commit 9bab06b

Please sign in to comment.