From df94066e3af02ff02d5ab4d033a3d603f743234c Mon Sep 17 00:00:00 2001 From: bjculkin Date: Mon, 12 Feb 2018 22:45:04 -0500 Subject: Formatting pass --- .../utils/components/FileComponentRepository.java | 46 ++++++++++++---------- 1 file changed, 25 insertions(+), 21 deletions(-) (limited to 'base/src/main/java/bjc/utils/components/FileComponentRepository.java') 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); } -- cgit v1.2.3