summaryrefslogtreecommitdiff
path: root/BJC-Utils2/src/main/java/bjc/utils/components
diff options
context:
space:
mode:
Diffstat (limited to 'BJC-Utils2/src/main/java/bjc/utils/components')
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java9
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java57
-rw-r--r--BJC-Utils2/src/main/java/bjc/utils/components/IComponentRepository.java16
3 files changed, 41 insertions, 41 deletions
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
index b35c77b..ef8f8b6 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
@@ -1,11 +1,12 @@
package bjc.utils.components;
+import static bjc.utils.parserutils.RuleBasedReaderPragmas.buildInteger;
+import static bjc.utils.parserutils.RuleBasedReaderPragmas.buildStringCollapser;
+
import java.io.InputStream;
import bjc.utils.parserutils.RuleBasedConfigReader;
-import static bjc.utils.parserutils.RuleBasedReaderPragmas.*;
-
/**
* Read a component description from a file
*
@@ -38,8 +39,8 @@ public class ComponentDescriptionFileParser {
* The stream to parse from
* @return The description parsed from the stream
*/
- public static ComponentDescription
- fromStream(InputStream inputSource) {
+ public static ComponentDescription fromStream(
+ InputStream inputSource) {
ComponentDescriptionState readState = reader
.fromStream(inputSource, new ComponentDescriptionState());
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java b/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java
index 182549c..bb2d421 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/components/FileComponentRepository.java
@@ -28,14 +28,14 @@ import bjc.utils.funcutils.FileUtils;
public class FileComponentRepository<ComponentType extends IDescribedComponent>
implements IComponentRepository<ComponentType> {
// The logger to use for storing data about this class
- private static final Logger CLASS_LOGGER =
- Logger.getLogger("FileComponentRepository");
+ private static final Logger CLASS_LOGGER = Logger
+ .getLogger("FileComponentRepository");
// The internal storage of components
private IMap<String, ComponentType> components;
// The path that all the components came from
- private Path sourceDirectory;
+ private Path sourceDirectory;
/**
* Create a new component repository sourcing components from files in
@@ -71,25 +71,24 @@ public class FileComponentRepository<ComponentType extends IDescribedComponent>
// Predicate to use to traverse all the files in a directory, but
// not recurse into sub-directories
- BiPredicate<Path, BasicFileAttributes> firstLevelTraverser =
- (pth, attr) -> {
- if (attr.isDirectory() && !isFirstDir.getValue()) {
-
- /*
- * Skip directories, they probably have component
- * support files.
- */
- return false;
- }
-
- /*
- * Don't skip the first directory, that's the parent
- * directory
- */
- isFirstDir.replace(false);
-
- return true;
- };
+ BiPredicate<Path, BasicFileAttributes> firstLevelTraverser = (pth,
+ attr) -> {
+ if (attr.isDirectory() && !isFirstDir.getValue()) {
+
+ /*
+ * Skip directories, they probably have component support
+ * files.
+ */
+ return false;
+ }
+
+ /*
+ * Don't skip the first directory, that's the parent directory
+ */
+ isFirstDir.replace(false);
+
+ return true;
+ };
// Try reading components
try {
@@ -107,6 +106,11 @@ public class FileComponentRepository<ComponentType extends IDescribedComponent>
}
@Override
+ public IMap<String, ComponentType> getAll() {
+ return components;
+ }
+
+ @Override
public ComponentType getByName(String name) {
return components.get(name);
}
@@ -117,11 +121,6 @@ public class FileComponentRepository<ComponentType extends IDescribedComponent>
}
@Override
- public IMap<String, ComponentType> getAll() {
- return components;
- }
-
- @Override
public String getSource() {
return "Components read from directory " + sourceDirectory + ".";
}
@@ -141,8 +140,8 @@ public class FileComponentRepository<ComponentType extends IDescribedComponent>
"Component reader read null component");
} else if (!components.containsKey(component.getName())) {
// We only care about the latest version of a component
- ComponentType oldComponent =
- components.put(component.getName(), component);
+ ComponentType oldComponent = components
+ .put(component.getName(), component);
if (oldComponent.getVersion() > component.getVersion()) {
components.put(oldComponent.getName(), oldComponent);
diff --git a/BJC-Utils2/src/main/java/bjc/utils/components/IComponentRepository.java b/BJC-Utils2/src/main/java/bjc/utils/components/IComponentRepository.java
index 2644276..1d322af 100644
--- a/BJC-Utils2/src/main/java/bjc/utils/components/IComponentRepository.java
+++ b/BJC-Utils2/src/main/java/bjc/utils/components/IComponentRepository.java
@@ -14,6 +14,14 @@ import bjc.utils.funcdata.IMap;
*/
public interface IComponentRepository<ComponentType extends IDescribedComponent> {
/**
+ * 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
+ */
+ public IMap<String, ComponentType> getAll();
+
+ /**
* Get a component with a specific name
*
* @param name
@@ -33,14 +41,6 @@ public interface IComponentRepository<ComponentType extends IDescribedComponent>
}
/**
- * 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
- */
- public IMap<String, ComponentType> getAll();
-
- /**
* Get the source from which these components came
*
* @return The source from which these components came