summaryrefslogtreecommitdiff
path: root/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-04-13 18:40:41 -0400
committerBen Culkin <scorpress@gmail.com>2020-04-13 18:40:41 -0400
commitd4ca769e542b2489b1e23cfcbdc3a0b7275b87cd (patch)
tree1653a7399f97fb0c63ce62e3f60fd830d5c37f70 /base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
parent2ac2e31a56ae59ee582e43a90c3495f86dd9ee7a (diff)
Cleanup pass
Cleanup pass to uniformize things
Diffstat (limited to 'base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java')
-rw-r--r--base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java81
1 files changed, 47 insertions, 34 deletions
diff --git a/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java b/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
index ee6e913..87a749e 100644
--- a/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
+++ b/base/src/main/java/bjc/utils/components/ComponentDescriptionFileParser.java
@@ -13,11 +13,12 @@ import bjc.utils.ioutils.RuleBasedConfigReader;
* The file format is based entirely off of pragma statements, and should have
* at least one of each of the following statements
* <ul>
- * <li>pragma name &lt;component-name&rt; </li>
- * <li>pragma author &lt;component-version&rt; </li>
- * <li>pragma description &lt;component-description&rt;</li>
- * <li>pragma version &lt;component-version&rt; </li>
+ * <li>pragma name &lt;component-name&rt;</li>
+ * <li>pragma author &lt;component-version&rt;</li>
+ * <li>pragma description &lt;component-description&rt;</li>
+ * <li>pragma version &lt;component-version&rt;</li>
* </ul>
+ *
* @author ben
*/
public class ComponentDescriptionFileParser {
@@ -27,14 +28,13 @@ public class ComponentDescriptionFileParser {
/* Initialize the reader and its pragmas. */
static {
/*
- * This reader works entirely off of pragmas, so no need to
- * handle rules.
+ * This reader works entirely off of pragmas, so no need to handle rules.
*/
reader = new RuleBasedConfigReader<>((tokenizer, statePair) -> {
/* Don't need to do anything on rule start. */
}, (tokenizer, state) -> {
/* Don't need to do anything on rule continuation. */
- }, (state) -> {
+ }, state -> {
/* Don't need to do anything on rule end. */
});
@@ -46,19 +46,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.
+ * This is valid, because the thing that is returned is the same reference we
+ * passed in.
*/
reader.fromStream(inputSource, state);
@@ -67,14 +67,17 @@ public class ComponentDescriptionFileParser {
/* Create all the pragmas the reader needs to function. */
private static void setupReaderPragmas() {
- reader.addPragma("name", buildStringCollapser("name", (name, state) -> state.setName(name)));
+ reader.addPragma("name",
+ buildStringCollapser("name", (name, state) -> state.setName(name)));
- reader.addPragma("author", buildStringCollapser("author", (author, state) -> state.setAuthor(author)));
+ reader.addPragma("author", buildStringCollapser("author",
+ (author, state) -> state.setAuthor(author)));
reader.addPragma("description", buildStringCollapser("description",
(description, state) -> state.setDescription(description)));
- reader.addPragma("version", buildInteger("version", (version, state) -> state.setVersion(version)));
+ reader.addPragma("version",
+ buildInteger("version", (version, state) -> state.setVersion(version)));
}
private static final class ComponentDescriptionState {
@@ -94,7 +97,7 @@ public class ComponentDescriptionFileParser {
* 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;
@@ -104,7 +107,7 @@ public class ComponentDescriptionFileParser {
* 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;
@@ -114,7 +117,7 @@ public class ComponentDescriptionFileParser {
* 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;
@@ -124,7 +127,7 @@ public class ComponentDescriptionFileParser {
* 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;
@@ -154,25 +157,35 @@ public class ComponentDescriptionFileParser {
@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;
}
@@ -187,19 +200,19 @@ public class ComponentDescriptionFileParser {
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(", ");