Skip to content

Commit

Permalink
Add processor param back to BJSLFileConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
Kale-Ko committed Mar 25, 2023
1 parent c20bb05 commit 8f72000
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.File;
import java.io.IOException;
import io.github.kale_ko.bjsl.parsers.Parser;
import io.github.kale_ko.bjsl.processor.ObjectProcessor;
import io.github.kale_ko.ejcl.file.FileConfig;

/**
Expand Down Expand Up @@ -30,18 +31,39 @@ public class BJSLFileConfig<T> extends FileConfig<T> {
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @param processor
* The ObjectProcessor to use for serialization/deserialization
* @since 2.0.0
*/
public BJSLFileConfig(Class<T> clazz, File file, Parser<?, ?> parser) {
public BJSLFileConfig(Class<T> clazz, File file, Parser<?, ?> parser, ObjectProcessor processor) {
super(clazz, file);

if (parser == null) {
throw new NullPointerException("Parser can not be null");
}
if (processor == null) {
throw new NullPointerException("Processor can not be null");
}

this.parser = parser;
this.processor = processor;
}

/**
* Create a new BJSLConfig
*
* @param clazz
* The class of the data being stored
* @param file
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @since 2.0.0
*/
// public BJSLFileConfig(Class<T> clazz, File file, Parser<?, ?> parser) {d u
// this(clazz, file, parser, new ObjectProcessor.Builder().build());
// }

/**
* Create a blank config file
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import io.github.kale_ko.bjsl.parsers.JsonParser;
import io.github.kale_ko.bjsl.processor.ObjectProcessor;

/**
* A JSON File Config for storing JSON data in a File
Expand All @@ -12,6 +13,23 @@
* @since 1.0.0
*/
public class JsonFileConfig<T> extends BJSLFileConfig<T> {
/**
* Create a new JsonFileConfig
*
* @param clazz
* The class of the data being stored
* @param file
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @param processor
* The ObjectProcessor to use for serialization/deserialization
* @since 2.0.0
*/
public JsonFileConfig(Class<T> clazz, File file, JsonParser parser, ObjectProcessor processor) {
super(clazz, file, parser, processor);
}

/**
* Create a new JsonFileConfig
*
Expand All @@ -24,7 +42,7 @@ public class JsonFileConfig<T> extends BJSLFileConfig<T> {
* @since 2.0.0
*/
public JsonFileConfig(Class<T> clazz, File file, JsonParser parser) {
super(clazz, file, parser);
super(clazz, file, parser, new ObjectProcessor.Builder().build());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import io.github.kale_ko.bjsl.parsers.PropertiesParser;
import io.github.kale_ko.bjsl.processor.ObjectProcessor;

/**
* A Properties File Config for storing Properties data in a File
Expand All @@ -21,10 +22,12 @@ public class PropertiesFileConfig<T> extends BJSLFileConfig<T> {
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @param processor
* The ObjectProcessor to use for serialization/deserialization
* @since 2.0.0
*/
public PropertiesFileConfig(Class<T> clazz, File file, PropertiesParser parser) {
super(clazz, file, parser);
public PropertiesFileConfig(Class<T> clazz, File file, PropertiesParser parser, ObjectProcessor processor) {
super(clazz, file, parser, processor);
}

/**
Expand All @@ -34,9 +37,11 @@ public PropertiesFileConfig(Class<T> clazz, File file, PropertiesParser parser)
* The class of the data being stored
* @param file
* The file where data is being stored
* @since 1.0.0
* @param parser
* The parser/processor to use for parsing and serialization
* @since 2.0.0
*/
public PropertiesFileConfig(Class<T> clazz, File file) {
this(clazz, file, new PropertiesParser.Builder().build());
public PropertiesFileConfig(Class<T> clazz, File file, PropertiesParser parser) {
super(clazz, file, parser, new ObjectProcessor.Builder().build());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import io.github.kale_ko.bjsl.parsers.SmileParser;
import io.github.kale_ko.bjsl.processor.ObjectProcessor;

/**
* A Smile File Config for storing Smile data in a File
Expand All @@ -21,10 +22,12 @@ public class SmileFileConfig<T> extends BJSLFileConfig<T> {
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @param processor
* The ObjectProcessor to use for serialization/deserialization
* @since 2.0.0
*/
public SmileFileConfig(Class<T> clazz, File file, SmileParser parser) {
super(clazz, file, parser);
public SmileFileConfig(Class<T> clazz, File file, SmileParser parser, ObjectProcessor processor) {
super(clazz, file, parser, processor);
}

/**
Expand All @@ -34,9 +37,11 @@ public SmileFileConfig(Class<T> clazz, File file, SmileParser parser) {
* The class of the data being stored
* @param file
* The file where data is being stored
* @since 1.0.0
* @param parser
* The parser/processor to use for parsing and serialization
* @since 2.0.0
*/
public SmileFileConfig(Class<T> clazz, File file) {
this(clazz, file, new SmileParser.Builder().build());
public SmileFileConfig(Class<T> clazz, File file, SmileParser parser) {
super(clazz, file, parser, new ObjectProcessor.Builder().build());
}
}
15 changes: 10 additions & 5 deletions src/main/java/io/github/kale_ko/ejcl/file/bjsl/TomlFileConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import io.github.kale_ko.bjsl.parsers.TomlParser;
import io.github.kale_ko.bjsl.processor.ObjectProcessor;

/**
* A TOML File Config for storing TOML data in a File
Expand All @@ -21,10 +22,12 @@ public class TomlFileConfig<T> extends BJSLFileConfig<T> {
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @param processor
* The ObjectProcessor to use for serialization/deserialization
* @since 2.0.0
*/
public TomlFileConfig(Class<T> clazz, File file, TomlParser parser) {
super(clazz, file, parser);
public TomlFileConfig(Class<T> clazz, File file, TomlParser parser, ObjectProcessor processor) {
super(clazz, file, parser, processor);
}

/**
Expand All @@ -34,9 +37,11 @@ public TomlFileConfig(Class<T> clazz, File file, TomlParser parser) {
* The class of the data being stored
* @param file
* The file where data is being stored
* @since 1.0.0
* @param parser
* The parser/processor to use for parsing and serialization
* @since 2.0.0
*/
public TomlFileConfig(Class<T> clazz, File file) {
this(clazz, file, new TomlParser.Builder().build());
public TomlFileConfig(Class<T> clazz, File file, TomlParser parser) {
super(clazz, file, parser, new ObjectProcessor.Builder().build());
}
}
15 changes: 10 additions & 5 deletions src/main/java/io/github/kale_ko/ejcl/file/bjsl/XmlFileConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import io.github.kale_ko.bjsl.parsers.XmlParser;
import io.github.kale_ko.bjsl.processor.ObjectProcessor;

/**
* A XML File Config for storing XML data in a File
Expand All @@ -21,10 +22,12 @@ public class XmlFileConfig<T> extends BJSLFileConfig<T> {
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @param processor
* The ObjectProcessor to use for serialization/deserialization
* @since 2.0.0
*/
public XmlFileConfig(Class<T> clazz, File file, XmlParser parser) {
super(clazz, file, parser);
public XmlFileConfig(Class<T> clazz, File file, XmlParser parser, ObjectProcessor processor) {
super(clazz, file, parser, processor);
}

/**
Expand All @@ -34,9 +37,11 @@ public XmlFileConfig(Class<T> clazz, File file, XmlParser parser) {
* The class of the data being stored
* @param file
* The file where data is being stored
* @since 1.0.0
* @param parser
* The parser/processor to use for parsing and serialization
* @since 2.0.0
*/
public XmlFileConfig(Class<T> clazz, File file) {
this(clazz, file, new XmlParser.Builder().setPrettyPrint(true).build());
public XmlFileConfig(Class<T> clazz, File file, XmlParser parser) {
super(clazz, file, parser, new ObjectProcessor.Builder().build());
}
}
15 changes: 10 additions & 5 deletions src/main/java/io/github/kale_ko/ejcl/file/bjsl/YamlFileConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import io.github.kale_ko.bjsl.parsers.YamlParser;
import io.github.kale_ko.bjsl.processor.ObjectProcessor;

/**
* A YAML File Config for storing YAML data in a File
Expand All @@ -21,10 +22,12 @@ public class YamlFileConfig<T> extends BJSLFileConfig<T> {
* The file where data is being stored
* @param parser
* The parser/processor to use for parsing and serialization
* @param processor
* The ObjectProcessor to use for serialization/deserialization
* @since 2.0.0
*/
public YamlFileConfig(Class<T> clazz, File file, YamlParser parser) {
super(clazz, file, parser);
public YamlFileConfig(Class<T> clazz, File file, YamlParser parser, ObjectProcessor processor) {
super(clazz, file, parser, processor);
}

/**
Expand All @@ -34,9 +37,11 @@ public YamlFileConfig(Class<T> clazz, File file, YamlParser parser) {
* The class of the data being stored
* @param file
* The file where data is being stored
* @since 1.0.0
* @param parser
* The parser/processor to use for parsing and serialization
* @since 2.0.0
*/
public YamlFileConfig(Class<T> clazz, File file) {
this(clazz, file, new YamlParser.Builder().build());
public YamlFileConfig(Class<T> clazz, File file, YamlParser parser) {
super(clazz, file, parser, new ObjectProcessor.Builder().build());
}
}

0 comments on commit 8f72000

Please sign in to comment.