From df94066e3af02ff02d5ab4d033a3d603f743234c Mon Sep 17 00:00:00 2001 From: bjculkin Date: Mon, 12 Feb 2018 22:45:04 -0500 Subject: Formatting pass --- .../bjc/utils/components/ComponentDescription.java | 52 +++++++++++----------- .../components/ComponentDescriptionFileParser.java | 6 +-- .../components/ComponentDescriptionState.java | 45 +++++++++---------- .../utils/components/FileComponentRepository.java | 46 ++++++++++--------- .../bjc/utils/components/IComponentRepository.java | 19 ++++---- .../bjc/utils/components/IDescribedComponent.java | 14 +++--- 6 files changed, 89 insertions(+), 93 deletions(-) (limited to 'base/src/main/java/bjc/utils/components') diff --git a/base/src/main/java/bjc/utils/components/ComponentDescription.java b/base/src/main/java/bjc/utils/components/ComponentDescription.java index 4f52ace..222dc09 100644 --- a/base/src/main/java/bjc/utils/components/ComponentDescription.java +++ b/base/src/main/java/bjc/utils/components/ComponentDescription.java @@ -10,39 +10,39 @@ public class ComponentDescription implements IDescribedComponent { @SuppressWarnings("unused") private static void sanityCheckArgs(final String name, final String author, final String description, final int version) { - if (name == null) { + if(name == null) { throw new NullPointerException("Component name can't be null"); - } else if (version <= 0) { + } else if(version <= 0) { throw new IllegalArgumentException("Component version must be greater than 0"); } } /** The author of the component */ - private final String author; + private final String author; /** The description of the component */ - private final String description; + private final String description; /** The name of the component */ - private final String name; + private final String name; /** The version of the component */ - private final int version; + private final int version; /** * Create a new component description. * * @param name - * The name of the component. + * The name of the component. * * @param author - * The author of the component. + * The author of the component. * * @param description - * The description of the component. + * The description of the component. * * @param version - * The version of the component. + * The version of the component. * * @throws IllegalArgumentException - * Thrown if version is less than 1. + * Thrown if version is less than 1. */ public ComponentDescription(final String name, final String author, final String description, final int version) { @@ -56,7 +56,7 @@ public class ComponentDescription implements IDescribedComponent { @Override public String getAuthor() { - if (author == null) { + if(author == null) { return IDescribedComponent.super.getAuthor(); } @@ -65,7 +65,7 @@ public class ComponentDescription implements IDescribedComponent { @Override public String getDescription() { - if (description == null) { + if(description == null) { return IDescribedComponent.super.getDescription(); } @@ -112,25 +112,25 @@ public class ComponentDescription implements IDescribedComponent { */ @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; final ComponentDescription other = (ComponentDescription) obj; - if (author == null) { - if (other.author != null) return false; - } else if (!author.equals(other.author)) return false; + if(author == null) { + if(other.author != null) return false; + } else if(!author.equals(other.author)) return false; - if (description == null) { - if (other.description != null) return false; - } else if (!description.equals(other.description)) return false; + if(description == null) { + if(other.description != null) return false; + } else if(!description.equals(other.description)) return false; - if (name == null) { - if (other.name != null) return false; - } else if (!name.equals(other.name)) return false; + if(name == null) { + if(other.name != null) return false; + } else if(!name.equals(other.name)) return false; - if (version != other.version) return false; + if(version != other.version) return false; return true; } diff --git a/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java b/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java index 3855f8f..c720cbf 100644 --- a/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java +++ b/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java @@ -38,19 +38,19 @@ public class ComponentDescriptionFileParser { * Parse a component description from a stream. * * @param inputSource - * The stream to parse from. + * The stream to parse from. * * @return The description parsed from the stream. */ public static ComponentDescription fromStream(final InputStream inputSource) { - if (inputSource == null) { + if(inputSource == null) { throw new NullPointerException("Input source must not be null"); } ComponentDescriptionState state = new ComponentDescriptionState(); /* * This is valid, because the thing that is returned is the same - * reference we passed in. + * reference we passed in. */ reader.fromStream(inputSource, state); diff --git a/base/src/main/java/bjc/utils/components/ComponentDescriptionState.java b/base/src/main/java/bjc/utils/components/ComponentDescriptionState.java index f944a9e..aea886e 100644 --- a/base/src/main/java/bjc/utils/components/ComponentDescriptionState.java +++ b/base/src/main/java/bjc/utils/components/ComponentDescriptionState.java @@ -22,7 +22,7 @@ public class ComponentDescriptionState { * Set the author of this component. * * @param author - * The author of this component. + * The author of this component. */ public void setAuthor(final String author) { this.author = author; @@ -32,7 +32,7 @@ public class ComponentDescriptionState { * Set the description of this component. * * @param description - * The description of this component. + * The description of this component. */ public void setDescription(final String description) { this.description = description; @@ -42,7 +42,7 @@ public class ComponentDescriptionState { * Set the name of this component. * * @param name - * The name of this component. + * The name of this component. */ public void setName(final String name) { this.name = name; @@ -52,7 +52,7 @@ public class ComponentDescriptionState { * Set the version of this component. * * @param version - * The version of this component. + * The version of this component. */ public void setVersion(final int version) { this.version = version; @@ -61,8 +61,7 @@ public class ComponentDescriptionState { /** * Convert this state into the description it represents. * - * @return - * The description represented by this state. + * @return The description represented by this state. */ public ComponentDescription toDescription() { return new ComponentDescription(name, author, description, version); @@ -71,7 +70,7 @@ public class ComponentDescriptionState { @Override public int hashCode() { final int prime = 31; - int result = 1; + int result = 1; result = prime * result + (author == null ? 0 : author.hashCode()); result = prime * result + (description == null ? 0 : description.hashCode()); @@ -83,25 +82,25 @@ public class ComponentDescriptionState { @Override public boolean equals(final Object obj) { - if (this == obj) return true; - if (obj == null) return false; - if (getClass() != obj.getClass()) return false; + if(this == obj) return true; + if(obj == null) return false; + if(getClass() != obj.getClass()) return false; final ComponentDescriptionState other = (ComponentDescriptionState) obj; - if (author == null) { - if (other.author != null) return false; - } else if (!author.equals(other.author)) return false; + if(author == null) { + if(other.author != null) return false; + } else if(!author.equals(other.author)) return false; - if (description == null) { - if (other.description != null) return false; - } else if (!description.equals(other.description)) return false; + if(description == null) { + if(other.description != null) return false; + } else if(!description.equals(other.description)) return false; - if (name == null) { - if (other.name != null) return false; - } else if (!name.equals(other.name)) return false; + if(name == null) { + if(other.name != null) return false; + } else if(!name.equals(other.name)) return false; - if (version != other.version) return false; + if(version != other.version) return false; return true; } @@ -116,19 +115,19 @@ public class ComponentDescriptionState { final StringBuilder builder = new StringBuilder(); builder.append("ComponentDescriptionState ["); - if (name != null) { + if(name != null) { builder.append("name="); builder.append(name); builder.append(", "); } - if (description != null) { + if(description != null) { builder.append("description="); builder.append(description); builder.append(", "); } - if (author != null) { + if(author != null) { builder.append("author="); builder.append(author); builder.append(", "); diff --git a/base/src/main/java/bjc/utils/components/FileComponentRepository.java b/base/src/main/java/bjc/utils/components/FileComponentRepository.java index 284c10c..cbf5aa9 100644 --- a/base/src/main/java/bjc/utils/components/FileComponentRepository.java +++ b/base/src/main/java/bjc/utils/components/FileComponentRepository.java @@ -22,7 +22,7 @@ import bjc.utils.funcutils.FileUtils; * @author ben * * @param - * The type of component being read in. + * The type of component being read in. */ public class FileComponentRepository implements IComponentRepository { @@ -43,22 +43,23 @@ public class FileComponentRepository * the loading of that component to fail, but a warning will be logged. * * @param directory - * The directory to read component files from. + * The directory to read component files from. * * @param componentReader - * The function to use to convert files to components. + * The function to use to convert files to components. */ public FileComponentRepository(final File directory, final Function componentReader) { /* Make sure we have valid arguments. */ - if (directory == null) { + if(directory == null) { throw new NullPointerException("Directory must not be null"); - } else if (!directory.isDirectory()) { - String msg = String.format("File %s is not a directory. Components can only be read from a directory.", + } else if(!directory.isDirectory()) { + String msg = String.format( + "File %s is not a directory. Components can only be read from a directory.", directory); throw new IllegalArgumentException(msg); - } else if (componentReader == null) { + } else if(componentReader == null) { throw new NullPointerException("Component reader must not be null"); } @@ -74,8 +75,8 @@ public class FileComponentRepository * but not recurse into sub-directories. */ final BiPredicate firstLevelTraverser = (pth, attr) -> { - if (attr.isDirectory() && !isFirstDir.getValue()) { - /* + if(attr.isDirectory() && !isFirstDir.getValue()) { + /* * Skip directories, they probably have * component support files. */ @@ -96,10 +97,13 @@ public class FileComponentRepository FileUtils.traverseDirectory(sourceDirectory, firstLevelTraverser, (pth, attr) -> { loadComponent(componentReader, pth); - /* Keep loading components, even if this one failed. */ + /* + * Keep loading components, even if this one + * failed. + */ return true; }); - } catch (final IOException ioex) { + } catch(final IOException ioex) { CLASS_LOGGER.log(Level.WARNING, ioex, () -> "Error found reading component from file."); } } @@ -130,16 +134,16 @@ public class FileComponentRepository /* Try to load the component. */ final ComponentType component = componentReader.apply(pth.toFile()); - if (component == null) { + if(component == null) { throw new NullPointerException("Component reader read null component"); - } else if (!components.containsKey(component.getName())) { + } else if(!components.containsKey(component.getName())) { /* * We only care about the latest version of a - * component. + * component. */ final ComponentType oldComponent = components.put(component.getName(), component); - if (oldComponent.getVersion() > component.getVersion()) { + if(oldComponent.getVersion() > component.getVersion()) { components.put(oldComponent.getName(), oldComponent); } } else { @@ -152,16 +156,16 @@ public class FileComponentRepository CLASS_LOGGER.warning(sb.toString()); } - } catch (final Exception ex) { - String msg = String.format("Error found reading component from file %s. It will not be loaded.", pth.toString()); + } catch(final Exception ex) { + String msg = String.format("Error found reading component from file %s. It will not be loaded.", + pth.toString()); CLASS_LOGGER.log(Level.WARNING, ex, () -> msg); } } /* - * @NOTE - * Should this be changed to something more readable? + * @NOTE Should this be changed to something more readable? * * (non-Javadoc) * @@ -172,13 +176,13 @@ public class FileComponentRepository final StringBuilder builder = new StringBuilder(); builder.append("FileComponentRepository ["); - if (components != null) { + if(components != null) { builder.append("components="); builder.append(components); builder.append(", "); } - if (sourceDirectory != null) { + if(sourceDirectory != null) { builder.append("sourceDirectory="); builder.append(sourceDirectory); } diff --git a/base/src/main/java/bjc/utils/components/IComponentRepository.java b/base/src/main/java/bjc/utils/components/IComponentRepository.java index 099693f..8ecd446 100644 --- a/base/src/main/java/bjc/utils/components/IComponentRepository.java +++ b/base/src/main/java/bjc/utils/components/IComponentRepository.java @@ -10,15 +10,14 @@ import bjc.utils.funcdata.IMap; * @author ben * * @param - * The type of components contained in this repository. + * The type of components contained in this repository. */ public interface IComponentRepository { /** * Get all of the components this repository knows about. * - * @return - * A map from component name to component, containing all of the - * components in the repositories. + * @return A map from component name to component, containing all of the + * components in the repositories. */ public IMap getAll(); @@ -26,18 +25,17 @@ public interface IComponentRepository * Get a component with a specific name. * * @param name - * The name of the component to retrieve. + * The name of the component to retrieve. * - * @return - * The named component, or null if no component with that name exists. + * @return The named component, or null if no component with that name + * exists. */ public ComponentType getByName(String name); /** * Get a list of all the registered components. * - * @return - * A list of all the registered components. + * @return A list of all the registered components. */ public default IList getList() { return getAll().valueList(); @@ -46,8 +44,7 @@ public interface IComponentRepository /** * Get the source from which these components came. * - * @return - * The source from which these components came. + * @return The source from which these components came. */ public String getSource(); } diff --git a/base/src/main/java/bjc/utils/components/IDescribedComponent.java b/base/src/main/java/bjc/utils/components/IDescribedComponent.java index 78af4bc..6921849 100644 --- a/base/src/main/java/bjc/utils/components/IDescribedComponent.java +++ b/base/src/main/java/bjc/utils/components/IDescribedComponent.java @@ -13,8 +13,7 @@ public interface IDescribedComponent extends Comparable { * * Providing this is optional, with "Anonymous" as the default author. * - * @return - * The author of the component. + * @return The author of the component. */ default String getAuthor() { return "Anonymous"; @@ -26,8 +25,7 @@ public interface IDescribedComponent extends Comparable { * Providing this is optional, with the default being a note that no * description was provided. * - * @return - * The description of the component + * @return The description of the component */ default String getDescription() { return "No description provided."; @@ -38,8 +36,7 @@ public interface IDescribedComponent extends Comparable { * * This is the only thing required of all components. * - * @return - * The name of the component. + * @return The name of the component. */ String getName(); @@ -48,8 +45,7 @@ public interface IDescribedComponent extends Comparable { * * Providing this is optional, with "1" as the default version. * - * @return - * The version of this component. + * @return The version of this component. */ default int getVersion() { return 1; @@ -59,7 +55,7 @@ public interface IDescribedComponent extends Comparable { default int compareTo(final IDescribedComponent o) { int res = getName().compareTo(o.getName()); - if (res == 0) { + if(res == 0) { res = getVersion() - o.getVersion(); } -- cgit v1.2.3