Skip to content

Commit

Permalink
Reformat code after enable Spotless plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Dec 11, 2022
1 parent 7b65df9 commit d00983e
Show file tree
Hide file tree
Showing 67 changed files with 2,981 additions and 4,445 deletions.
5 changes: 1 addition & 4 deletions mrm-api/pom.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>

<!--
~ Copyright 2011 Stephen Connolly
~
Expand All @@ -15,7 +14,6 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -60,8 +58,7 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</dependencies>

</project>
69 changes: 25 additions & 44 deletions mrm-api/src/main/java/org/codehaus/mojo/mrm/api/AbstractEntry.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
* @serial
* @since 1.0
*/
public abstract class AbstractEntry
implements Entry
{
public abstract class AbstractEntry implements Entry {

/**
* Ensure consistent serialization.
Expand Down Expand Up @@ -65,8 +63,7 @@ public abstract class AbstractEntry
* @param name The name of the entry.
* @since 1.0
*/
protected AbstractEntry( FileSystem fileSystem, DirectoryEntry parent, String name )
{
protected AbstractEntry(FileSystem fileSystem, DirectoryEntry parent, String name) {
this.fileSystem = fileSystem;
this.parent = parent;
this.name = name;
Expand All @@ -75,100 +72,84 @@ protected AbstractEntry( FileSystem fileSystem, DirectoryEntry parent, String na
/**
* {@inheritDoc}
*/
public FileSystem getFileSystem()
{
public FileSystem getFileSystem() {
return fileSystem;
}

/**
* {@inheritDoc}
*/
public DirectoryEntry getParent()
{
public DirectoryEntry getParent() {
return parent;
}

/**
* {@inheritDoc}
*/
public String getName()
{
public String getName() {
return name;
}

/**
* {@inheritDoc}
*/
public boolean equals( Object o )
{
if ( this == o )
{
public boolean equals(Object o) {
if (this == o) {
return true;
}
if ( !( o instanceof AbstractEntry ) )
{
if (!(o instanceof AbstractEntry)) {
return false;
}

AbstractEntry abstractEntry = (AbstractEntry) o;

if ( !fileSystem.equals( abstractEntry.fileSystem ) )
{
if (!fileSystem.equals(abstractEntry.fileSystem)) {
return false;
}
if ( !name.equals( abstractEntry.name ) )
{
if (!name.equals(abstractEntry.name)) {
return false;
}
return Objects.equals( parent, abstractEntry.parent );
return Objects.equals(parent, abstractEntry.parent);
}

/**
* {@inheritDoc}
*/
public final int hashCode()
{
public final int hashCode() {
int result = name.hashCode();
result = 31 * result + ( parent != null ? parent.hashCode() : 0 );
result = 31 * result + (parent != null ? parent.hashCode() : 0);
return result;
}

/**
* {@inheritDoc}
*/
public String toString()
{
public String toString() {
final StringBuilder sb = new StringBuilder();
sb.append( "Entry[" );
sb.append( fileSystem );
sb.append( ':' ).append( toPath() ).append( ']' );
sb.append("Entry[");
sb.append(fileSystem);
sb.append(':').append(toPath()).append(']');
return sb.toString();
}

/**
* {@inheritDoc}
*/
public final String toPath()
{
public final String toPath() {
Stack<String> stack = new Stack<>();
Entry root = getFileSystem().getRoot();
Entry entry = this;
do
{
stack.push( entry.getName() );
do {
stack.push(entry.getName());
entry = entry.getParent();
}
while ( entry != null && !root.equals( entry ) );
} while (entry != null && !root.equals(entry));

StringBuilder buf = new StringBuilder();
while ( stack.size() > 1 )
{
buf.append( stack.pop() );
buf.append( '/' );
while (stack.size() > 1) {
buf.append(stack.pop());
buf.append('/');
}
buf.append( stack.pop() );
buf.append(stack.pop());
return buf.toString();
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@
*
* @since 1.0
*/
public abstract class BaseFileEntry
extends AbstractEntry
implements FileEntry
{
public abstract class BaseFileEntry extends AbstractEntry implements FileEntry {
/**
* Ensure consistent serialization.
*
Expand All @@ -40,8 +37,7 @@ public abstract class BaseFileEntry
* @param name The name of the entry.
* @since 1.0
*/
protected BaseFileEntry( FileSystem fileSystem, DirectoryEntry parent, String name )
{
super( fileSystem, parent, name );
protected BaseFileEntry(FileSystem fileSystem, DirectoryEntry parent, String name) {
super(fileSystem, parent, name);
}
}
62 changes: 22 additions & 40 deletions mrm-api/src/main/java/org/codehaus/mojo/mrm/api/BaseFileSystem.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@
*
* @since 1.0
*/
public abstract class BaseFileSystem
implements FileSystem
{
public abstract class BaseFileSystem implements FileSystem {
/**
* Ensure consistent serialization.
*
Expand All @@ -38,40 +36,34 @@ public abstract class BaseFileSystem
/**
* The root entry.
*/
private final DirectoryEntry root = new DefaultDirectoryEntry( this, null, "" );
private final DirectoryEntry root = new DefaultDirectoryEntry(this, null, "");

/**
* {@inheritDoc}
*/
public DirectoryEntry getRoot()
{
public DirectoryEntry getRoot() {
return root;
}

/**
* {@inheritDoc}
*/
public Entry get( String path )
{
if ( path.startsWith( "/" ) )
{
path = path.substring( 1 );
public Entry get(String path) {
if (path.startsWith("/")) {
path = path.substring(1);
}
if ( path.length() == 0 )
{
if (path.length() == 0) {
return root;
}
String[] parts = path.split( "/" );
if ( parts.length == 0 )
{
String[] parts = path.split("/");
if (parts.length == 0) {
return root;
}
DirectoryEntry parent = root;
for ( int i = 0; i < parts.length - 1; i++ )
{
parent = new DefaultDirectoryEntry( this, parent, parts[i] );
for (int i = 0; i < parts.length - 1; i++) {
parent = new DefaultDirectoryEntry(this, parent, parts[i]);
}
return get( parent, parts[parts.length - 1] );
return get(parent, parts[parts.length - 1]);
}

/**
Expand All @@ -83,16 +75,12 @@ public Entry get( String path )
* @param name the name of the entry to get.
* @return the {@link Entry} or <code>null</code> if the entry does not exist.
*/
protected Entry get( DirectoryEntry parent, String name )
{
protected Entry get(DirectoryEntry parent, String name) {
parent.getClass();
Entry[] entries = listEntries( parent );
if ( entries != null )
{
for ( Entry entry : entries )
{
if ( name.equals( entry.getName() ) )
{
Entry[] entries = listEntries(parent);
if (entries != null) {
for (Entry entry : entries) {
if (name.equals(entry.getName())) {
return entry;
}
}
Expand All @@ -103,34 +91,28 @@ protected Entry get( DirectoryEntry parent, String name )
/**
* {@inheritDoc}
*/
public DirectoryEntry mkdir( DirectoryEntry parent, String name )
{
public DirectoryEntry mkdir(DirectoryEntry parent, String name) {
throw new UnsupportedOperationException();
}

/**
* {@inheritDoc}
*/
public FileEntry put( DirectoryEntry parent, String name, InputStream content )
throws IOException
{
public FileEntry put(DirectoryEntry parent, String name, InputStream content) throws IOException {
throw new UnsupportedOperationException();
}

/**
* {@inheritDoc}
*/
public FileEntry put( DirectoryEntry parent, String name, byte[] content )
throws IOException
{
return put( parent, name, new ByteArrayInputStream( content ) );
public FileEntry put(DirectoryEntry parent, String name, byte[] content) throws IOException {
return put(parent, name, new ByteArrayInputStream(content));
}

/**
* {@inheritDoc}
*/
public void remove( Entry entry )
{
public void remove(Entry entry) {
throw new UnsupportedOperationException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
*
* @since 1.0
*/
public class DefaultDirectoryEntry
extends AbstractEntry
implements DirectoryEntry
{
public class DefaultDirectoryEntry extends AbstractEntry implements DirectoryEntry {
/**
* Ensure consistent serialization.
*
Expand All @@ -42,9 +39,8 @@ public class DefaultDirectoryEntry
* @param name The name of the entry (or the empty string if this is the root entry).
* @since 1.0
*/
public DefaultDirectoryEntry( FileSystem fileSystem, DirectoryEntry parent, String name )
{
super( fileSystem, parent, name );
public DefaultDirectoryEntry(FileSystem fileSystem, DirectoryEntry parent, String name) {
super(fileSystem, parent, name);
}

/**
Expand All @@ -56,25 +52,20 @@ public DefaultDirectoryEntry( FileSystem fileSystem, DirectoryEntry parent, Stri
* @return a {@link DirectoryEntry} in the target filesystem.
* @since 1.0
*/
public static DirectoryEntry equivalent( FileSystem target, DirectoryEntry directory )
{
if ( target.equals( directory.getFileSystem() ) )
{
public static DirectoryEntry equivalent(FileSystem target, DirectoryEntry directory) {
if (target.equals(directory.getFileSystem())) {
return directory;
}
if ( directory.getParent() == null )
{
if (directory.getParent() == null) {
return target.getRoot();
}
return new DefaultDirectoryEntry( target, equivalent( target, directory.getParent() ), directory.getName() );
return new DefaultDirectoryEntry(target, equivalent(target, directory.getParent()), directory.getName());
}

/**
* {@inheritDoc}
*/
public long getLastModified()
throws IOException
{
return getFileSystem().getLastModified( this );
public long getLastModified() throws IOException {
return getFileSystem().getLastModified(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,4 @@
*
* @since 1.0
*/
public interface DirectoryEntry
extends Entry
{
}
public interface DirectoryEntry extends Entry {}
Loading

0 comments on commit d00983e

Please sign in to comment.