columnValues = new TreeSet<>();
+
+ for (int i = 0; i < columns.length; i++) {
+ int columnNumber = i + 1;
+ ColumnValue columnValue = newColumnValue(readerConfig, columnNumber, columns[i]);
+ columnValues.add(columnValue);
+ }
+
+ return newLineValue(++lineNumber, contentCurrentLine, columnValues);
+ }
+
+ private void setCurrentLine() {
+ if (lastLineFromReader == null) {
+ try {
+ lastLineFromReader = bufferedReader.readLine();
+ } catch (IOException e) {
+ throw new IllegalStateException(e);
+ }
+ }
+ }
+
+ private String getContentCurrentLine() {
+ String currentLine = lastLineFromReader;
+ lastLineFromReader = null;
+
+ if (currentLine == null) {
+ throw new NoSuchElementException("No more lines to read.");
+ }
+
+ return currentLine;
+ }
+
+ }
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderFactory.java b/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderFactory.java
index fa80297..4c37883 100644
--- a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderFactory.java
+++ b/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderFactory.java
@@ -1,39 +1,163 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
package com.jonpereiradev.jfile.reader;
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Objects;
+import java.util.regex.Pattern;
+
/**
- * Factory to create the {@link JFileReader} implementation.
+ * Factory to produces {@link JFileReader} and {@link JFileReaderConfig} objects to configure and read files.
+ *
+ * @author jonpereiradev
+ * @see JFileReader
+ * @see JFileReaderConfig
+ * @since 0.1.0
*/
public final class JFileReaderFactory {
private JFileReaderFactory() {
- throw new UnsupportedOperationException();
+ throw new UnsupportedOperationException("Instantiation not supported");
+ }
+
+ /**
+ * Creates a {@link JFileReader} object configured with file and regex split pattern.
+ *
+ * @param file the file instance used to create the {@link InputStream}.
+ * @param regex the pattern used to split a line into columns.
+ *
+ * @return a {@link JFileReader} object configured for file reading.
+ *
+ * @throws IOException if a problem occurs when creating {@link InputStream} for the file.
+ */
+ public static JFileReader newUtf8JFileReader(File file, String regex) throws IOException {
+ return newUtf8JFileReader(file.toPath(), regex);
+ }
+
+ /**
+ * Creates a {@link JFileReader} object configured with file and configuration.
+ *
+ * @param file the file instance used to create the {@link InputStream}.
+ * @param readerConfig the configuration for reading the file.
+ *
+ * @return a {@link JFileReader} object configured for file reading.
+ *
+ * @throws IOException if a problem occurs when creating {@link InputStream} for the file.
+ */
+ public static JFileReader newJFileReader(File file, JFileReaderConfig readerConfig) throws IOException {
+ return newJFileReader(file.toPath(), readerConfig);
+ }
+
+ /**
+ * Creates a {@link JFileReader} object configured with file and configuration.
+ *
+ * @param path the path used to create the {@link InputStream}.
+ * @param regex the pattern used to split a line into columns.
+ *
+ * @return a {@link JFileReader} object configured for file reading.
+ *
+ * @throws IOException if a problem occurs when creating {@link InputStream} for the path.
+ */
+ public static JFileReader newUtf8JFileReader(Path path, String regex) throws IOException {
+ return newUtf8JFileReader(Files.newInputStream(path), regex);
+ }
+
+ /**
+ * Creates a {@link JFileReader} object configured with file and configuration.
+ *
+ * @param path the path used to create the {@link InputStream}.
+ * @param readerConfig the configuration for reading the file.
+ *
+ * @return a {@link JFileReader} object configured for file reading.
+ *
+ * @throws IOException if a problem occurs when creating {@link InputStream} for the path.
+ */
+ public static JFileReader newJFileReader(Path path, JFileReaderConfig readerConfig) throws IOException {
+ return newJFileReader(Files.newInputStream(path), readerConfig);
+ }
+
+ /**
+ * Creates a {@link JFileReader} object configured with file and configuration.
+ *
+ * @param inputStream the stream to read the file content.
+ * @param regex the pattern used to split a line into columns.
+ *
+ * @return a {@link JFileReader} object configured for file reading.
+ *
+ * @throws IOException if a problem occurs when creating {@link InputStream} for the path.
+ */
+ public static JFileReader newUtf8JFileReader(InputStream inputStream, String regex) throws IOException {
+ return newJFileReader(inputStream, newUtf8ReaderConfig(regex));
}
- public static JFileReader newInstance(File file, ReaderConfiguration configuration) {
- return newInstance(file.toPath(), configuration);
+ /**
+ * Creates a {@link JFileReader} object configured with file and configuration.
+ *
+ * @param inputStream the file instance to creates the stream.
+ * @param readerConfig the configuration for reading the file.
+ *
+ * @return a {@link JFileReader} object configured for file reading.
+ *
+ * @throws IOException if a problem occurs when validating the {@link InputStream}.
+ */
+ public static JFileReader newJFileReader(
+ InputStream inputStream,
+ JFileReaderConfig readerConfig) throws IOException {
+ Objects.requireNonNull(inputStream, "InputStream is required");
+ Objects.requireNonNull(readerConfig, "JFileReaderConfig is required");
+ return JFileReaderEngine.newInstance(inputStream, readerConfig);
}
- public static JFileReader newInstance(Path path, ReaderConfiguration configuration) {
- try {
- return newInstance(Files.newInputStream(path), configuration);
- } catch (IOException e) {
- throw new IllegalArgumentException(e);
- }
+ /**
+ * Creates a {@link JFileReaderConfig} object configured with UTF-8 encoding.
+ *
+ * @param regex the pattern used to split a line into columns.
+ *
+ * @return a {@link JFileReaderConfig} object configured with UTF-8 encoding.
+ */
+ public static JFileReaderConfig newUtf8ReaderConfig(String regex) {
+ return newReaderConfig(regex, StandardCharsets.UTF_8);
}
- public static JFileReader newInstance(InputStream inputStream, ReaderConfiguration configuration) {
- Objects.requireNonNull(inputStream, "InputStream is required.");
- JFileReaderContext context = new JFileReaderContext(inputStream, configuration);
- return new JFileReaderImpl(context);
+ /**
+ * Creates a {@link JFileReaderConfig} object configured with regex and charset.
+ *
+ * @param regex the pattern used to split a line into columns.
+ * @param charset the encode of the file content.
+ *
+ * @return a {@link JFileReaderConfig} object.
+ */
+ public static JFileReaderConfig newReaderConfig(String regex, Charset charset) {
+ return new JFileReaderConfigImpl(Pattern.compile(regex), charset);
}
}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderImpl.java
deleted file mode 100644
index a81fe05..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderImpl.java
+++ /dev/null
@@ -1,115 +0,0 @@
-package com.jonpereiradev.jfile.reader;
-
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.rule.RuleViolation;
-import com.jonpereiradev.jfile.reader.stream.StreamReader;
-import com.jonpereiradev.jfile.reader.validation.JFileValidatorEngine;
-import com.jonpereiradev.jfile.reader.validation.Report;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Objects;
-
-final class JFileReaderImpl implements JFileReader {
-
- private final JFileReaderContext context;
- private final StreamReader streamReader;
-
- private JFileReaderIterator iterator;
-
- JFileReaderImpl(JFileReaderContext context) {
- this.context = context;
- this.streamReader = context.getStreamReader();
- }
-
- @Override
- public JFileReaderIterator iterator() {
- if (iterator == null) {
- iterator = new JFileReaderIteratorImpl(context, streamReader);
- }
-
- return iterator;
- }
-
- @Override
- public Report validate() {
- Objects.requireNonNull(context.getRuleConfiguration(), "No rule configuration provided.");
-
- if (iterator != null) {
- throw new IllegalStateException("Iterator already initialized. You can't use this method after called iterator().");
- }
-
- List lines = new ArrayList<>();
- Report report = Report.defaultReport();
- int maxViolationSize = context.getReaderConfiguration().getMaxViolationSize();
- JFileReaderIterator iterator = iterator();
-
- while (iterator.hasNext()) {
- JFileLine line = iterator.next();
- List violations = validateLine(line);
-
- report.put(line.getRow(), violations);
- lines.add(line);
-
- if (maxViolationSize > 0 && report.getViolations().size() > maxViolationSize) {
- break;
- }
- }
-
- this.iterator = new InMemoryJFileReaderIterator(lines);
-
- return report;
- }
-
- @Override
- public Report validate(JFileLine line) {
- Report report = Report.defaultReport();
- List violations = validateLine(line);
-
- report.put(line.getRow(), violations);
-
- return report;
- }
-
- private List validateLine(JFileLine line) {
- Objects.requireNonNull(context.getRuleConfiguration(), "No rule configuration provided.");
-
- if (line == null) {
- throw new IllegalStateException("No line selected in the iterator.");
- }
-
- return JFileValidatorEngine.defaultEngine(context).validate(line);
- }
-
- @Override
- public T parse(JFileLine line, Class toClass) {
- return context.getFileLineParser().parse(line, toClass);
- }
-
- @Override
- public void close() throws IOException {
- streamReader.close();
- }
-
- private class InMemoryJFileReaderIterator implements JFileReaderIterator {
-
- private final List lines;
-
- private int index = 0;
-
- private InMemoryJFileReaderIterator(List lines) {
- this.lines = lines;
- }
-
- @Override
- public boolean hasNext() {
- return index < lines.size();
- }
-
- @Override
- public JFileLine next() {
- return lines.get(index++);
- }
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderIterator.java b/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderIterator.java
deleted file mode 100644
index d57e3b3..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderIterator.java
+++ /dev/null
@@ -1,12 +0,0 @@
-package com.jonpereiradev.jfile.reader;
-
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-
-import java.util.Iterator;
-
-/**
- * Iterator for read and validate the line of a file.
- */
-public interface JFileReaderIterator extends Iterator {
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderIteratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderIteratorImpl.java
deleted file mode 100644
index 2b301ae..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/JFileReaderIteratorImpl.java
+++ /dev/null
@@ -1,41 +0,0 @@
-package com.jonpereiradev.jfile.reader;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.stream.StreamReader;
-
-import java.util.Iterator;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-final class JFileReaderIteratorImpl implements JFileReaderIterator {
-
- private final JFileReaderContext context;
- private final Iterator iterator;
-
- private int row;
-
- JFileReaderIteratorImpl(JFileReaderContext context, StreamReader streamReader) {
- this.context = context;
- this.iterator = streamReader.iterator();
- }
-
- @Override
- public boolean hasNext() {
- return iterator.hasNext();
- }
-
- @Override
- public JFileLine next() {
- String content = iterator.next();
- String[] columns = context.getPattern().split(content);
-
- SortedSet fileColumns = new TreeSet<>();
-
- for (int i = 0; i < columns.length; i++) {
- fileColumns.add(new JFileColumn(context, i + 1, columns[i]));
- }
-
- return new JFileLine(++row, content, fileColumns);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/configuration/ReaderConfiguration.java b/src/main/java/com/jonpereiradev/jfile/reader/configuration/ReaderConfiguration.java
deleted file mode 100644
index 471fa47..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/configuration/ReaderConfiguration.java
+++ /dev/null
@@ -1,110 +0,0 @@
-package com.jonpereiradev.jfile.reader.configuration;
-
-import com.jonpereiradev.jfile.reader.parser.FileLineParser;
-import com.jonpereiradev.jfile.reader.rule.RuleConfiguration;
-import com.jonpereiradev.jfile.reader.stream.StreamReader;
-
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.nio.charset.StandardCharsets;
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.time.format.DateTimeFormatter;
-import java.util.function.Function;
-import java.util.regex.Pattern;
-
-public interface ReaderConfiguration {
-
- static ReaderConfiguration utf8Reader(String regex) {
- return new ReaderConfigurationImpl(Pattern.compile(regex), StandardCharsets.UTF_8);
- }
-
- static ReaderConfiguration reader(String regex, Charset charset) {
- return new ReaderConfigurationImpl(Pattern.compile(regex), charset);
- }
-
- /**
- * Configure the default {@link java.util.Date} string formatter.
- */
- ReaderConfiguration withDateFormatter(DateFormat dateFormatter);
-
- /**
- * Configure the default {@link java.time.LocalDate} string formatter.
- */
- ReaderConfiguration withLocalDateFormatter(DateTimeFormatter localDateFormatter);
-
- /**
- * Configure the default {@link java.time.LocalDateTime} string formatter.
- */
- ReaderConfiguration withLocalDateTimeFormatter(DateTimeFormatter localDateTimeFormatter);
-
- /**
- * Configure the default {@link java.math.BigDecimal} string formatter.
- */
- ReaderConfiguration withBigDecimalFormat(DecimalFormat decimalFormat);
-
- /**
- * Configure the rules of validation.
- */
- ReaderConfiguration withRuleConfiguration(RuleConfiguration ruleConfiguration);
-
- /**
- * Configure the {@link StreamReader} to parse the file.
- */
- ReaderConfiguration withStreamReader(Function streamReader);
-
- /**
- * Configure the max violation size for lines.
- */
- ReaderConfiguration withMaxViolationSize(int maxViolationSize);
-
- /**
- * @return the pattern to split the line in columns.
- */
- Pattern getPattern();
-
- /**
- * @return the charset to read the bytes as string.
- */
- Charset getCharset();
-
- /**
- * @return the date formatter for {@link java.util.Date}
- */
- DateFormat getDateFormat();
-
- /**
- * @return the local date formatter for {@link java.time.LocalDate}
- */
- DateTimeFormatter getLocalDateFormatter();
-
- /**
- * @return the local date time formatter for {@link java.time.LocalDateTime}
- */
- DateTimeFormatter getLocalDateTimeFormatter();
-
- /**
- * @return the big decimal formatter for {@link java.math.BigDecimal}
- */
- DecimalFormat getBigDecimalFormatter();
-
- /**
- * @return the rules configuration for this reader.
- */
- RuleConfiguration getRuleConfiguration();
-
- /**
- * @return the responsible stream reader to read the file content.
- */
- Function super InputStream, ? extends StreamReader> getStreamReader();
-
- /**
- * @return the parser responsible to convert a line into an object.
- */
- FileLineParser getFileLineParser();
-
- /**
- * @return the max lines violation size.
- */
- int getMaxViolationSize();
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/configuration/ReaderConfigurationImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/configuration/ReaderConfigurationImpl.java
deleted file mode 100644
index c9f191b..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/configuration/ReaderConfigurationImpl.java
+++ /dev/null
@@ -1,132 +0,0 @@
-package com.jonpereiradev.jfile.reader.configuration;
-
-import com.jonpereiradev.jfile.reader.parser.FileLineParser;
-import com.jonpereiradev.jfile.reader.rule.RuleConfiguration;
-import com.jonpereiradev.jfile.reader.stream.StreamReader;
-
-import java.io.InputStream;
-import java.nio.charset.Charset;
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.time.format.DateTimeFormatter;
-import java.util.function.Function;
-import java.util.regex.Pattern;
-
-final class ReaderConfigurationImpl implements ReaderConfiguration {
-
- private final Pattern pattern;
- private final Charset charset;
- private final FileLineParser fileLineParser;
-
- private DateFormat dateFormat;
- private DateTimeFormatter localDateFormatter;
- private DateTimeFormatter localDateTimeFormatter;
- private DecimalFormat bigDecimalFormatter;
- private RuleConfiguration ruleConfiguration;
- private Function streamReader;
- private int maxViolationSize = -1;
-
- ReaderConfigurationImpl(Pattern pattern, Charset charset) {
- this.pattern = pattern;
- this.charset = charset;
- this.fileLineParser = FileLineParser.defaultParser(this);
- this.dateFormat = DateFormat.getInstance();
- this.localDateFormatter = DateTimeFormatter.ISO_LOCAL_DATE;
- this.localDateTimeFormatter = DateTimeFormatter.ISO_LOCAL_DATE_TIME;
- this.bigDecimalFormatter = new DecimalFormat();
- this.bigDecimalFormatter.setParseBigDecimal(true);
- this.streamReader = inputStream -> StreamReader.defaultStreamReader(inputStream, charset);
- }
-
- @Override
- public ReaderConfiguration withDateFormatter(DateFormat dateFormat) {
- this.dateFormat = dateFormat;
- return this;
- }
-
- @Override
- public ReaderConfiguration withLocalDateFormatter(DateTimeFormatter localDateFormatter) {
- this.localDateFormatter = localDateFormatter;
- return this;
- }
-
- @Override
- public ReaderConfiguration withLocalDateTimeFormatter(DateTimeFormatter localDateTimeFormatter) {
- this.localDateTimeFormatter = localDateTimeFormatter;
- return this;
- }
-
- @Override
- public ReaderConfiguration withBigDecimalFormat(DecimalFormat decimalFormat) {
- this.bigDecimalFormatter = decimalFormat;
- return this;
- }
-
- @Override
- public ReaderConfiguration withRuleConfiguration(RuleConfiguration ruleConfiguration) {
- this.ruleConfiguration = ruleConfiguration;
- return this;
- }
-
- @Override
- public ReaderConfiguration withStreamReader(Function streamReader) {
- this.streamReader = streamReader;
- return this;
- }
-
- @Override
- public ReaderConfiguration withMaxViolationSize(int maxViolationSize) {
- this.maxViolationSize = maxViolationSize;
- return this;
- }
-
- @Override
- public Pattern getPattern() {
- return pattern;
- }
-
- @Override
- public Charset getCharset() {
- return charset;
- }
-
- @Override
- public DateFormat getDateFormat() {
- return dateFormat;
- }
-
- @Override
- public DateTimeFormatter getLocalDateFormatter() {
- return localDateFormatter;
- }
-
- @Override
- public DateTimeFormatter getLocalDateTimeFormatter() {
- return localDateTimeFormatter;
- }
-
- @Override
- public DecimalFormat getBigDecimalFormatter() {
- return bigDecimalFormatter;
- }
-
- @Override
- public RuleConfiguration getRuleConfiguration() {
- return ruleConfiguration;
- }
-
- @Override
- public Function super InputStream, ? extends StreamReader> getStreamReader() {
- return streamReader;
- }
-
- @Override
- public FileLineParser getFileLineParser() {
- return fileLineParser;
- }
-
- @Override
- public int getMaxViolationSize() {
- return maxViolationSize;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/converter/DateTimeFormatter.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/DateTimeFormatter.java
new file mode 100644
index 0000000..6c5b7fe
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/DateTimeFormatter.java
@@ -0,0 +1,43 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * @author jonpereiradev
+ * @since 0.1.0
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface DateTimeFormatter {
+
+ String value();
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/converter/DecimalFormatter.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/DecimalFormatter.java
new file mode 100644
index 0000000..b894c39
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/DecimalFormatter.java
@@ -0,0 +1,47 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * @author jonpereiradev
+ * @since 0.1.0
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface DecimalFormatter {
+
+ String value();
+
+ char groupingSeparator() default '.';
+
+ char decimalSeparator() default ',';
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/converter/FileColumn.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/FileColumn.java
new file mode 100644
index 0000000..1f132fb
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/FileColumn.java
@@ -0,0 +1,43 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
+
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * @author jonpereiradev
+ * @since 0.1.0
+ */
+@Target(ElementType.FIELD)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface FileColumn {
+
+ int value();
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/converter/GetterSetterPair.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/GetterSetterPair.java
new file mode 100644
index 0000000..5f47c89
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/GetterSetterPair.java
@@ -0,0 +1,78 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
+
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+
+
+/**
+ * @author jonpereiradev
+ * @since 0.1.0
+ */
+final class GetterSetterPair {
+
+ private Field field;
+ private Method getter;
+ private Method setter;
+ private FileColumn annotation;
+
+ Field getField() {
+ return field;
+ }
+
+ void setField(Field field) {
+ this.field = field;
+ }
+
+ Method getGetter() {
+ return getter;
+ }
+
+ void setGetter(Method getter) {
+ this.getter = getter;
+ }
+
+ Method getSetter() {
+ return setter;
+ }
+
+ void setSetter(Method setter) {
+ this.setter = setter;
+ }
+
+ FileColumn getAnnotation() {
+ return annotation;
+ }
+
+ void setAnnotation(FileColumn annotation) {
+ this.annotation = annotation;
+ }
+
+ boolean hasGetterAndSetter() {
+ return getter != null && setter != null;
+ }
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/converter/LineValueConverter.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/LineValueConverter.java
new file mode 100644
index 0000000..dc50d6f
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/LineValueConverter.java
@@ -0,0 +1,38 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
+
+
+import com.jonpereiradev.jfile.reader.file.LineValue;
+
+
+/**
+ * @author jonpereiradev
+ * @since 0.1.0
+ */
+public interface LineValueConverter {
+
+ T convert(LineValue lineValue, Class classType);
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionLineValueConverter.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionLineValueConverter.java
new file mode 100644
index 0000000..937fcf2
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionLineValueConverter.java
@@ -0,0 +1,89 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
+
+
+import com.jonpereiradev.jfile.reader.JFileReaderConfig;
+import com.jonpereiradev.jfile.reader.file.LineValue;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public final class ReflectionLineValueConverter implements LineValueConverter {
+
+ private static final Map, Map> CACHE_CLASS_REFLECTIONS = new HashMap<>();
+
+ private final JFileReaderConfig readerConfig;
+
+ public ReflectionLineValueConverter(JFileReaderConfig readerConfig) {
+ this.readerConfig = readerConfig;
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T convert(LineValue lineValue, Class classType) {
+ if (classType.isAssignableFrom(String.class)) {
+ return (T) lineValue.getContent();
+ }
+
+ if (classType.equals(LineValue.class)) {
+ return (T) lineValue;
+ }
+
+ return convertLineValueToObject(lineValue, classType);
+ }
+
+ private T convertLineValueToObject(LineValue lineValue, Class classType) {
+ T object = newInstance(classType);
+ Map pair = getGetterSetterPair(classType);
+ ReflectionObjectWriter reflectionObjectWriter = new ReflectionObjectWriter(readerConfig);
+
+ lineValue.getColumnValues().forEach(o -> {
+ if (pair.containsKey(o.getColumnNumber())) {
+ reflectionObjectWriter.write(object, o, pair.get(o.getColumnNumber()));
+ }
+ });
+
+ return object;
+ }
+
+ private Map getGetterSetterPair(Class clazz) {
+ if (!CACHE_CLASS_REFLECTIONS.containsKey(clazz)) {
+ ReflectionObjectReader reflectionObjectReader = new ReflectionObjectReader();
+ CACHE_CLASS_REFLECTIONS.put(clazz, reflectionObjectReader.read(clazz));
+ }
+
+ return CACHE_CLASS_REFLECTIONS.get(clazz);
+ }
+
+ private T newInstance(Class clazz) {
+ try {
+ return clazz.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ throw new IllegalArgumentException(e);
+ }
+ }
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/ObjectReader.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionObjectReader.java
similarity index 71%
rename from src/main/java/com/jonpereiradev/jfile/reader/parser/ObjectReader.java
rename to src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionObjectReader.java
index 5c83895..ace6c26 100644
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/ObjectReader.java
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionObjectReader.java
@@ -1,4 +1,27 @@
-package com.jonpereiradev.jfile.reader.parser;
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
import java.lang.reflect.Field;
@@ -10,7 +33,7 @@
import java.util.function.Consumer;
-final class ObjectReader {
+final class ReflectionObjectReader {
private static final String PREFIX_GETTER_METHOD = "get";
private static final String PREFIX_SETTER_METHOD = "set";
@@ -18,7 +41,7 @@ final class ObjectReader {
private Map getterSetterMapping;
- public Map read(Class> clazz) {
+ Map read(Class> clazz) {
getterSetterMapping = new TreeMap<>();
for (final Method method : clazz.getMethods()) {
@@ -82,4 +105,5 @@ private boolean isJavaBeanSetterMethod(Method method) {
private boolean isJavaBeanBooleanGetterMethod(Method method) {
return method.getName().startsWith(PREFIX_IS_METHOD) && method.getParameters().length == 0;
}
+
}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionObjectWriter.java b/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionObjectWriter.java
new file mode 100644
index 0000000..72d22ff
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/converter/ReflectionObjectWriter.java
@@ -0,0 +1,131 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.converter;
+
+
+import com.jonpereiradev.jfile.reader.JFileReaderConfig;
+import com.jonpereiradev.jfile.reader.file.ColumnValue;
+
+import java.lang.reflect.AccessibleObject;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.math.BigDecimal;
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+
+
+final class ReflectionObjectWriter {
+
+ private final JFileReaderConfig readerConfig;
+
+ ReflectionObjectWriter(JFileReaderConfig readerConfig) {
+ this.readerConfig = readerConfig;
+ }
+
+ void write(Object instance, ColumnValue columnValue, GetterSetterPair getterSetterPair) {
+ try {
+ writeOnInstance(instance, columnValue, getterSetterPair);
+ } catch (IllegalAccessException | InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void writeOnInstance(Object instance, ColumnValue columnValue, GetterSetterPair getterSetterPair)
+ throws IllegalAccessException, InvocationTargetException {
+ if (getterSetterPair.hasGetterAndSetter()) {
+ Class> parameterType = getterSetterPair.getSetter().getParameterTypes()[0];
+ Object newObject = createObject(columnValue, getterSetterPair.getField(), parameterType);
+
+ getterSetterPair.getSetter().invoke(instance, newObject);
+ } else if (getterSetterPair.getGetter() != null) {
+ Field field = getterSetterPair.getField();
+ Object newObject = createObject(columnValue, field, getterSetterPair.getGetter().getReturnType());
+
+ AccessibleObject.setAccessible(new Field[]{field}, true);
+ field.set(instance, newObject);
+ AccessibleObject.setAccessible(new Field[]{field}, false);
+ }
+ }
+
+ private Object createObject(ColumnValue columnValue, Field field, Class> classType) {
+ if (classType == BigDecimal.class) {
+ return createBigDecimalObject(columnValue, field);
+ }
+
+ if (classType == LocalDate.class) {
+ return createLocalDateObject(columnValue, field);
+ }
+
+ if (classType == LocalDateTime.class) {
+ return createLocalDateTimeObject(columnValue, field);
+ }
+
+ return columnValue.getContent(classType);
+ }
+
+ private BigDecimal createBigDecimalObject(ColumnValue columnValue, Field field) {
+ DecimalFormat numberFormatter = readerConfig.getBigDecimalFormatter();
+
+ if (field.isAnnotationPresent(DecimalFormatter.class)) {
+ DecimalFormatter annotation = field.getAnnotation(DecimalFormatter.class);
+ DecimalFormat format = new DecimalFormat(annotation.value());
+ DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
+
+ symbols.setDecimalSeparator(annotation.decimalSeparator());
+ symbols.setGroupingSeparator(annotation.groupingSeparator());
+
+ format.setDecimalFormatSymbols(symbols);
+ format.setParseBigDecimal(true);
+
+ numberFormatter = format;
+ }
+
+ return columnValue.getBigDecimal(numberFormatter);
+ }
+
+ private LocalDate createLocalDateObject(ColumnValue columnValue, Field field) {
+ java.time.format.DateTimeFormatter formatter = readerConfig.getLocalDateFormatter();
+
+ if (field.isAnnotationPresent(DateTimeFormatter.class)) {
+ DateTimeFormatter annotation = field.getAnnotation(DateTimeFormatter.class);
+ formatter = java.time.format.DateTimeFormatter.ofPattern(annotation.value());
+ }
+
+ return columnValue.getLocalDate(formatter);
+ }
+
+ private LocalDateTime createLocalDateTimeObject(ColumnValue columnValue, Field field) {
+ java.time.format.DateTimeFormatter formatter = readerConfig.getLocalDateTimeFormatter();
+
+ if (field.isAnnotationPresent(DateTimeFormatter.class)) {
+ DateTimeFormatter annotation = field.getAnnotation(DateTimeFormatter.class);
+ formatter = java.time.format.DateTimeFormatter.ofPattern(annotation.value());
+ }
+
+ return columnValue.getLocalDateTime(formatter);
+ }
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/file/ColumnValue.java b/src/main/java/com/jonpereiradev/jfile/reader/file/ColumnValue.java
new file mode 100644
index 0000000..3e0da7a
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/file/ColumnValue.java
@@ -0,0 +1,150 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.file;
+
+
+import com.jonpereiradev.jfile.reader.JFilePatternConfig;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Date;
+import java.util.regex.Pattern;
+
+
+/**
+ * @author jonpereiradev
+ * @since 0.1.0
+ */
+public interface ColumnValue extends Comparable {
+
+ static ColumnValue newColumnValue(JFilePatternConfig patternConfig, int columnNumber, String content) {
+ return new ColumnValueImpl(patternConfig, columnNumber, content);
+ }
+
+ int getColumnNumber();
+
+ T getContent(Class clazz);
+
+ String getText();
+
+ String[] getTextArray();
+
+ String[] getTextArray(Pattern splitPattern);
+
+ Character getCharacter();
+
+ Character[] getCharacterArray();
+
+ Character[] getCharacterArray(Pattern splitPattern);
+
+ Short getShort();
+
+ Short[] getShortArray();
+
+ Short[] getShortArray(Pattern splitPattern);
+
+ Integer getInt();
+
+ Integer[] getIntArray();
+
+ Integer[] getIntArray(Pattern splitPattern);
+
+ Long getLong();
+
+ Long[] getLongArray();
+
+ Long[] getLongArray(Pattern splitPattern);
+
+ Float getFloat();
+
+ Float[] getFloatArray();
+
+ Float[] getFloatArray(Pattern splitPattern);
+
+ Double getDouble();
+
+ Double[] getDoubleArray();
+
+ Double[] getDoubleArray(Pattern splitPattern);
+
+ Boolean getBoolean();
+
+ Boolean[] getBooleanArray();
+
+ Boolean[] getBooleanArray(Pattern splitPattern);
+
+ BigInteger getBigInteger();
+
+ BigInteger[] getBigIntegerArray();
+
+ BigInteger[] getBigIntegerArray(Pattern splitPattern);
+
+ BigDecimal getBigDecimal();
+
+ BigDecimal getBigDecimal(DecimalFormat bigDecimalFormatter);
+
+ BigDecimal[] getBigDecimalArray();
+
+ BigDecimal[] getBigDecimalArray(Pattern splitPattern);
+
+ BigDecimal[] getBigDecimalArray(Pattern splitPattern, DecimalFormat bigDecimalFormatter);
+
+ Date getDate();
+
+ Date getDate(DateFormat dateFormat);
+
+ Date[] getDateArray();
+
+ Date[] getDateArray(Pattern splitPattern);
+
+ Date[] getDateArray(Pattern splitPattern, DateFormat dateFormat);
+
+ LocalDate getLocalDate();
+
+ LocalDate getLocalDate(DateTimeFormatter dateTimeFormatter);
+
+ LocalDate[] getLocalDateArray();
+
+ LocalDate[] getLocalDateArray(Pattern splitPattern);
+
+ LocalDate[] getLocalDateArray(Pattern splitPattern, DateTimeFormatter dateTimeFormatter);
+
+ LocalDateTime getLocalDateTime();
+
+ LocalDateTime getLocalDateTime(DateTimeFormatter dateTimeFormatter);
+
+ LocalDateTime[] getLocalDateTimeArray();
+
+ LocalDateTime[] getLocalDateTimeArray(Pattern splitPattern);
+
+ LocalDateTime[] getLocalDateTimeArray(Pattern splitPattern, DateTimeFormatter dateTimeFormatter);
+
+ JFilePatternConfig getPatternConfig();
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/file/ColumnValueImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/file/ColumnValueImpl.java
new file mode 100644
index 0000000..03538ca
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/file/ColumnValueImpl.java
@@ -0,0 +1,476 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.file;
+
+
+import com.jonpereiradev.jfile.reader.JFilePatternConfig;
+import com.jonpereiradev.jfile.reader.validator.rule.RuleUtils;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.Objects;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+import java.util.function.Function;
+import java.util.regex.Pattern;
+
+
+final class ColumnValueImpl implements ColumnValue {
+
+ private static final Pattern DEFAULT_ARRAY_SEPARATOR = Pattern.compile(",\\s*");
+ private static final ConcurrentMap, Function> MAPPER = new ConcurrentHashMap<>();
+
+ static {
+ MAPPER.putIfAbsent(char.class, ColumnValueImpl::getCharacter);
+ MAPPER.putIfAbsent(Character.class, ColumnValueImpl::getCharacter);
+ MAPPER.putIfAbsent(String.class, ColumnValueImpl::getText);
+ MAPPER.putIfAbsent(short.class, ColumnValueImpl::getShort);
+ MAPPER.putIfAbsent(Short.class, ColumnValueImpl::getShort);
+ MAPPER.putIfAbsent(int.class, ColumnValueImpl::getInt);
+ MAPPER.putIfAbsent(Integer.class, ColumnValueImpl::getInt);
+ MAPPER.putIfAbsent(long.class, ColumnValueImpl::getLong);
+ MAPPER.putIfAbsent(Long.class, ColumnValueImpl::getLong);
+ MAPPER.putIfAbsent(float.class, ColumnValueImpl::getFloat);
+ MAPPER.putIfAbsent(Float.class, ColumnValueImpl::getFloat);
+ MAPPER.putIfAbsent(double.class, ColumnValueImpl::getDouble);
+ MAPPER.putIfAbsent(Double.class, ColumnValueImpl::getDouble);
+ MAPPER.putIfAbsent(boolean.class, ColumnValueImpl::getBoolean);
+ MAPPER.putIfAbsent(Boolean.class, ColumnValueImpl::getBoolean);
+ MAPPER.putIfAbsent(BigInteger.class, ColumnValueImpl::getBigInteger);
+ MAPPER.putIfAbsent(BigDecimal.class, ColumnValueImpl::getBigDecimal);
+ MAPPER.putIfAbsent(Date.class, ColumnValueImpl::getDate);
+ MAPPER.putIfAbsent(LocalDate.class, ColumnValueImpl::getLocalDate);
+ MAPPER.putIfAbsent(LocalDateTime.class, ColumnValueImpl::getLocalDateTime);
+ }
+
+ private final JFilePatternConfig patternConfig;
+
+ private final int columnNumber;
+ private final String content;
+
+ ColumnValueImpl(JFilePatternConfig patternConfig, int columnNumber, String content) {
+ this.patternConfig = patternConfig;
+ this.columnNumber = columnNumber;
+ this.content = RuleUtils.trimToEmpty(content);
+ }
+
+ @Override
+ public int getColumnNumber() {
+ return columnNumber;
+ }
+
+ @SuppressWarnings("unchecked")
+ public T getContent(Class clazz) {
+ return (T) MAPPER.get(clazz).apply(this);
+ }
+
+ @Override
+ public String getText() {
+ return content;
+ }
+
+ @Override
+ public String[] getTextArray() {
+ return getTextArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public String[] getTextArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getText).toArray(String[]::new)
+ );
+ }
+
+ @Override
+ public Character getCharacter() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ if (content.length() > 1) {
+ throw new IllegalStateException("The value '" + content + "' is not parsable to Character");
+ }
+
+ return content.charAt(0);
+ }
+
+ @Override
+ public Character[] getCharacterArray() {
+ return getCharacterArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Character[] getCharacterArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getCharacter).toArray(Character[]::new)
+ );
+ }
+
+ @Override
+ public Short getShort() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return Short.valueOf(content);
+ }
+
+ @Override
+ public Short[] getShortArray() {
+ return getShortArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Short[] getShortArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getShort).toArray(Short[]::new)
+ );
+ }
+
+ @Override
+ public Integer getInt() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return Integer.valueOf(content);
+ }
+
+ @Override
+ public Integer[] getIntArray() {
+ return getIntArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Integer[] getIntArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getInt).toArray(Integer[]::new)
+ );
+ }
+
+ @Override
+ public Long getLong() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return Long.valueOf(content);
+ }
+
+ @Override
+ public Long[] getLongArray() {
+ return getLongArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Long[] getLongArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getLong).toArray(Long[]::new)
+ );
+ }
+
+ @Override
+ public Float getFloat() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return Float.valueOf(content);
+ }
+
+ @Override
+ public Float[] getFloatArray() {
+ return getFloatArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Float[] getFloatArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getFloat).toArray(Float[]::new)
+ );
+ }
+
+ @Override
+ public Double getDouble() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return Double.valueOf(content);
+ }
+
+ @Override
+ public Double[] getDoubleArray() {
+ return getDoubleArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Double[] getDoubleArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getDouble).toArray(Double[]::new)
+ );
+ }
+
+ @Override
+ public Boolean getBoolean() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ String booleanString = content;
+
+ if (booleanString.equals("0")) {
+ booleanString = "false";
+ } else if (booleanString.equals("1")) {
+ booleanString = "true";
+ }
+
+ return RuleUtils.toBooleanObject(booleanString);
+ }
+
+ @Override
+ public Boolean[] getBooleanArray() {
+ return getBooleanArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Boolean[] getBooleanArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getBoolean).toArray(Boolean[]::new)
+ );
+ }
+
+ @Override
+ public BigInteger getBigInteger() {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return new BigInteger(content);
+ }
+
+ @Override
+ public BigInteger[] getBigIntegerArray() {
+ return getBigIntegerArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public BigInteger[] getBigIntegerArray(Pattern splitPattern) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(ColumnValueImpl::getBigInteger).toArray(BigInteger[]::new)
+ );
+ }
+
+ @Override
+ public BigDecimal getBigDecimal() {
+ return getBigDecimal(patternConfig.getBigDecimalFormatter());
+ }
+
+ @Override
+ public BigDecimal getBigDecimal(DecimalFormat bigDecimalFormatter) {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ try {
+ return (BigDecimal) bigDecimalFormatter.parse(content);
+ } catch (ParseException e) {
+ throw new NumberFormatException(
+ "The value '" + content + "' is not parsable to BigDecimal with current DecimalFormat"
+ );
+ }
+ }
+
+ @Override
+ public BigDecimal[] getBigDecimalArray() {
+ return getBigDecimalArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public BigDecimal[] getBigDecimalArray(Pattern splitPattern) {
+ return getBigDecimalArray(splitPattern, patternConfig.getBigDecimalFormatter());
+ }
+
+ @Override
+ public BigDecimal[] getBigDecimalArray(Pattern splitPattern, DecimalFormat bigDecimalFormatter) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(o -> o.getBigDecimal(bigDecimalFormatter)).toArray(BigDecimal[]::new)
+ );
+ }
+
+ @Override
+ public Date getDate() {
+ return getDate(patternConfig.getDateFormat());
+ }
+
+ @Override
+ public Date getDate(DateFormat dateFormat) {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ try {
+ return dateFormat.parse(content);
+ } catch (ParseException e) {
+ throw new IllegalStateException(
+ "The value '" + content + "' is not parsable to Date with current DateFormat"
+ );
+ }
+ }
+
+ @Override
+ public Date[] getDateArray() {
+ return getDateArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public Date[] getDateArray(Pattern splitPattern) {
+ return getDateArray(splitPattern, patternConfig.getDateFormat());
+ }
+
+ @Override
+ public Date[] getDateArray(Pattern splitPattern, DateFormat dateFormat) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(o -> o.getDate(dateFormat)).toArray(Date[]::new)
+ );
+ }
+
+ @Override
+ public LocalDate getLocalDate() {
+ return getLocalDate(patternConfig.getLocalDateFormatter());
+ }
+
+ @Override
+ public LocalDate getLocalDate(DateTimeFormatter dateTimeFormatter) {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return LocalDate.parse(content, dateTimeFormatter);
+ }
+
+ @Override
+ public LocalDate[] getLocalDateArray() {
+ return getLocalDateArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public LocalDate[] getLocalDateArray(Pattern splitPattern) {
+ return getLocalDateArray(splitPattern, patternConfig.getLocalDateFormatter());
+ }
+
+ @Override
+ public LocalDate[] getLocalDateArray(Pattern splitPattern, DateTimeFormatter dateTimeFormatter) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(o -> o.getLocalDate(dateTimeFormatter)).toArray(LocalDate[]::new)
+ );
+ }
+
+ @Override
+ public LocalDateTime getLocalDateTime() {
+ return getLocalDateTime(patternConfig.getLocalDateTimeFormatter());
+ }
+
+ @Override
+ public LocalDateTime getLocalDateTime(DateTimeFormatter dateTimeFormatter) {
+ if (RuleUtils.isBlank(content)) {
+ return null;
+ }
+
+ return LocalDateTime.parse(content, dateTimeFormatter);
+ }
+
+ @Override
+ public LocalDateTime[] getLocalDateTimeArray() {
+ return getLocalDateTimeArray(DEFAULT_ARRAY_SEPARATOR);
+ }
+
+ @Override
+ public LocalDateTime[] getLocalDateTimeArray(Pattern splitPattern) {
+ return getLocalDateTimeArray(splitPattern, patternConfig.getLocalDateTimeFormatter());
+ }
+
+ @Override
+ public LocalDateTime[] getLocalDateTimeArray(Pattern splitPattern, DateTimeFormatter dateTimeFormatter) {
+ return getArrayOf(
+ splitPattern,
+ array -> Arrays.stream(array).map(o -> o.getLocalDateTime(dateTimeFormatter)).toArray(LocalDateTime[]::new)
+ );
+ }
+
+ @Override
+ public JFilePatternConfig getPatternConfig() {
+ return patternConfig;
+ }
+
+ private T[] getArrayOf(Pattern splitPattern, Function function) {
+ String[] split = splitPattern.split(content);
+
+ ColumnValueImpl[] columnValueStream = Arrays
+ .stream(split)
+ .map(content -> new ColumnValueImpl(patternConfig, columnNumber, content))
+ .toArray(ColumnValueImpl[]::new);
+
+ return function.apply(columnValueStream);
+ }
+
+ @Override
+ public int compareTo(ColumnValue o) {
+ return Integer.compare(columnNumber, o.getColumnNumber());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(columnNumber);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ ColumnValueImpl that = (ColumnValueImpl) o;
+ return columnNumber == that.columnNumber;
+ }
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/file/JFileColumn.java b/src/main/java/com/jonpereiradev/jfile/reader/file/JFileColumn.java
deleted file mode 100644
index fdd33a2..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/file/JFileColumn.java
+++ /dev/null
@@ -1,382 +0,0 @@
-package com.jonpereiradev.jfile.reader.file;
-
-import com.jonpereiradev.jfile.reader.JFileReaderContext;
-import org.apache.commons.lang3.BooleanUtils;
-import org.apache.commons.lang3.StringUtils;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.text.ParseException;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.Objects;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.function.Function;
-import java.util.regex.Pattern;
-
-public class JFileColumn implements Comparable {
-
- private static final Pattern DEFAULT_ARRAY_SEPARATOR = Pattern.compile(",\\s*");
- private static final ConcurrentMap, Function> MAPPER = new ConcurrentHashMap<>();
-
- static {
- MAPPER.putIfAbsent(char.class, JFileColumn::getCharacter);
- MAPPER.putIfAbsent(Character.class, JFileColumn::getCharacter);
- MAPPER.putIfAbsent(String.class, JFileColumn::getText);
- MAPPER.putIfAbsent(short.class, JFileColumn::getShort);
- MAPPER.putIfAbsent(Short.class, JFileColumn::getShort);
- MAPPER.putIfAbsent(int.class, JFileColumn::getInt);
- MAPPER.putIfAbsent(Integer.class, JFileColumn::getInt);
- MAPPER.putIfAbsent(long.class, JFileColumn::getLong);
- MAPPER.putIfAbsent(Long.class, JFileColumn::getLong);
- MAPPER.putIfAbsent(float.class, JFileColumn::getFloat);
- MAPPER.putIfAbsent(Float.class, JFileColumn::getFloat);
- MAPPER.putIfAbsent(double.class, JFileColumn::getDouble);
- MAPPER.putIfAbsent(Double.class, JFileColumn::getDouble);
- MAPPER.putIfAbsent(boolean.class, JFileColumn::getBoolean);
- MAPPER.putIfAbsent(Boolean.class, JFileColumn::getBoolean);
- MAPPER.putIfAbsent(BigInteger.class, JFileColumn::getBigInteger);
- MAPPER.putIfAbsent(BigDecimal.class, JFileColumn::getBigDecimal);
- MAPPER.putIfAbsent(Date.class, JFileColumn::getDate);
- MAPPER.putIfAbsent(LocalDate.class, JFileColumn::getLocalDate);
- MAPPER.putIfAbsent(LocalDateTime.class, JFileColumn::getLocalDateTime);
- }
-
- private final JFileReaderContext context;
-
- private final int position;
- private final String content;
-
- public JFileColumn(JFileReaderContext context, int position, String content) {
- this.context = context;
- this.position = position;
- this.content = StringUtils.trimToEmpty(content);
- }
-
- public int getPosition() {
- return position;
- }
-
- @SuppressWarnings("unchecked")
- public T getContent(Class clazz) {
- return (T) MAPPER.get(clazz).apply(this);
- }
-
- public String getText() {
- return content;
- }
-
- public String[] getTextArray() {
- return getTextArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public String[] getTextArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getText).toArray(String[]::new));
- }
-
- public Character getCharacter() {
- if (StringUtils.isBlank(content) || content.length() > 1) {
- return null;
- }
-
- return content.charAt(0);
- }
-
- public Character[] getCharacterArray() {
- return getCharacterArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Character[] getCharacterArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getCharacter).toArray(Character[]::new));
- }
-
- public Short getShort() {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return Short.valueOf(content);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- public Short[] getShortArray() {
- return getShortArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Short[] getShortArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getShort).toArray(Short[]::new));
- }
-
- public Integer getInt() {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return Integer.valueOf(content);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- public Integer[] getIntArray() {
- return getIntArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Integer[] getIntArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getInt).toArray(Integer[]::new));
- }
-
- public Long getLong() {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return Long.valueOf(content);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- public Long[] getLongArray() {
- return getLongArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Long[] getLongArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getLong).toArray(Long[]::new));
- }
-
- public Float getFloat() {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return Float.valueOf(content);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- public Float[] getFloatArray() {
- return getFloatArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Float[] getFloatArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getFloat).toArray(Float[]::new));
- }
-
- public Double getDouble() {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return Double.valueOf(content);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- public Double[] getDoubleArray() {
- return getDoubleArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Double[] getDoubleArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getDouble).toArray(Double[]::new));
- }
-
- public Boolean getBoolean() {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- String booleanString = content;
-
- if (booleanString.equals("0")) {
- booleanString = "false";
- } else if (booleanString.equals("1")) {
- booleanString = "true";
- }
-
- return BooleanUtils.toBooleanObject(booleanString);
- }
-
- public Boolean[] getBooleanArray() {
- return getBooleanArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Boolean[] getBooleanArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getBoolean).toArray(Boolean[]::new));
- }
-
- public BigInteger getBigInteger() {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return new BigInteger(content);
- } catch (NumberFormatException e) {
- return null;
- }
- }
-
- public BigInteger[] getBigIntegerArray() {
- return getBigIntegerArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public BigInteger[] getBigIntegerArray(Pattern pattern) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(JFileColumn::getBigInteger).toArray(BigInteger[]::new));
- }
-
- public BigDecimal getBigDecimal() {
- return getBigDecimal(context.getBigDecimalFormatter());
- }
-
- public BigDecimal getBigDecimal(DecimalFormat bigDecimalFormatter) {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return (BigDecimal) bigDecimalFormatter.parse(content);
- } catch (ParseException e) {
- return null;
- }
- }
-
- public BigDecimal[] getBigDecimalArray() {
- return getBigDecimalArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public BigDecimal[] getBigDecimalArray(Pattern pattern) {
- return getBigDecimalArray(pattern, context.getBigDecimalFormatter());
- }
-
- public BigDecimal[] getBigDecimalArray(Pattern pattern, DecimalFormat bigDecimalFormatter) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(o -> o.getBigDecimal(bigDecimalFormatter)).toArray(BigDecimal[]::new));
- }
-
- public Date getDate() {
- return getDate(context.getDateFormat());
- }
-
- public Date getDate(DateFormat pattern) {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return pattern.parse(content);
- } catch (ParseException e) {
- return null;
- }
- }
-
- public Date[] getDateArray() {
- return getDateArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public Date[] getDateArray(Pattern pattern) {
- return getDateArray(pattern, context.getDateFormat());
- }
-
- public Date[] getDateArray(Pattern pattern, DateFormat dateFormat) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(o -> o.getDate(dateFormat)).toArray(Date[]::new));
- }
-
- public LocalDate getLocalDate() {
- return getLocalDate(context.getLocalDateFormatter());
- }
-
- public LocalDate getLocalDate(DateTimeFormatter dateTimeFormatter) {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return LocalDate.parse(content, dateTimeFormatter);
- } catch (DateTimeParseException e) {
- return null;
- }
- }
-
- public LocalDate[] getLocalDateArray() {
- return getLocalDateArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public LocalDate[] getLocalDateArray(Pattern pattern) {
- return getLocalDateArray(pattern, context.getLocalDateFormatter());
- }
-
- public LocalDate[] getLocalDateArray(Pattern pattern, DateTimeFormatter dateTimeFormatter) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(o -> o.getLocalDate(dateTimeFormatter)).toArray(LocalDate[]::new));
- }
-
- public LocalDateTime getLocalDateTime() {
- return getLocalDateTime(context.getLocalDateTimeFormatter());
- }
-
- public LocalDateTime getLocalDateTime(DateTimeFormatter dateTimeFormatter) {
- if (StringUtils.isBlank(content)) {
- return null;
- }
-
- try {
- return LocalDateTime.parse(content, dateTimeFormatter);
- } catch (DateTimeParseException e) {
- return null;
- }
- }
-
- public LocalDateTime[] getLocalDateTimeArray() {
- return getLocalDateTimeArray(DEFAULT_ARRAY_SEPARATOR);
- }
-
- public LocalDateTime[] getLocalDateTimeArray(Pattern pattern) {
- return getLocalDateTimeArray(pattern, context.getLocalDateTimeFormatter());
- }
-
- public LocalDateTime[] getLocalDateTimeArray(Pattern pattern, DateTimeFormatter dateTimeFormatter) {
- return getArrayOf(pattern, array -> Arrays.stream(array).map(o -> o.getLocalDateTime(dateTimeFormatter)).toArray(LocalDateTime[]::new));
- }
-
- private T[] getArrayOf(Pattern pattern, Function function) {
- String[] split = pattern.split(content);
- return function.apply(Arrays.stream(split).map(s -> new JFileColumn(context, position, s)).toArray(JFileColumn[]::new));
- }
-
- public JFileReaderContext getContext() {
- return context;
- }
-
- @Override
- public int compareTo(JFileColumn o) {
- return Integer.compare(position, o.position);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- JFileColumn that = (JFileColumn) o;
- return position == that.position;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(position);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/file/JFileLine.java b/src/main/java/com/jonpereiradev/jfile/reader/file/JFileLine.java
deleted file mode 100644
index 7ab81bc..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/file/JFileLine.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.jonpereiradev.jfile.reader.file;
-
-import java.util.Collections;
-import java.util.Objects;
-import java.util.SortedSet;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-import java.util.stream.Stream;
-
-public class JFileLine implements Comparable {
-
- private final ConcurrentMap columnsByPosition = new ConcurrentHashMap<>();
-
- private final int row;
- private final String content;
- private final SortedSet columns;
-
- public JFileLine(int row, String content, SortedSet columns) {
- this.row = row;
- this.content = content;
- this.columns = Collections.unmodifiableSortedSet(columns);
- }
-
- @Override
- public int compareTo(JFileLine o) {
- return Integer.compare(row, o.row);
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- JFileLine jFileLine = (JFileLine) o;
- return row == jFileLine.row;
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(row);
- }
-
- public JFileColumn getColumn(int position) {
- if (!columnsByPosition.containsKey(position)) {
- Stream stream = getColumns().stream().filter(o -> o.getPosition() == position);
- JFileColumn column = stream.findFirst().orElseThrow(() -> new IllegalArgumentException("Position doesn't exists in line."));
- columnsByPosition.put(position, column);
- }
-
- return columnsByPosition.get(position);
- }
-
- public int getRow() {
- return row;
- }
-
- public String getContent() {
- return content;
- }
-
- public SortedSet getColumns() {
- return columns;
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/file/LineValue.java b/src/main/java/com/jonpereiradev/jfile/reader/file/LineValue.java
new file mode 100644
index 0000000..c115caa
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/file/LineValue.java
@@ -0,0 +1,48 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.file;
+
+
+import java.util.SortedSet;
+
+
+/**
+ * @author jonpereiradev
+ * @since 0.1.0
+ */
+public interface LineValue extends Comparable {
+
+ static LineValueImpl newLineValue(int lineNumber, String content, SortedSet columnValues) {
+ return new LineValueImpl(lineNumber, content, columnValues);
+ }
+
+ int getLineNumber();
+
+ String getContent();
+
+ ColumnValue getColumnValue(int columnNumber);
+
+ SortedSet getColumnValues();
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/file/LineValueImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/file/LineValueImpl.java
new file mode 100644
index 0000000..181c52b
--- /dev/null
+++ b/src/main/java/com/jonpereiradev/jfile/reader/file/LineValueImpl.java
@@ -0,0 +1,100 @@
+/*
+ * MIT License
+ *
+ * Copyright (c) 2020 Jonathan de Almeida Pereira
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all
+ * copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ */
+package com.jonpereiradev.jfile.reader.file;
+
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import java.util.SortedSet;
+import java.util.stream.Stream;
+
+
+final class LineValueImpl implements LineValue {
+
+ private static final String POSITION_ERROR = "Position doesn't exists in line.";
+
+ private final Map columnsByPosition = new HashMap<>();
+
+ private final int lineNumber;
+ private final String content;
+ private final SortedSet columnValues;
+
+ LineValueImpl(int lineNumber, String content, SortedSet columnValues) {
+ this.lineNumber = lineNumber;
+ this.content = content;
+ this.columnValues = Collections.unmodifiableSortedSet(columnValues);
+ }
+
+ @Override
+ public int compareTo(LineValue o) {
+ return Integer.compare(lineNumber, o.getLineNumber());
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(lineNumber);
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+ LineValueImpl lineValue = (LineValueImpl) o;
+ return lineNumber == lineValue.lineNumber;
+ }
+
+ @Override
+ public String toString() {
+ return "[lineNumber=" + lineNumber + ", content=" + content + "]";
+ }
+
+ @Override
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
+ @Override
+ public String getContent() {
+ return content;
+ }
+
+ @Override
+ public ColumnValue getColumnValue(int columnNumber) {
+ if (!columnsByPosition.containsKey(columnNumber)) {
+ Stream stream = getColumnValues().stream().filter(o -> o.getColumnNumber() == columnNumber);
+ ColumnValue column = stream.findFirst().orElseThrow(() -> new IllegalArgumentException(POSITION_ERROR));
+ columnsByPosition.put(columnNumber, column);
+ }
+
+ return columnsByPosition.get(columnNumber);
+ }
+
+ @Override
+ public SortedSet getColumnValues() {
+ return columnValues;
+ }
+
+}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/DateTimeFormatter.java b/src/main/java/com/jonpereiradev/jfile/reader/parser/DateTimeFormatter.java
deleted file mode 100644
index dc08a30..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/DateTimeFormatter.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.jonpereiradev.jfile.reader.parser;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface DateTimeFormatter {
-
- String value();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/DecimalFormatter.java b/src/main/java/com/jonpereiradev/jfile/reader/parser/DecimalFormatter.java
deleted file mode 100644
index d6c1017..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/DecimalFormatter.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jonpereiradev.jfile.reader.parser;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface DecimalFormatter {
-
- String value();
-
- char groupingSeparator() default '.';
-
- char decimalSeparator() default ',';
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/DefaultFileLineParser.java b/src/main/java/com/jonpereiradev/jfile/reader/parser/DefaultFileLineParser.java
deleted file mode 100644
index 6124671..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/DefaultFileLineParser.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.jonpereiradev.jfile.reader.parser;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-
-import java.util.HashMap;
-import java.util.Map;
-
-final class DefaultFileLineParser implements FileLineParser {
-
- private static final Map, Map> CACHE_CLASS_REFLECTIONS = new HashMap<>();
-
- private final ReaderConfiguration configuration;
-
- DefaultFileLineParser(ReaderConfiguration configuration) {
- this.configuration = configuration;
- }
-
- @Override
- public T parse(JFileLine fileLine, Class clazz) {
- T object = newInstance(clazz);
- Map pair = getGetterSetterPair(clazz);
-
- ObjectWriter objectWriter = new ObjectWriter(configuration);
-
- fileLine.getColumns().forEach(o -> {
- if (pair.containsKey(o.getPosition())) {
- objectWriter.write(object, o, pair.get(o.getPosition()));
- }
- });
-
- return object;
- }
-
- private Map getGetterSetterPair(Class clazz) {
- if (!CACHE_CLASS_REFLECTIONS.containsKey(clazz)) {
- ObjectReader objectReader = new ObjectReader();
- CACHE_CLASS_REFLECTIONS.put(clazz, objectReader.read(clazz));
- }
-
- return CACHE_CLASS_REFLECTIONS.get(clazz);
- }
-
- private T newInstance(Class clazz) {
- try {
- return clazz.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new IllegalArgumentException(e);
- }
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/FileColumn.java b/src/main/java/com/jonpereiradev/jfile/reader/parser/FileColumn.java
deleted file mode 100644
index d55441f..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/FileColumn.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.jonpereiradev.jfile.reader.parser;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Target(ElementType.FIELD)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface FileColumn {
-
- int value();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/FileLineParser.java b/src/main/java/com/jonpereiradev/jfile/reader/parser/FileLineParser.java
deleted file mode 100644
index 0f3e57d..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/FileLineParser.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.jonpereiradev.jfile.reader.parser;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-
-public interface FileLineParser {
-
- static FileLineParser defaultParser(ReaderConfiguration configuration) {
- return new DefaultFileLineParser(configuration);
- }
-
- T parse(JFileLine fileLine, Class clazz);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/GetterSetterPair.java b/src/main/java/com/jonpereiradev/jfile/reader/parser/GetterSetterPair.java
deleted file mode 100644
index 5179328..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/GetterSetterPair.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.jonpereiradev.jfile.reader.parser;
-
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-
-
-final class GetterSetterPair {
-
- private Field field;
- private Method getter;
- private Method setter;
- private FileColumn annotation;
-
- Field getField() {
- return field;
- }
-
- void setField(Field field) {
- this.field = field;
- }
-
- Method getGetter() {
- return getter;
- }
-
- void setGetter(Method getter) {
- this.getter = getter;
- }
-
- Method getSetter() {
- return setter;
- }
-
- void setSetter(Method setter) {
- this.setter = setter;
- }
-
- FileColumn getAnnotation() {
- return annotation;
- }
-
- void setAnnotation(FileColumn annotation) {
- this.annotation = annotation;
- }
-
- boolean hasGetterAndSetter() {
- return getter != null && setter != null;
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/parser/ObjectWriter.java b/src/main/java/com/jonpereiradev/jfile/reader/parser/ObjectWriter.java
deleted file mode 100644
index 46750c0..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/parser/ObjectWriter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package com.jonpereiradev.jfile.reader.parser;
-
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-
-
-final class ObjectWriter {
-
- private final ReaderConfiguration configuration;
-
- ObjectWriter(ReaderConfiguration configuration) {
- this.configuration = configuration;
- }
-
- public void write(Object instance, JFileColumn fileColumn, GetterSetterPair getterSetterPair) {
- try {
- writeOnInstance(instance, fileColumn, getterSetterPair);
- } catch (IllegalAccessException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void writeOnInstance(Object instance, JFileColumn fileColumn, GetterSetterPair getterSetterPair)
- throws IllegalAccessException, InvocationTargetException {
- if (getterSetterPair.hasGetterAndSetter()) {
- Class> parameterType = getterSetterPair.getSetter().getParameterTypes()[0];
- Object newObject = createObject(fileColumn, getterSetterPair.getField(), parameterType);
-
- getterSetterPair.getSetter().invoke(instance, newObject);
- } else if (getterSetterPair.getGetter() != null) {
- Field field = getterSetterPair.getField();
- Object newObject = createObject(fileColumn, field, getterSetterPair.getGetter().getReturnType());
-
- field.setAccessible(true);
- field.set(instance, newObject);
- field.setAccessible(false);
- }
- }
-
- private Object createObject(JFileColumn fileColumn, Field field, Class> clazz) {
- if (clazz == BigDecimal.class) {
- return createBigDecimalObject(fileColumn, field);
- }
-
- if (clazz == LocalDate.class) {
- return createLocalDateObject(fileColumn, field);
- }
-
- if (clazz == LocalDateTime.class) {
- return createLocalDateTimeObject(fileColumn, field);
- }
-
- return fileColumn.getContent(clazz);
- }
-
- private BigDecimal createBigDecimalObject(JFileColumn fileColumn, Field field) {
- DecimalFormat numberFormatter = configuration.getBigDecimalFormatter();
-
- if (field.isAnnotationPresent(DecimalFormatter.class)) {
- DecimalFormatter annotation = field.getAnnotation(DecimalFormatter.class);
- DecimalFormat format = new DecimalFormat(annotation.value());
- DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance();
-
- symbols.setDecimalSeparator(annotation.decimalSeparator());
- symbols.setGroupingSeparator(annotation.groupingSeparator());
-
- format.setDecimalFormatSymbols(symbols);
- format.setParseBigDecimal(true);
-
- numberFormatter = format;
- }
-
- return fileColumn.getBigDecimal(numberFormatter);
- }
-
- private LocalDate createLocalDateObject(JFileColumn fileColumn, Field field) {
- java.time.format.DateTimeFormatter formatter = configuration.getLocalDateFormatter();
-
- if (field.isAnnotationPresent(DateTimeFormatter.class)) {
- DateTimeFormatter annotation = field.getAnnotation(DateTimeFormatter.class);
- formatter = java.time.format.DateTimeFormatter.ofPattern(annotation.value());
- }
-
- return fileColumn.getLocalDate(formatter);
- }
-
- private LocalDateTime createLocalDateTimeObject(JFileColumn fileColumn, Field field) {
- java.time.format.DateTimeFormatter formatter = configuration.getLocalDateTimeFormatter();
-
- if (field.isAnnotationPresent(DateTimeFormatter.class)) {
- DateTimeFormatter annotation = field.getAnnotation(DateTimeFormatter.class);
- formatter = java.time.format.DateTimeFormatter.ofPattern(annotation.value());
- }
-
- return fileColumn.getLocalDateTime(formatter);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/Rule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/Rule.java
deleted file mode 100644
index 9d10e38..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/Rule.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-public interface Rule {
-
- boolean isValid(T object);
-
- boolean canValidate(T object);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfiguration.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfiguration.java
deleted file mode 100644
index 3670155..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfiguration.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.file.FileRule;
-import com.jonpereiradev.jfile.reader.rule.line.LineRule;
-
-public interface RuleConfiguration {
-
- RuleNode getFileRootNode();
-
- RuleNode getLineRootNode();
-
- RuleNode getColumnRootNode();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfigurationImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfigurationImpl.java
deleted file mode 100644
index 87d78e0..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfigurationImpl.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.file.FileRule;
-import com.jonpereiradev.jfile.reader.rule.line.LineRule;
-
-final class RuleConfigurationImpl implements RuleConfiguration {
-
- private final RuleNode fileRuleNode = new RuleNodeImpl<>(null, null);
- private final RuleNode lineRuleNode = new RuleNodeImpl<>(null, null);
- private final RuleNode columnRuleNode = new RuleNodeImpl<>(null, null);
-
- @Override
- public RuleNode getFileRootNode() {
- return fileRuleNode;
- }
-
- @Override
- public RuleNode getLineRootNode() {
- return lineRuleNode;
- }
-
- @Override
- public RuleNode getColumnRootNode() {
- return columnRuleNode;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfigurator.java
deleted file mode 100644
index aff6cc1..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfigurator.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.configurator.FileRuleConfigurator;
-
-public interface RuleConfigurator {
-
- static RuleConfigurator defaultConfigurator(ReaderConfiguration readerConfiguration) {
- readerConfiguration.withRuleConfiguration(new RuleConfigurationImpl());
- return new RuleConfiguratorImpl(readerConfiguration);
- }
-
- FileRuleConfigurator files();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfiguratorImpl.java
deleted file mode 100644
index e58e5fc..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleConfiguratorImpl.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.configurator.FileRuleConfigurator;
-
-final class RuleConfiguratorImpl implements RuleConfigurator {
-
- private final ReaderConfiguration configuration;
-
- RuleConfiguratorImpl(ReaderConfiguration configuration) {
- this.configuration = configuration;
- }
-
- @Override
- public FileRuleConfigurator files() {
- return FileRuleConfigurator.defaultConfigurator(configuration);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleNode.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleNode.java
deleted file mode 100644
index e15e468..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleNode.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-import java.util.List;
-
-public interface RuleNode> extends Iterable {
-
- Class> getType();
-
- void add(T rule);
-
- RuleNode getParentNode();
-
- List getChildrens();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleNodeImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleNodeImpl.java
deleted file mode 100644
index c3c987d..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleNodeImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-public class RuleNodeImpl> implements RuleNode {
-
- private final Class> type;
- private final RuleNode parentNode;
- private final List rules = new ArrayList<>();
-
- public RuleNodeImpl(Class> type, RuleNode parentNode) {
- this.type = type;
- this.parentNode = parentNode;
- }
-
- @Override
- public void add(T rule) {
- this.rules.add(rule);
- }
-
- @Override
- public Class> getType() {
- return type;
- }
-
- @Override
- public Iterator iterator() {
- return rules.iterator();
- }
-
- @Override
- public RuleNode getParentNode() {
- return parentNode;
- }
-
- @Override
- public List getChildrens() {
- return Collections.unmodifiableList(rules);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleViolation.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleViolation.java
deleted file mode 100644
index e18d24b..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/RuleViolation.java
+++ /dev/null
@@ -1,59 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule;
-
-import java.util.Objects;
-
-public final class RuleViolation {
-
- private int row;
- private int column;
- private String content;
- private String rule;
-
- @Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- RuleViolation that = (RuleViolation) o;
- return row == that.row &&
- column == that.column &&
- Objects.equals(rule, that.rule);
- }
-
- @Override
- public int hashCode() {
- return Objects.hash(row, column, rule);
- }
-
- public int getRow() {
- return row;
- }
-
- public void setRow(int row) {
- this.row = row;
- }
-
- public int getColumn() {
- return column;
- }
-
- public void setColumn(int column) {
- this.column = column;
- }
-
- public String getContent() {
- return content;
- }
-
- public void setContent(String content) {
- this.content = content;
- }
-
- public String getRule() {
- return rule;
- }
-
- public void setRule(String rule) {
- this.rule = rule;
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/AbstractColumnRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/AbstractColumnRule.java
deleted file mode 100644
index 7d98f5b..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/AbstractColumnRule.java
+++ /dev/null
@@ -1,48 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import org.apache.commons.lang3.StringUtils;
-
-public abstract class AbstractColumnRule implements ColumnRule {
-
- private final int position;
-
- private JFileLine fileLine;
- private RuleNode ruleNode;
-
- public AbstractColumnRule(int position) {
- this.position = position;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return StringUtils.isNotBlank(fileColumn.getText());
- }
-
- @Override
- public int getPosition() {
- return position;
- }
-
- @Override
- public JFileLine getFileLine() {
- return fileLine;
- }
-
- @Override
- public void setFileLine(JFileLine fileLine) {
- this.fileLine = fileLine;
- }
-
- @Override
- public RuleNode getRuleNode() {
- return ruleNode;
- }
-
- @Override
- public void setRuleNode(RuleNode ruleNode) {
- this.ruleNode = ruleNode;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/AbstractRefRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/AbstractRefRule.java
deleted file mode 100644
index 53ad468..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/AbstractRefRule.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-
-public abstract class AbstractRefRule implements RefRule {
-
- private final int refPosition;
- private final int position;
-
- private JFileLine fileLine;
- private RuleNode ruleNode;
-
- public AbstractRefRule(int refPosition, int position) {
- this.refPosition = refPosition;
- this.position = position;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return true;
- }
-
- @Override
- public int getRefPosition() {
- return refPosition;
- }
-
- @Override
- public int getPosition() {
- return position;
- }
-
- @Override
- public JFileLine getFileLine() {
- return fileLine;
- }
-
- @Override
- public void setFileLine(JFileLine fileLine) {
- this.fileLine = fileLine;
- }
-
- @Override
- public RuleNode getRuleNode() {
- return ruleNode;
- }
-
- @Override
- public void setRuleNode(RuleNode ruleNode) {
- this.ruleNode = ruleNode;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ArrayOfTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ArrayOfTypeRule.java
deleted file mode 100644
index b4f74ad..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ArrayOfTypeRule.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.regex.Pattern;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-public class ArrayOfTypeRule extends AbstractColumnRule {
-
- private final Pattern pattern;
-
- public ArrayOfTypeRule(int position, Pattern pattern) {
- super(position);
- this.pattern = pattern;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return true;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-
- public List split(JFileColumn fileColumn) {
- String[] values = pattern.split(fileColumn.getText());
- Stream stream = Arrays.stream(values).map(o -> new JFileColumn(fileColumn.getContext(), getPosition(), o));
- return stream.collect(Collectors.toList());
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BigDecimalTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BigDecimalTypeRule.java
deleted file mode 100644
index 8baf06d..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BigDecimalTypeRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DecimalFormat;
-
-public class BigDecimalTypeRule extends AbstractColumnRule {
-
- private final DecimalFormat decimalFormat;
-
- public BigDecimalTypeRule(int position, DecimalFormat decimalFormat) {
- super(position);
- this.decimalFormat = decimalFormat;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getBigDecimal(decimalFormat) != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BigIntegerTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BigIntegerTypeRule.java
deleted file mode 100644
index aa760db..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BigIntegerTypeRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class BigIntegerTypeRule extends AbstractColumnRule {
-
- public BigIntegerTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getBigInteger() != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BooleanTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BooleanTypeRule.java
deleted file mode 100644
index 0b4592a..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/BooleanTypeRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class BooleanTypeRule extends AbstractColumnRule {
-
- public BooleanTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getBoolean() != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CharacterTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CharacterTypeRule.java
deleted file mode 100644
index 3a784f5..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CharacterTypeRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class CharacterTypeRule extends AbstractColumnRule {
-
- public CharacterTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getCharacter() != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CnpjRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CnpjRule.java
deleted file mode 100644
index 9fce975..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CnpjRule.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class CnpjRule extends AbstractColumnRule {
-
- private static final List INVALID_CNPJS = Arrays.asList(
- "00000000000000",
- "11111111111111",
- "22222222222222",
- "33333333333333",
- "44444444444444",
- "55555555555555",
- "66666666666666",
- "77777777777777",
- "88888888888888",
- "99999999999999"
- );
-
- public CnpjRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- String cnpj = fileColumn.getText();
-
- if (cnpj.length() != 14 || INVALID_CNPJS.contains(cnpj)) {
- return false;
- }
-
- int i;
- int j;
- int digit;
- int coeficient;
- int sum;
- int[] foundDv = {0, 0};
-
- int dv1 = Integer.parseInt(String.valueOf(cnpj.charAt(cnpj.length() - 2)));
- int dv2 = Integer.parseInt(String.valueOf(cnpj.charAt(cnpj.length() - 1)));
-
- for (j = 0; j < 2; j++) {
- sum = 0;
- coeficient = 2;
-
- for (i = cnpj.length() - 3 + j; i >= 0; i--) {
- digit = Integer.parseInt(String.valueOf(cnpj.charAt(i)));
- sum += digit * coeficient;
- coeficient++;
-
- if (coeficient > 9) {
- coeficient = 2;
- }
- }
-
- foundDv[j] = 11 - sum % 11;
-
- if (foundDv[j] >= 10) {
- foundDv[j] = 0;
- }
- }
-
- return dv1 == foundDv[0] && dv2 == foundDv[1];
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ColumnRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ColumnRule.java
deleted file mode 100644
index ccb6b8d..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ColumnRule.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.rule.Rule;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import org.apache.commons.lang3.StringUtils;
-
-public interface ColumnRule extends Rule {
-
- @Override
- boolean isValid(JFileColumn fileColumn);
-
- @Override
- default boolean canValidate(JFileColumn fileColumn) {
- return StringUtils.isNotBlank(fileColumn.getText());
- }
-
- int getPosition();
-
- JFileLine getFileLine();
-
- void setFileLine(JFileLine fileLine);
-
- RuleNode getRuleNode();
-
- void setRuleNode(RuleNode ruleNode);
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CpfRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CpfRule.java
deleted file mode 100644
index 987a882..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/CpfRule.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.Arrays;
-import java.util.List;
-
-public class CpfRule extends AbstractColumnRule {
-
- private static final List INVALID_CPFS = Arrays.asList(
- "00000000000",
- "11111111111",
- "22222222222",
- "33333333333",
- "44444444444",
- "55555555555",
- "66666666666",
- "77777777777",
- "88888888888",
- "99999999999"
- );
-
- public CpfRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- String cpf = fileColumn.getText();
-
- if (cpf.length() != 11 || INVALID_CPFS.contains(cpf)) {
- return false;
- }
-
- int i;
- int j;
- int digit;
- int coeficient;
- int sum;
- int[] foundDv = {0, 0};
-
- int dv1 = Integer.parseInt(String.valueOf(cpf.charAt(cpf.length() - 2)));
- int dv2 = Integer.parseInt(String.valueOf(cpf.charAt(cpf.length() - 1)));
-
- for (j = 0; j < 2; j++) {
- sum = 0;
- coeficient = 2;
-
- for (i = cpf.length() - 3 + j; i >= 0; i--) {
- digit = Integer.parseInt(String.valueOf(cpf.charAt(i)));
- sum += digit * coeficient;
- coeficient++;
- }
-
- foundDv[j] = 11 - sum % 11;
-
- if (foundDv[j] >= 10) {
- foundDv[j] = 0;
- }
- }
-
- return dv1 == foundDv[0] && dv2 == foundDv[1];
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateAfterRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateAfterRule.java
deleted file mode 100644
index b2d6654..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateAfterRule.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DateFormat;
-import java.util.Date;
-
-public class DateAfterRule extends AbstractColumnRule {
-
- private final DateFormat dateFormat;
- private final Date min;
- private final int columnPosition;
-
- public DateAfterRule(int position, DateFormat dateFormat, Date min) {
- super(position);
- this.dateFormat = dateFormat;
- this.min = min;
- this.columnPosition = -1;
- }
-
- public DateAfterRule(int position, DateFormat dateFormat, int columnPosition) {
- super(position);
- this.dateFormat = dateFormat;
- this.min = null;
- this.columnPosition = columnPosition;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- Date date = fileColumn.getDate(dateFormat);
- return date.compareTo(getComparingDate()) > 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDate(dateFormat) != null && getComparingDate() != null;
- }
-
- private Date getComparingDate() {
- if (columnPosition == -1) {
- return min;
- }
-
- return getFileLine().getColumn(columnPosition).getDate(dateFormat);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateBeforeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateBeforeRule.java
deleted file mode 100644
index eae1840..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateBeforeRule.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DateFormat;
-import java.util.Date;
-
-public class DateBeforeRule extends AbstractColumnRule {
-
- private final DateFormat dateFormat;
- private final Date max;
- private final int columnPosition;
-
- public DateBeforeRule(int position, DateFormat dateFormat, Date max) {
- super(position);
- this.dateFormat = dateFormat;
- this.max = max;
- this.columnPosition = -1;
- }
-
- public DateBeforeRule(Integer position, DateFormat dateFormat, int columnPosition) {
- super(position);
- this.dateFormat = dateFormat;
- this.max = null;
- this.columnPosition = columnPosition;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- Date date = fileColumn.getDate(dateFormat);
- return date.compareTo(getComparingDate()) < 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDate(dateFormat) != null && getComparingDate() != null;
- }
-
- private Date getComparingDate() {
- if (columnPosition == -1) {
- return max;
- }
-
- return getFileLine().getColumn(columnPosition).getDate(dateFormat);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateFutureOrPresentRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateFutureOrPresentRule.java
deleted file mode 100644
index a4043b9..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateFutureOrPresentRule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-public class DateFutureOrPresentRule extends AbstractColumnRule {
-
- private final DateFormat dateFormat;
-
- public DateFutureOrPresentRule(int position, DateFormat dateFormat) {
- super(position);
- this.dateFormat = dateFormat;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- Date date = fileColumn.getDate(dateFormat);
- Date current = Calendar.getInstance().getTime();
-
- return current.compareTo(date) <= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDate(dateFormat) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateFutureRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateFutureRule.java
deleted file mode 100644
index 81e3147..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateFutureRule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-public class DateFutureRule extends AbstractColumnRule {
-
- private final DateFormat dateFormat;
-
- public DateFutureRule(int position, DateFormat dateFormat) {
- super(position);
- this.dateFormat = dateFormat;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- Date date = fileColumn.getDate(dateFormat);
- Date current = Calendar.getInstance().getTime();
-
- return current.before(date);
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDate(dateFormat) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DatePastOrPresentRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DatePastOrPresentRule.java
deleted file mode 100644
index 5309d04..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DatePastOrPresentRule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-public class DatePastOrPresentRule extends AbstractColumnRule {
-
- private final DateFormat dateFormat;
-
- public DatePastOrPresentRule(int position, DateFormat dateFormat) {
- super(position);
- this.dateFormat = dateFormat;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- Date date = fileColumn.getDate(dateFormat);
- Date current = Calendar.getInstance().getTime();
-
- return current.compareTo(date) >= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDate(dateFormat) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DatePastRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DatePastRule.java
deleted file mode 100644
index 21afb45..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DatePastRule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DateFormat;
-import java.util.Calendar;
-import java.util.Date;
-
-public class DatePastRule extends AbstractColumnRule {
-
- private final DateFormat dateFormat;
-
- public DatePastRule(int position, DateFormat dateFormat) {
- super(position);
- this.dateFormat = dateFormat;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- Date date = fileColumn.getDate(dateFormat);
- Date current = Calendar.getInstance().getTime();
-
- return current.after(date);
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDate(dateFormat) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateTypeRule.java
deleted file mode 100644
index 4255067..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DateTypeRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.text.DateFormat;
-
-public class DateTypeRule extends AbstractColumnRule {
-
- private final DateFormat pattern;
-
- public DateTypeRule(int position, DateFormat pattern) {
- super(position);
- this.pattern = pattern;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getDate(pattern) != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainCharacterRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainCharacterRule.java
deleted file mode 100644
index ef5264f..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainCharacterRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.List;
-
-public class DomainCharacterRule extends AbstractColumnRule {
-
- private final List domains;
-
- public DomainCharacterRule(int position, List domains) {
- super(position);
- this.domains = domains;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return domains.contains(fileColumn.getCharacter());
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getCharacter() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainIntegerRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainIntegerRule.java
deleted file mode 100644
index 2193ce4..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainIntegerRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.List;
-
-public class DomainIntegerRule extends AbstractColumnRule {
-
- private final List domains;
-
- public DomainIntegerRule(int position, List domains) {
- super(position);
- this.domains = domains;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return domains.contains(fileColumn.getInt());
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getInt() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainLongRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainLongRule.java
deleted file mode 100644
index 4385815..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainLongRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.List;
-
-public class DomainLongRule extends AbstractColumnRule {
-
- private final List domains;
-
- public DomainLongRule(int position, List domains) {
- super(position);
- this.domains = domains;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return domains.contains(fileColumn.getLong());
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLong() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainRefRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainRefRule.java
deleted file mode 100644
index bd67a3c..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainRefRule.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.List;
-
-public class DomainRefRule extends AbstractRefRule {
-
- private final List domains;
- private final Class clazz;
-
- @SuppressWarnings("unchecked")
- public DomainRefRule(int refPosition, int position, List domains) {
- super(refPosition, position);
- this.domains = domains;
- this.clazz = (Class) domains.get(0).getClass();
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return domains.contains(fileColumn.getContent(clazz));
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainShortRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainShortRule.java
deleted file mode 100644
index d843fcb..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainShortRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.List;
-
-public class DomainShortRule extends AbstractColumnRule {
-
- private final List domains;
-
- public DomainShortRule(int position, List domains) {
- super(position);
- this.domains = domains;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return domains.contains(fileColumn.getShort());
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getShort() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainStringRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainStringRule.java
deleted file mode 100644
index ca2177a..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DomainStringRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.List;
-
-public class DomainStringRule extends AbstractColumnRule {
-
- private final List domains;
-
- public DomainStringRule(int position, List domains) {
- super(position);
- this.domains = domains;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return domains.contains(fileColumn.getText());
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DoubleTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DoubleTypeRule.java
deleted file mode 100644
index 5d90dc2..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/DoubleTypeRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class DoubleTypeRule extends AbstractColumnRule {
-
- public DoubleTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getDouble() != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/EmailRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/EmailRule.java
deleted file mode 100644
index 162838b..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/EmailRule.java
+++ /dev/null
@@ -1,11 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import java.util.regex.Pattern;
-
-public class EmailRule extends RegexRule {
-
- public EmailRule(int position) {
- super(position, Pattern.compile("^[_A-Za-z0-9-+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$"));
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/EmptyRefRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/EmptyRefRule.java
deleted file mode 100644
index 3d1b9d5..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/EmptyRefRule.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class EmptyRefRule extends AbstractRefRule {
-
- public EmptyRefRule(int refPosition, int position) {
- super(refPosition, position);
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return new OnlyNullRule(fileColumn.getPosition()).isValid(fileColumn);
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/FilledRefRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/FilledRefRule.java
deleted file mode 100644
index e6f112b..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/FilledRefRule.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class FilledRefRule extends AbstractRefRule {
-
- public FilledRefRule(int refPosition, int position) {
- super(refPosition, position);
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return new NotEmptyRule(fileColumn.getPosition()).isValid(fileColumn);
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/FloatTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/FloatTypeRule.java
deleted file mode 100644
index 25a1b52..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/FloatTypeRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class FloatTypeRule extends AbstractColumnRule {
-
- public FloatTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getFloat() != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/IntegerTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/IntegerTypeRule.java
deleted file mode 100644
index abf2869..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/IntegerTypeRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class IntegerTypeRule extends AbstractColumnRule {
-
- public IntegerTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().isEmpty() || fileColumn.getInt() != null;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateAfterRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateAfterRule.java
deleted file mode 100644
index 0c8b101..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateAfterRule.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateAfterRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
- private final LocalDate min;
- private final int refColumn;
-
- public LocalDateAfterRule(int position, DateTimeFormatter dateTimeFormatter, LocalDate min) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.min = min;
- this.refColumn = -1;
- }
-
- public LocalDateAfterRule(int position, DateTimeFormatter dateTimeFormatter, int refColumn) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.min = null;
- this.refColumn = refColumn;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDate date = fileColumn.getLocalDate(dateTimeFormatter);
- return date.compareTo(getComparingDate()) > 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDate(dateTimeFormatter) != null && getComparingDate() != null;
- }
-
- private LocalDate getComparingDate() {
- if (refColumn == -1) {
- return min;
- }
-
- return getFileLine().getColumn(refColumn).getLocalDate(dateTimeFormatter);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateBeforeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateBeforeRule.java
deleted file mode 100644
index af18aa8..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateBeforeRule.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateBeforeRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
- private final LocalDate max;
- private final int refColumn;
-
- public LocalDateBeforeRule(int position, DateTimeFormatter dateTimeFormatter, LocalDate max) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.max = max;
- this.refColumn = -1;
- }
-
- public LocalDateBeforeRule(int position, DateTimeFormatter dateTimeFormatter, int refColumn) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.max = null;
- this.refColumn = refColumn;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDate date = fileColumn.getLocalDate(dateTimeFormatter);
- return date.compareTo(getComparingDate()) < 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDate(dateTimeFormatter) != null && getComparingDate() != null;
- }
-
- private LocalDate getComparingDate() {
- if (refColumn == -1) {
- return max;
- }
-
- return getFileLine().getColumn(refColumn).getLocalDate(dateTimeFormatter);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateFutureOrPresentRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateFutureOrPresentRule.java
deleted file mode 100644
index 50ee2d8..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateFutureOrPresentRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateFutureOrPresentRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateFutureOrPresentRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDate date = fileColumn.getLocalDate(dateTimeFormatter);
- LocalDate current = LocalDate.now();
-
- return current.compareTo(date) <= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDate(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateFutureRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateFutureRule.java
deleted file mode 100644
index 2e81c94..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateFutureRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateFutureRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateFutureRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDate date = fileColumn.getLocalDate(dateTimeFormatter);
- LocalDate current = LocalDate.now();
-
- return current.compareTo(date) < 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDate(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDatePastOrPresentRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDatePastOrPresentRule.java
deleted file mode 100644
index e4515b7..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDatePastOrPresentRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDatePastOrPresentRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDatePastOrPresentRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDate date = fileColumn.getLocalDate(dateTimeFormatter);
- LocalDate current = LocalDate.now();
-
- return current.compareTo(date) >= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDate(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDatePastRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDatePastRule.java
deleted file mode 100644
index baf77a3..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDatePastRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDatePastRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDatePastRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDate date = fileColumn.getLocalDate(dateTimeFormatter);
- LocalDate current = LocalDate.now();
-
- return current.compareTo(date) > 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDate(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeAfterRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeAfterRule.java
deleted file mode 100644
index c50f1fc..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeAfterRule.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateTimeAfterRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
- private final LocalDateTime min;
- private final int refColumn;
-
- public LocalDateTimeAfterRule(int position, DateTimeFormatter dateTimeFormatter, LocalDateTime min) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.min = min;
- this.refColumn = -1;
- }
-
- public LocalDateTimeAfterRule(int position, DateTimeFormatter dateTimeFormatter, int refColumn) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.min = null;
- this.refColumn = refColumn;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDateTime date = fileColumn.getLocalDateTime(dateTimeFormatter);
- return date.compareTo(getComparingDate()) > 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDateTime(dateTimeFormatter) != null && getComparingDate() != null;
- }
-
- private LocalDateTime getComparingDate() {
- if (refColumn == -1) {
- return min;
- }
-
- return getFileLine().getColumn(refColumn).getLocalDateTime(dateTimeFormatter);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeBeforeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeBeforeRule.java
deleted file mode 100644
index 471ff6e..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeBeforeRule.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateTimeBeforeRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
- private final LocalDateTime max;
- private final int refColumn;
-
- public LocalDateTimeBeforeRule(int position, DateTimeFormatter dateTimeFormatter, LocalDateTime max) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.max = max;
- this.refColumn = -1;
- }
-
- public LocalDateTimeBeforeRule(int position, DateTimeFormatter dateTimeFormatter, int refColumn) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- this.max = null;
- this.refColumn = refColumn;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDateTime date = fileColumn.getLocalDateTime(dateTimeFormatter);
- return date.compareTo(getComparingDate()) < 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDateTime(dateTimeFormatter) != null && getComparingDate() != null;
- }
-
- private LocalDateTime getComparingDate() {
- if (refColumn == -1) {
- return max;
- }
-
- return getFileLine().getColumn(refColumn).getLocalDateTime(dateTimeFormatter);
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeFutureOrPresentRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeFutureOrPresentRule.java
deleted file mode 100644
index e24b7be..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeFutureOrPresentRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateTimeFutureOrPresentRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateTimeFutureOrPresentRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDateTime date = fileColumn.getLocalDateTime(dateTimeFormatter);
- LocalDateTime current = LocalDateTime.now();
-
- return current.compareTo(date) <= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDateTime(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeFutureRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeFutureRule.java
deleted file mode 100644
index 1f14fb2..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeFutureRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateTimeFutureRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateTimeFutureRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDateTime date = fileColumn.getLocalDateTime(dateTimeFormatter);
- LocalDateTime current = LocalDateTime.now();
-
- return current.compareTo(date) < 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDateTime(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimePastOrPresentRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimePastOrPresentRule.java
deleted file mode 100644
index 767b867..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimePastOrPresentRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateTimePastOrPresentRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateTimePastOrPresentRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDateTime date = fileColumn.getLocalDateTime(dateTimeFormatter);
- LocalDateTime current = LocalDateTime.now();
-
- return current.compareTo(date) >= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDateTime(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimePastRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimePastRule.java
deleted file mode 100644
index 5392d4a..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimePastRule.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-public class LocalDateTimePastRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateTimePastRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- LocalDateTime date = fileColumn.getLocalDateTime(dateTimeFormatter);
- LocalDateTime current = LocalDateTime.now();
-
- return current.compareTo(date) > 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLocalDateTime(dateTimeFormatter) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeTypeRule.java
deleted file mode 100644
index 2fb5ddd..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTimeTypeRule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
-
-public class LocalDateTimeTypeRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateTimeTypeRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- try {
- return fileColumn.getText().isEmpty() || fileColumn.getLocalDateTime(dateTimeFormatter) != null;
- } catch (DateTimeParseException e) {
- return false;
- }
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTypeRule.java
deleted file mode 100644
index 08ff756..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LocalDateTypeRule.java
+++ /dev/null
@@ -1,30 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.time.format.DateTimeFormatter;
-import java.time.format.DateTimeParseException;
-
-public class LocalDateTypeRule extends AbstractColumnRule {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- public LocalDateTypeRule(int position, DateTimeFormatter dateTimeFormatter) {
- super(position);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- try {
- return fileColumn.getText().isEmpty() || fileColumn.getLocalDate(dateTimeFormatter) != null;
- } catch (DateTimeParseException e) {
- return false;
- }
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LongTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LongTypeRule.java
deleted file mode 100644
index ddc66a6..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/LongTypeRule.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class LongTypeRule extends AbstractColumnRule {
-
- public LongTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- try {
- return fileColumn.getText().isEmpty() || fileColumn.getLong() != null;
- } catch (NumberFormatException e) {
- return false;
- }
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxBigDecimalRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxBigDecimalRule.java
deleted file mode 100644
index dd30dab..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxBigDecimalRule.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-
-public class MaxBigDecimalRule extends AbstractColumnRule {
-
- private final BigDecimal max;
- private final DecimalFormat decimalFormat;
-
- public MaxBigDecimalRule(int position, BigDecimal max, DecimalFormat decimalFormat) {
- super(position);
- this.max = max;
- this.decimalFormat = decimalFormat;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getBigDecimal(decimalFormat).compareTo(max) <= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getBigDecimal(decimalFormat) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxBigIntegerRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxBigIntegerRule.java
deleted file mode 100644
index aa43c2f..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxBigIntegerRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.math.BigInteger;
-
-public class MaxBigIntegerRule extends AbstractColumnRule {
-
- private final BigInteger max;
-
- public MaxBigIntegerRule(int position, BigInteger max) {
- super(position);
- this.max = max;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getBigInteger().compareTo(max) <= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getBigInteger() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxDoubleRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxDoubleRule.java
deleted file mode 100644
index 3b9e506..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxDoubleRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MaxDoubleRule extends AbstractColumnRule {
-
- private final double max;
-
- public MaxDoubleRule(int position, double max) {
- super(position);
- this.max = max;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getDouble() <= max;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDouble() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxFloatRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxFloatRule.java
deleted file mode 100644
index 5d3e739..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxFloatRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MaxFloatRule extends AbstractColumnRule {
-
- private final float max;
-
- public MaxFloatRule(int position, float max) {
- super(position);
- this.max = max;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getFloat() <= max;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getFloat() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxIntegerRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxIntegerRule.java
deleted file mode 100644
index c600d15..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxIntegerRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MaxIntegerRule extends AbstractColumnRule {
-
- private final int max;
-
- public MaxIntegerRule(int position, int max) {
- super(position);
- this.max = max;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getInt() <= max;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getInt() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxLongRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxLongRule.java
deleted file mode 100644
index a2a29e9..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxLongRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MaxLongRule extends AbstractColumnRule {
-
- private final long max;
-
- public MaxLongRule(int position, long max) {
- super(position);
- this.max = max;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getLong() <= max;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLong() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxShortRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxShortRule.java
deleted file mode 100644
index f1ef28d..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxShortRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MaxShortRule extends AbstractColumnRule {
-
- private final short max;
-
- public MaxShortRule(int position, short max) {
- super(position);
- this.max = max;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getShort() <= max;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getShort() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxStringRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxStringRule.java
deleted file mode 100644
index e0cbf56..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MaxStringRule.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MaxStringRule extends AbstractColumnRule {
-
- private final int max;
-
- public MaxStringRule(int position, int max) {
- super(position);
- this.max = max;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().trim().length() <= max;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinBigDecimalRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinBigDecimalRule.java
deleted file mode 100644
index 286d86d..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinBigDecimalRule.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-
-public class MinBigDecimalRule extends AbstractColumnRule {
-
- private final BigDecimal min;
- private final DecimalFormat decimalFormat;
-
- public MinBigDecimalRule(int position, BigDecimal min, DecimalFormat decimalFormat) {
- super(position);
- this.min = min;
- this.decimalFormat = decimalFormat;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getBigDecimal(decimalFormat).compareTo(min) >= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getBigDecimal(decimalFormat) != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinBigIntegerRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinBigIntegerRule.java
deleted file mode 100644
index f7daab2..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinBigIntegerRule.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.math.BigInteger;
-
-public class MinBigIntegerRule extends AbstractColumnRule {
-
- private final BigInteger min;
-
- public MinBigIntegerRule(int position, BigInteger min) {
- super(position);
- this.min = min;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getBigInteger().compareTo(min) >= 0;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getBigInteger() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinDoubleRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinDoubleRule.java
deleted file mode 100644
index 9db24ac..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinDoubleRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MinDoubleRule extends AbstractColumnRule {
-
- private final double min;
-
- public MinDoubleRule(int position, double min) {
- super(position);
- this.min = min;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getDouble() >= min;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getDouble() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinFloatRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinFloatRule.java
deleted file mode 100644
index d07a079..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinFloatRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MinFloatRule extends AbstractColumnRule {
-
- private final float min;
-
- public MinFloatRule(int position, float min) {
- super(position);
- this.min = min;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getFloat() >= min;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getFloat() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinIntegerRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinIntegerRule.java
deleted file mode 100644
index b83cab9..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinIntegerRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MinIntegerRule extends AbstractColumnRule {
-
- private final int min;
-
- public MinIntegerRule(int position, int min) {
- super(position);
- this.min = min;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getInt() >= min;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getInt() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinLongRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinLongRule.java
deleted file mode 100644
index 4aa6228..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinLongRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MinLongRule extends AbstractColumnRule {
-
- private final long min;
-
- public MinLongRule(int position, long min) {
- super(position);
- this.min = min;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getLong() >= min;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getLong() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinShortRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinShortRule.java
deleted file mode 100644
index 9fc37f9..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinShortRule.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MinShortRule extends AbstractColumnRule {
-
- private final short min;
-
- public MinShortRule(int position, short min) {
- super(position);
- this.min = min;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getShort() >= min;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return fileColumn.getShort() != null;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinStringRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinStringRule.java
deleted file mode 100644
index c57ac6c..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/MinStringRule.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class MinStringRule extends AbstractColumnRule {
-
- private final int min;
-
- public MinStringRule(int position, int min) {
- super(position);
- this.min = min;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return fileColumn.getText().trim().length() >= min;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/NotEmptyRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/NotEmptyRule.java
deleted file mode 100644
index 61ed17c..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/NotEmptyRule.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import org.apache.commons.lang3.StringUtils;
-
-public class NotEmptyRule extends AbstractColumnRule {
-
- public NotEmptyRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return StringUtils.isNotBlank(fileColumn.getText());
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/NotNullRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/NotNullRule.java
deleted file mode 100644
index c2e566f..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/NotNullRule.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import org.apache.commons.lang3.StringUtils;
-
-public class NotNullRule extends AbstractColumnRule {
-
- public NotNullRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return StringUtils.isNotEmpty(fileColumn.getText());
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/OnlyNullRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/OnlyNullRule.java
deleted file mode 100644
index 6adc7a8..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/OnlyNullRule.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import org.apache.commons.lang3.StringUtils;
-
-public class OnlyNullRule extends AbstractColumnRule {
-
- public OnlyNullRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return StringUtils.isBlank(fileColumn.getText());
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/RefRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/RefRule.java
deleted file mode 100644
index 2d74a63..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/RefRule.java
+++ /dev/null
@@ -1,7 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-public interface RefRule extends ColumnRule {
-
- int getRefPosition();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/RegexRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/RegexRule.java
deleted file mode 100644
index 44fb6f1..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/RegexRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-import java.util.regex.Pattern;
-
-public class RegexRule extends AbstractColumnRule {
-
- private final Pattern regex;
-
- public RegexRule(int position, Pattern pattern) {
- super(position);
- this.regex = pattern;
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return regex.matcher(fileColumn.getText()).matches();
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ShortTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ShortTypeRule.java
deleted file mode 100644
index b0163aa..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/ShortTypeRule.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class ShortTypeRule extends AbstractColumnRule {
-
- public ShortTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- try {
- return fileColumn.getText().isEmpty() || fileColumn.getShort() != null;
- } catch (NumberFormatException e) {
- return false;
- }
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/StringTypeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/column/StringTypeRule.java
deleted file mode 100644
index 60c10a7..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/column/StringTypeRule.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.column;
-
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-
-public class StringTypeRule extends AbstractColumnRule {
-
- public StringTypeRule(int position) {
- super(position);
- }
-
- @Override
- public boolean isValid(JFileColumn fileColumn) {
- return true;
- }
-
- @Override
- public boolean canValidate(JFileColumn fileColumn) {
- return true;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/AbstractRuleConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/AbstractRuleConfigurator.java
deleted file mode 100644
index 65749e1..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/AbstractRuleConfigurator.java
+++ /dev/null
@@ -1,86 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.RuleNodeImpl;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.NotNullRule;
-import com.jonpereiradev.jfile.reader.rule.column.OnlyNullRule;
-import com.jonpereiradev.jfile.reader.rule.column.RefRule;
-
-import java.util.function.Function;
-
-abstract class AbstractRuleConfigurator> implements TypedRuleConfigurator {
-
- private final int position;
- private final ReaderConfiguration configuration;
-
- private RuleNode ruleNode;
-
- AbstractRuleConfigurator(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- this.position = position;
- this.configuration = configuration;
- this.ruleNode = ruleNode;
- }
-
- @Override
- public T notNull() {
- return rule(NotNullRule::new);
- }
-
- @Override
- public T onlyNull() {
- return rule(OnlyNullRule::new);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T rule(Function rule) {
- ColumnRule columnRule = rule.apply(position);
- columnRule.setRuleNode(new RuleNodeImpl<>(columnRule.getClass(), ruleNode));
- ruleNode.add(columnRule);
- return (T) this;
- }
-
- @Override
- public GenericTypeConfigurator column(int position) {
- return new GenericTypeConfiguratorImpl(position, configuration, getParentNode());
- }
-
- private RuleNode getParentNode() {
- RuleNode node = ruleNode;
-
- while (node.getParentNode() != null) {
- node = node.getParentNode();
- }
-
- return node;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public RefRuleConfigurator depends(int column) {
- RuleNode parentNode = ruleNode;
-
- if (ruleNode.getParentNode() != null && RefRule.class.isAssignableFrom(ruleNode.getType())) {
- parentNode = ruleNode.getParentNode();
- }
-
- return new RefRuleConfiguratorImpl<>(column, position, parentNode, (T) this);
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T apply() {
- if (ruleNode.getParentNode() != null) {
- setRuleNode(ruleNode.getParentNode());
- }
-
- return (T) this;
- }
-
- @Override
- public void setRuleNode(RuleNode ruleNode) {
- this.ruleNode = ruleNode;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ArrayTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ArrayTypeConfigurator.java
deleted file mode 100644
index 517e943..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ArrayTypeConfigurator.java
+++ /dev/null
@@ -1,94 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.time.format.DateTimeFormatter;
-
-public interface ArrayTypeConfigurator {
-
- /**
- * defines a rule for a column of short type.
- */
- ShortTypeConfigurator shortType();
-
- /**
- * defines a rule for a column of integer type.
- */
- IntegerTypeConfigurator integerType();
-
- /**
- * defines a rule for a column of long type.
- */
- LongTypeConfigurator longType();
-
- /**
- * defines a rule for a column of float type.
- */
- FloatTypeConfigurator floatType();
-
- /**
- * defines a rule for a column of double type.
- */
- DoubleTypeConfigurator doubleType();
-
- /**
- * defines a rule for a column of boolean type.
- */
- BooleanTypeConfigurator booleanType();
-
- /**
- * defines a rule for a column of character type.
- */
- CharacterTypeConfigurator characterType();
-
- /**
- * defines a rule for a column of string type.
- */
- StringTypeConfigurator stringType();
-
- /**
- * defines a rule for a column of big integer type.
- */
- BigIntegerTypeConfigurator bigIntegerType();
-
- /**
- * defines a rule for a column of big decimal type.
- */
- BigDecimalTypeConfigurator bigDecimalType();
-
- /**
- * defines a rule for a column of big decimal type.
- */
- BigDecimalTypeConfigurator bigDecimalType(DecimalFormat decimalFormat);
-
- /**
- * defines a rule for a column of date type.
- */
- DateTypeConfigurator dateType();
-
- /**
- * defines a rule for a column of date type.
- */
- DateTypeConfigurator dateType(DateFormat pattern);
-
- /**
- * defines a rule for a column of local date type.
- */
- LocalDateTypeConfigurator localDateType();
-
- /**
- * defines a rule for a column of local date type.
- */
- LocalDateTypeConfigurator localDateType(DateTimeFormatter dateTimeFormatter);
-
- /**
- * defines a rule for a column of local date time type.
- */
- LocalDateTimeTypeConfigurator localDateTimeType();
-
- /**
- * defines a rule for a column of local date time type.
- */
- LocalDateTimeTypeConfigurator localDateTimeType(DateTimeFormatter dateTimeFormatter);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigDecimalTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigDecimalTypeConfigurator.java
deleted file mode 100644
index e4aa3b2..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigDecimalTypeConfigurator.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.math.BigDecimal;
-
-public interface BigDecimalTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a min value rule validation.
- */
- BigDecimalTypeConfigurator min(BigDecimal min);
-
- /**
- * defines a max value rule validation.
- */
- BigDecimalTypeConfigurator max(BigDecimal max);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigDecimalTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigDecimalTypeConfiguratorImpl.java
deleted file mode 100644
index fdc1429..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigDecimalTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.MaxBigDecimalRule;
-import com.jonpereiradev.jfile.reader.rule.column.MinBigDecimalRule;
-
-import java.math.BigDecimal;
-import java.text.DecimalFormat;
-
-final class BigDecimalTypeConfiguratorImpl
- extends AbstractRuleConfigurator implements BigDecimalTypeConfigurator {
-
- private final DecimalFormat decimalFormat;
-
- BigDecimalTypeConfiguratorImpl(
- int position,
- DecimalFormat decimalFormat,
- ReaderConfiguration configuration,
- RuleNode ruleNode
- ) {
- super(position, configuration, ruleNode);
- this.decimalFormat = decimalFormat;
- }
-
- @Override
- public BigDecimalTypeConfigurator min(BigDecimal min) {
- return rule(position -> new MinBigDecimalRule(position, min, decimalFormat));
- }
-
- @Override
- public BigDecimalTypeConfigurator max(BigDecimal max) {
- return rule(position -> new MaxBigDecimalRule(position, max, decimalFormat));
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigIntegerTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigIntegerTypeConfigurator.java
deleted file mode 100644
index f21f462..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigIntegerTypeConfigurator.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.math.BigInteger;
-
-public interface BigIntegerTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a min value rule validation.
- */
- BigIntegerTypeConfigurator min(BigInteger min);
-
- /**
- * defines a max value rule validation.
- */
- BigIntegerTypeConfigurator max(BigInteger max);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigIntegerTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigIntegerTypeConfiguratorImpl.java
deleted file mode 100644
index 5de8878..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BigIntegerTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.MaxBigIntegerRule;
-import com.jonpereiradev.jfile.reader.rule.column.MinBigIntegerRule;
-
-import java.math.BigInteger;
-
-final class BigIntegerTypeConfiguratorImpl
- extends AbstractRuleConfigurator implements BigIntegerTypeConfigurator {
-
- BigIntegerTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public BigIntegerTypeConfigurator min(BigInteger min) {
- return rule(position -> new MinBigIntegerRule(position, min));
- }
-
- @Override
- public BigIntegerTypeConfigurator max(BigInteger max) {
- return rule(position -> new MaxBigIntegerRule(position, max));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BooleanTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BooleanTypeConfigurator.java
deleted file mode 100644
index 463c5dd..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BooleanTypeConfigurator.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface BooleanTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a domain rule validation with possible values options.
- */
- BooleanTypeConfigurator domain(Character... values);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BooleanTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BooleanTypeConfiguratorImpl.java
deleted file mode 100644
index a59747a..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/BooleanTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.DomainCharacterRule;
-
-import java.util.Arrays;
-
-final class BooleanTypeConfiguratorImpl extends AbstractRuleConfigurator implements BooleanTypeConfigurator {
-
- BooleanTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public BooleanTypeConfigurator domain(Character... values) {
- return rule(position -> new DomainCharacterRule(position, Arrays.asList(values)));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/CharacterTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/CharacterTypeConfigurator.java
deleted file mode 100644
index a39a3d4..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/CharacterTypeConfigurator.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface CharacterTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a domain rule validation with possible values options.
- */
- CharacterTypeConfigurator domain(Character... values);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/CharacterTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/CharacterTypeConfiguratorImpl.java
deleted file mode 100644
index 89fac78..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/CharacterTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,21 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.DomainCharacterRule;
-
-import java.util.Arrays;
-
-final class CharacterTypeConfiguratorImpl
- extends AbstractRuleConfigurator implements CharacterTypeConfigurator {
-
- CharacterTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public CharacterTypeConfigurator domain(Character... values) {
- return rule(position -> new DomainCharacterRule(position, Arrays.asList(values)));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DateTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DateTypeConfigurator.java
deleted file mode 100644
index c1b93f1..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DateTypeConfigurator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.util.Date;
-
-public interface DateTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a future rule validation.
- */
- DateTypeConfigurator future();
-
- /**
- * defines a future or present rule validation.
- */
- DateTypeConfigurator futureOrPresent();
-
- /**
- * defines a past rule validation.
- */
- DateTypeConfigurator past();
-
- /**
- * defines a past or present rule validation.
- */
- DateTypeConfigurator pastOrPresent();
-
- /**
- * defines a min date rule validation.
- */
- DateTypeConfigurator after(Date min);
-
- /**
- * defines a min date rule validation comparing to another column.
- */
- DateTypeConfigurator after(int columnPosition);
-
- /**
- * defines a max date rule validation.
- */
- DateTypeConfigurator before(Date max);
-
- /**
- * defines a max date rule validation comparing to another column.
- */
- DateTypeConfigurator before(int columnPosition);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DateTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DateTypeConfiguratorImpl.java
deleted file mode 100644
index 8ce1a0e..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DateTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,58 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.*;
-
-import java.text.DateFormat;
-import java.util.Date;
-
-final class DateTypeConfiguratorImpl extends AbstractRuleConfigurator implements DateTypeConfigurator {
-
- private final DateFormat dateFormat;
-
- DateTypeConfiguratorImpl(int position, DateFormat dateFormat, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- this.dateFormat = dateFormat;
- }
-
- @Override
- public DateTypeConfigurator future() {
- return rule(position -> new DateFutureRule(position, dateFormat));
- }
-
- @Override
- public DateTypeConfigurator futureOrPresent() {
- return rule(position -> new DateFutureOrPresentRule(position, dateFormat));
- }
-
- @Override
- public DateTypeConfigurator past() {
- return rule(position -> new DatePastRule(position, dateFormat));
- }
-
- @Override
- public DateTypeConfigurator pastOrPresent() {
- return rule(position -> new DatePastOrPresentRule(position, dateFormat));
- }
-
- @Override
- public DateTypeConfigurator after(Date min) {
- return rule(position -> new DateAfterRule(position, dateFormat, min));
- }
-
- @Override
- public DateTypeConfigurator after(int columnPosition) {
- return rule(position -> new DateAfterRule(position, dateFormat, columnPosition));
- }
-
- @Override
- public DateTypeConfigurator before(Date max) {
- return rule(position -> new DateBeforeRule(position, dateFormat, max));
- }
-
- @Override
- public DateTypeConfigurator before(int columnPosition) {
- return rule(position -> new DateBeforeRule(position, dateFormat, columnPosition));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DoubleTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DoubleTypeConfigurator.java
deleted file mode 100644
index 9985017..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DoubleTypeConfigurator.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface DoubleTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a min value rule validation.
- */
- DoubleTypeConfigurator min(double min);
-
- /**
- * defines a max value rule validation.
- */
- DoubleTypeConfigurator max(double max);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DoubleTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DoubleTypeConfiguratorImpl.java
deleted file mode 100644
index 8eca7bc..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/DoubleTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,24 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.MaxDoubleRule;
-import com.jonpereiradev.jfile.reader.rule.column.MinDoubleRule;
-
-final class DoubleTypeConfiguratorImpl extends AbstractRuleConfigurator implements DoubleTypeConfigurator {
-
- DoubleTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public DoubleTypeConfigurator min(double min) {
- return rule(position -> new MinDoubleRule(position, min));
- }
-
- @Override
- public DoubleTypeConfigurator max(double max) {
- return rule(position -> new MaxDoubleRule(position, max));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FileRuleConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FileRuleConfigurator.java
deleted file mode 100644
index 4b281aa..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FileRuleConfigurator.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-
-public interface FileRuleConfigurator {
-
- static FileRuleConfigurator defaultConfigurator(ReaderConfiguration configuration) {
- return new FileRuleConfiguratorImpl(configuration);
- }
-
- /**
- * creates the rule configurator for lines.
- */
- LineRuleConfigurator lines();
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FileRuleConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FileRuleConfiguratorImpl.java
deleted file mode 100644
index c3b8476..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FileRuleConfiguratorImpl.java
+++ /dev/null
@@ -1,18 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-
-final class FileRuleConfiguratorImpl implements FileRuleConfigurator {
-
- private final ReaderConfiguration configuration;
-
- FileRuleConfiguratorImpl(ReaderConfiguration configuration) {
- this.configuration = configuration;
- }
-
- @Override
- public LineRuleConfigurator lines() {
- return new LineRuleConfiguratorImpl(configuration);
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FloatTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FloatTypeConfigurator.java
deleted file mode 100644
index ae99c11..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FloatTypeConfigurator.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface FloatTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a min value rule validation.
- */
- FloatTypeConfigurator min(float min);
-
- /**
- * defines a max value rule validation.
- */
- FloatTypeConfigurator max(float max);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FloatTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FloatTypeConfiguratorImpl.java
deleted file mode 100644
index 0af865a..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/FloatTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.MaxFloatRule;
-import com.jonpereiradev.jfile.reader.rule.column.MinFloatRule;
-
-final class FloatTypeConfiguratorImpl extends AbstractRuleConfigurator implements FloatTypeConfigurator {
-
- FloatTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public FloatTypeConfigurator min(float min) {
- return rule(position -> new MinFloatRule(position, min));
- }
-
- @Override
- public FloatTypeConfigurator max(float max) {
- return rule(position -> new MaxFloatRule(position, max));
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/GenericTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/GenericTypeConfigurator.java
deleted file mode 100644
index 291c24e..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/GenericTypeConfigurator.java
+++ /dev/null
@@ -1,105 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.time.format.DateTimeFormatter;
-import java.util.regex.Pattern;
-
-public interface GenericTypeConfigurator {
-
- /**
- * defines a rule for a column of short type.
- */
- ShortTypeConfigurator shortType();
-
- /**
- * defines a rule for a column of integer type.
- */
- IntegerTypeConfigurator integerType();
-
- /**
- * defines a rule for a column of long type.
- */
- LongTypeConfigurator longType();
-
- /**
- * defines a rule for a column of float type.
- */
- FloatTypeConfigurator floatType();
-
- /**
- * defines a rule for a column of double type.
- */
- DoubleTypeConfigurator doubleType();
-
- /**
- * defines a rule for a column of boolean type.
- */
- BooleanTypeConfigurator booleanType();
-
- /**
- * defines a rule for a column of character type.
- */
- CharacterTypeConfigurator characterType();
-
- /**
- * defines a rule for a column of string type.
- */
- StringTypeConfigurator stringType();
-
- /**
- * defines a rule for a column of big integer type.
- */
- BigIntegerTypeConfigurator bigIntegerType();
-
- /**
- * defines a rule for a column of big decimal type.
- */
- BigDecimalTypeConfigurator bigDecimalType();
-
- /**
- * defines a rule for a column of big decimal type.
- */
- BigDecimalTypeConfigurator bigDecimalType(DecimalFormat decimalFormat);
-
- /**
- * defines a rule for a column of date type.
- */
- DateTypeConfigurator dateType();
-
- /**
- * defines a rule for a column of date type.
- */
- DateTypeConfigurator dateType(DateFormat pattern);
-
- /**
- * defines a rule for a column of local date type.
- */
- LocalDateTypeConfigurator localDateType();
-
- /**
- * defines a rule for a column of local date type.
- */
- LocalDateTypeConfigurator localDateType(DateTimeFormatter dateTimeFormatter);
-
- /**
- * defines a rule for a column of local date time type.
- */
- LocalDateTimeTypeConfigurator localDateTimeType();
-
- /**
- * defines a rule for a column of local date time type.
- */
- LocalDateTimeTypeConfigurator localDateTimeType(DateTimeFormatter dateTimeFormatter);
-
- /**
- * defines a rule for a column of array type.
- */
- ArrayTypeConfigurator arrayOf();
-
- /**
- * defines a rule for a column of array type.
- */
- ArrayTypeConfigurator arrayOf(Pattern pattern);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/GenericTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/GenericTypeConfiguratorImpl.java
deleted file mode 100644
index f088f72..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/GenericTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,164 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.RuleNodeImpl;
-import com.jonpereiradev.jfile.reader.rule.column.*;
-
-import java.text.DateFormat;
-import java.text.DecimalFormat;
-import java.time.format.DateTimeFormatter;
-import java.util.regex.Pattern;
-
-final class GenericTypeConfiguratorImpl implements GenericTypeConfigurator {
-
- private static final Pattern DEFAULT_ARRAY_SEPARATOR = Pattern.compile(",\\s*");
-
- private final int position;
- private final ReaderConfiguration configuration;
- private final RuleNode ruleNode;
-
- GenericTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- this.position = position;
- this.configuration = configuration;
- this.ruleNode = ruleNode;
- }
-
- @Override
- public ShortTypeConfigurator shortType() {
- ShortTypeRule rule = new ShortTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new ShortTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public IntegerTypeConfigurator integerType() {
- IntegerTypeRule rule = new IntegerTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new IntegerTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public LongTypeConfigurator longType() {
- LongTypeRule rule = new LongTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new LongTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public FloatTypeConfigurator floatType() {
- FloatTypeRule rule = new FloatTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new FloatTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public DoubleTypeConfigurator doubleType() {
- DoubleTypeRule rule = new DoubleTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new DoubleTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public BooleanTypeConfigurator booleanType() {
- BooleanTypeRule rule = new BooleanTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new BooleanTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public CharacterTypeConfigurator characterType() {
- CharacterTypeRule rule = new CharacterTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new CharacterTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public StringTypeConfigurator stringType() {
- StringTypeRule rule = new StringTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new StringTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public BigIntegerTypeConfigurator bigIntegerType() {
- BigIntegerTypeRule rule = new BigIntegerTypeRule(position);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new BigIntegerTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
- @Override
- public BigDecimalTypeConfigurator bigDecimalType() {
- return bigDecimalType(configuration.getBigDecimalFormatter());
- }
-
- @Override
- public BigDecimalTypeConfigurator bigDecimalType(DecimalFormat decimalFormat) {
- BigDecimalTypeRule rule = new BigDecimalTypeRule(position, decimalFormat);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new BigDecimalTypeConfiguratorImpl(position, decimalFormat, configuration, rule.getRuleNode());
- }
-
- @Override
- public DateTypeConfigurator dateType() {
- return dateType(configuration.getDateFormat());
- }
-
- @Override
- public DateTypeConfigurator dateType(DateFormat dateFormat) {
- DateTypeRule rule = new DateTypeRule(position, dateFormat);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new DateTypeConfiguratorImpl(position, dateFormat, configuration, rule.getRuleNode());
- }
-
- @Override
- public LocalDateTypeConfigurator localDateType() {
- return localDateType(configuration.getLocalDateFormatter());
- }
-
- @Override
- public LocalDateTypeConfigurator localDateType(DateTimeFormatter dateTimeFormatter) {
- LocalDateTypeRule rule = new LocalDateTypeRule(position, dateTimeFormatter);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new LocalDateTypeConfiguratorImpl(position, dateTimeFormatter, configuration, rule.getRuleNode());
- }
-
- @Override
- public LocalDateTimeTypeConfigurator localDateTimeType() {
- return localDateTimeType(configuration.getLocalDateTimeFormatter());
- }
-
- @Override
- public LocalDateTimeTypeConfigurator localDateTimeType(DateTimeFormatter dateTimeFormatter) {
- LocalDateTimeTypeRule rule = new LocalDateTimeTypeRule(position, dateTimeFormatter);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new LocalDateTimeTypeConfiguratorImpl(position, dateTimeFormatter, configuration, rule.getRuleNode());
- }
-
- @Override
- public ArrayTypeConfigurator arrayOf() {
- return arrayOf(DEFAULT_ARRAY_SEPARATOR);
- }
-
- @Override
- public ArrayTypeConfigurator arrayOf(Pattern pattern) {
- ArrayOfTypeRule rule = new ArrayOfTypeRule(position, pattern);
- rule.setRuleNode(new RuleNodeImpl<>(rule.getClass(), ruleNode));
- ruleNode.add(rule);
- return new ArrayTypeConfiguratorImpl(position, configuration, rule.getRuleNode());
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/IntegerTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/IntegerTypeConfigurator.java
deleted file mode 100644
index 3e335fa..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/IntegerTypeConfigurator.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface IntegerTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a min value rule validation.
- */
- IntegerTypeConfigurator min(int min);
-
- /**
- * defines a max value rule validation.
- */
- IntegerTypeConfigurator max(int max);
-
- /**
- * defines a domain rule validation with possible values options.
- */
- IntegerTypeConfigurator domain(Integer... values);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/IntegerTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/IntegerTypeConfiguratorImpl.java
deleted file mode 100644
index a4124c3..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/IntegerTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.DomainIntegerRule;
-import com.jonpereiradev.jfile.reader.rule.column.MaxIntegerRule;
-import com.jonpereiradev.jfile.reader.rule.column.MinIntegerRule;
-
-import java.util.Arrays;
-
-final class IntegerTypeConfiguratorImpl extends AbstractRuleConfigurator implements IntegerTypeConfigurator {
-
- IntegerTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public IntegerTypeConfigurator min(int min) {
- return rule(position -> new MinIntegerRule(position, min));
- }
-
- @Override
- public IntegerTypeConfigurator max(int max) {
- return rule(position -> new MaxIntegerRule(position, max));
- }
-
- @Override
- public IntegerTypeConfigurator domain(Integer... values) {
- return rule(position -> new DomainIntegerRule(position, Arrays.asList(values)));
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LineRuleConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LineRuleConfigurator.java
deleted file mode 100644
index 603b921..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LineRuleConfigurator.java
+++ /dev/null
@@ -1,15 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface LineRuleConfigurator {
-
- /**
- * define the number of columns for one line.
- */
- LineRuleConfigurator columns(int size);
-
- /**
- * creates the rule configuration for the column at position.
- */
- GenericTypeConfigurator column(int position);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LineRuleConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LineRuleConfiguratorImpl.java
deleted file mode 100644
index 3c704df..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LineRuleConfiguratorImpl.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.line.LineColumnSizeRule;
-
-final class LineRuleConfiguratorImpl implements LineRuleConfigurator {
-
- private final ReaderConfiguration configuration;
-
- LineRuleConfiguratorImpl(ReaderConfiguration configuration) {
- this.configuration = configuration;
- }
-
- @Override
- public LineRuleConfigurator columns(int size) {
- configuration.getRuleConfiguration().getLineRootNode().add(new LineColumnSizeRule(size));
- return this;
- }
-
- @Override
- public GenericTypeConfigurator column(int position) {
- return new GenericTypeConfiguratorImpl(position, configuration, configuration.getRuleConfiguration().getColumnRootNode());
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTimeTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTimeTypeConfigurator.java
deleted file mode 100644
index ea21206..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTimeTypeConfigurator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.time.LocalDateTime;
-
-public interface LocalDateTimeTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a future rule validation.
- */
- LocalDateTimeTypeConfigurator future();
-
- /**
- * defines a future or present rule validation.
- */
- LocalDateTimeTypeConfigurator futureOrPresent();
-
- /**
- * defines a past rule validation.
- */
- LocalDateTimeTypeConfigurator past();
-
- /**
- * defines a past or present rule validation.
- */
- LocalDateTimeTypeConfigurator pastOrPresent();
-
- /**
- * defines a min date rule validation.
- */
- LocalDateTimeTypeConfigurator after(LocalDateTime min);
-
- /**
- * defines a min date rule validation comparing to another column.
- */
- LocalDateTimeTypeConfigurator after(int columnPosition);
-
- /**
- * defines a max date rule validation.
- */
- LocalDateTimeTypeConfigurator before(LocalDateTime max);
-
- /**
- * defines a max date rule validation comparing to another column.
- */
- LocalDateTimeTypeConfigurator before(int columnPosition);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTimeTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTimeTypeConfiguratorImpl.java
deleted file mode 100644
index 2c167e1..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTimeTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.*;
-
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
-
-final class LocalDateTimeTypeConfiguratorImpl
- extends AbstractRuleConfigurator implements LocalDateTimeTypeConfigurator {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- LocalDateTimeTypeConfiguratorImpl(
- int position,
- DateTimeFormatter dateTimeFormatter,
- ReaderConfiguration configuration,
- RuleNode ruleNode
- ) {
- super(position, configuration, ruleNode);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public LocalDateTimeTypeConfigurator future() {
- return rule(position -> new LocalDateTimeFutureRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTimeTypeConfigurator futureOrPresent() {
- return rule(position -> new LocalDateTimeFutureOrPresentRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTimeTypeConfigurator past() {
- return rule(position -> new LocalDateTimePastRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTimeTypeConfigurator pastOrPresent() {
- return rule(position -> new LocalDateTimePastOrPresentRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTimeTypeConfigurator after(LocalDateTime min) {
- return rule(position -> new LocalDateTimeAfterRule(position, dateTimeFormatter, min));
- }
-
- @Override
- public LocalDateTimeTypeConfigurator after(int column) {
- return rule(position -> new LocalDateTimeAfterRule(position, dateTimeFormatter, column));
- }
-
- @Override
- public LocalDateTimeTypeConfigurator before(LocalDateTime max) {
- return rule(position -> new LocalDateTimeBeforeRule(position, dateTimeFormatter, max));
- }
-
- @Override
- public LocalDateTimeTypeConfigurator before(int column) {
- return rule(position -> new LocalDateTimeBeforeRule(position, dateTimeFormatter, column));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTypeConfigurator.java
deleted file mode 100644
index ea6188c..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTypeConfigurator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.time.LocalDate;
-
-public interface LocalDateTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a future rule validation.
- */
- LocalDateTypeConfigurator future();
-
- /**
- * defines a future or present rule validation.
- */
- LocalDateTypeConfigurator futureOrPresent();
-
- /**
- * defines a past rule validation.
- */
- LocalDateTypeConfigurator past();
-
- /**
- * defines a past or present rule validation.
- */
- LocalDateTypeConfigurator pastOrPresent();
-
- /**
- * defines a min date rule validation.
- */
- LocalDateTypeConfigurator after(LocalDate min);
-
- /**
- * defines a min date rule validation comparing to another column.
- */
- LocalDateTypeConfigurator after(int columnPosition);
-
- /**
- * defines a max date rule validation.
- */
- LocalDateTypeConfigurator before(LocalDate max);
-
- /**
- * defines a max date rule validation comparing to another column.
- */
- LocalDateTypeConfigurator before(int columnPosition);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTypeConfiguratorImpl.java
deleted file mode 100644
index a8b090f..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LocalDateTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.*;
-
-import java.time.LocalDate;
-import java.time.format.DateTimeFormatter;
-
-final class LocalDateTypeConfiguratorImpl
- extends AbstractRuleConfigurator implements LocalDateTypeConfigurator {
-
- private final DateTimeFormatter dateTimeFormatter;
-
- LocalDateTypeConfiguratorImpl(
- int position,
- DateTimeFormatter dateTimeFormatter,
- ReaderConfiguration configuration,
- RuleNode ruleNode
- ) {
- super(position, configuration, ruleNode);
- this.dateTimeFormatter = dateTimeFormatter;
- }
-
- @Override
- public LocalDateTypeConfigurator future() {
- return rule(position -> new LocalDateFutureRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTypeConfigurator futureOrPresent() {
- return rule(position -> new LocalDateFutureOrPresentRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTypeConfigurator past() {
- return rule(position -> new LocalDatePastRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTypeConfigurator pastOrPresent() {
- return rule(position -> new LocalDatePastOrPresentRule(position, dateTimeFormatter));
- }
-
- @Override
- public LocalDateTypeConfigurator after(LocalDate min) {
- return rule(position -> new LocalDateAfterRule(position, dateTimeFormatter, min));
- }
-
- @Override
- public LocalDateTypeConfigurator after(int columnPosition) {
- return rule(position -> new LocalDateAfterRule(position, dateTimeFormatter, columnPosition));
- }
-
- @Override
- public LocalDateTypeConfigurator before(LocalDate max) {
- return rule(position -> new LocalDateBeforeRule(position, dateTimeFormatter, max));
- }
-
- @Override
- public LocalDateTypeConfigurator before(int columnPosition) {
- return rule(position -> new LocalDateBeforeRule(position, dateTimeFormatter, columnPosition));
- }
-
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LongTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LongTypeConfigurator.java
deleted file mode 100644
index 470d683..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LongTypeConfigurator.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface LongTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a min value rule validation.
- */
- LongTypeConfigurator min(long min);
-
- /**
- * defines a max value rule validation.
- */
- LongTypeConfigurator max(long max);
-
- /**
- * defines a domain rule validation with possible values options.
- */
- LongTypeConfigurator domain(Long... values);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LongTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LongTypeConfiguratorImpl.java
deleted file mode 100644
index b1160d8..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/LongTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.DomainLongRule;
-import com.jonpereiradev.jfile.reader.rule.column.MaxLongRule;
-import com.jonpereiradev.jfile.reader.rule.column.MinLongRule;
-
-import java.util.Arrays;
-
-final class LongTypeConfiguratorImpl extends AbstractRuleConfigurator implements LongTypeConfigurator {
-
- LongTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public LongTypeConfigurator min(long min) {
- return rule(position -> new MinLongRule(position, min));
- }
-
- @Override
- public LongTypeConfigurator max(long max) {
- return rule(position -> new MaxLongRule(position, max));
- }
-
- @Override
- public LongTypeConfigurator domain(Long... values) {
- return rule(position -> new DomainLongRule(position, Arrays.asList(values)));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/RefRuleConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/RefRuleConfigurator.java
deleted file mode 100644
index e836843..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/RefRuleConfigurator.java
+++ /dev/null
@@ -1,25 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-/**
- * Configurate the reference column rule.
- *
- * @param the type of rule configurator returned.
- */
-public interface RefRuleConfigurator> {
-
- /**
- * creates a rule for not empty column.
- */
- T filled();
-
- /**
- * creates a rule for column with specific values.
- */
- T filled(Object... values);
-
- /**
- * creates a rule for column with empty value.
- */
- T empty();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/RefRuleConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/RefRuleConfiguratorImpl.java
deleted file mode 100644
index 4b31e08..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/RefRuleConfiguratorImpl.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.RuleNodeImpl;
-import com.jonpereiradev.jfile.reader.rule.column.*;
-
-import java.util.Arrays;
-
-final class RefRuleConfiguratorImpl> implements RefRuleConfigurator {
-
- private final int refPosition;
- private final int position;
- private final T currentConfigurator;
- private final RuleNode rule;
-
- RefRuleConfiguratorImpl(int refPosition, int position, RuleNode ruleNode, T currentConfigurator) {
- this.refPosition = refPosition;
- this.position = position;
- this.currentConfigurator = currentConfigurator;
- this.rule = ruleNode;
- }
-
- @Override
- public T filled() {
- RefRule ref = new FilledRefRule(refPosition, position);
- ref.setRuleNode(new RuleNodeImpl<>(ref.getClass(), rule));
- rule.add(ref);
- currentConfigurator.setRuleNode(ref.getRuleNode());
- return currentConfigurator;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public T filled(Object... values) {
- RefRule ref = new DomainRefRule(refPosition, position, Arrays.asList(values));
- ref.setRuleNode(new RuleNodeImpl<>(ref.getClass(), rule));
- rule.add(ref);
- currentConfigurator.setRuleNode(ref.getRuleNode());
- return currentConfigurator;
- }
-
- @Override
- public T empty() {
- RefRule ref = new EmptyRefRule(refPosition, position);
- ref.setRuleNode(new RuleNodeImpl<>(ref.getClass(), rule));
- rule.add(ref);
- currentConfigurator.setRuleNode(ref.getRuleNode());
- return currentConfigurator;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ShortTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ShortTypeConfigurator.java
deleted file mode 100644
index 08f1883..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ShortTypeConfigurator.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-public interface ShortTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a min value rule validation.
- */
- ShortTypeConfigurator min(short min);
-
- /**
- * defines a max value rule validation.
- */
- ShortTypeConfigurator max(short max);
-
- /**
- * defines a domain rule validation with possible values options.
- */
- ShortTypeConfigurator domain(Short... values);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ShortTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ShortTypeConfiguratorImpl.java
deleted file mode 100644
index a7c0e4a..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/ShortTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.DomainShortRule;
-import com.jonpereiradev.jfile.reader.rule.column.MaxShortRule;
-import com.jonpereiradev.jfile.reader.rule.column.MinShortRule;
-
-import java.util.Arrays;
-
-final class ShortTypeConfiguratorImpl extends AbstractRuleConfigurator implements ShortTypeConfigurator {
-
- ShortTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public ShortTypeConfigurator min(short min) {
- return rule(position -> new MinShortRule(position, min));
- }
-
- @Override
- public ShortTypeConfigurator max(short max) {
- return rule(position -> new MaxShortRule(position, max));
- }
-
- @Override
- public ShortTypeConfigurator domain(Short... values) {
- return rule(position -> new DomainShortRule(position, Arrays.asList(values)));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/StringTypeConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/StringTypeConfigurator.java
deleted file mode 100644
index 88a8823..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/StringTypeConfigurator.java
+++ /dev/null
@@ -1,47 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import java.util.regex.Pattern;
-
-public interface StringTypeConfigurator extends TypedRuleConfigurator {
-
- /**
- * defines a not empty rule validation.
- */
- StringTypeConfigurator notEmpty();
-
- /**
- * defines a min length rule validation.
- */
- StringTypeConfigurator min(int min);
-
- /**
- * defines a max length rule validation.
- */
- StringTypeConfigurator max(int max);
-
- /**
- * defines a domain rule validation with possible values options.
- */
- StringTypeConfigurator domain(String... values);
-
- /**
- * defines an email rule validation.
- */
- StringTypeConfigurator email();
-
- /**
- * defines a brazilian document CPF rule validation.
- */
- StringTypeConfigurator cpf();
-
- /**
- * defines a brazilian document CNPJ rule validation.
- */
- StringTypeConfigurator cnpj();
-
- /**
- * defines a pattern rule validation.
- */
- StringTypeConfigurator regex(Pattern pattern);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/StringTypeConfiguratorImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/StringTypeConfiguratorImpl.java
deleted file mode 100644
index a7e6419..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/StringTypeConfiguratorImpl.java
+++ /dev/null
@@ -1,55 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.configuration.ReaderConfiguration;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.*;
-
-import java.util.Arrays;
-import java.util.regex.Pattern;
-
-final class StringTypeConfiguratorImpl extends AbstractRuleConfigurator implements StringTypeConfigurator {
-
- StringTypeConfiguratorImpl(int position, ReaderConfiguration configuration, RuleNode ruleNode) {
- super(position, configuration, ruleNode);
- }
-
- @Override
- public StringTypeConfigurator notEmpty() {
- return rule(NotEmptyRule::new);
- }
-
- @Override
- public StringTypeConfigurator min(int min) {
- return rule(position -> new MinStringRule(position, min));
- }
-
- @Override
- public StringTypeConfigurator max(int max) {
- return rule(position -> new MaxStringRule(position, max));
- }
-
- @Override
- public StringTypeConfigurator domain(String... values) {
- return rule(position -> new DomainStringRule(position, Arrays.asList(values)));
- }
-
- @Override
- public StringTypeConfigurator email() {
- return rule(EmailRule::new);
- }
-
- @Override
- public StringTypeConfigurator cpf() {
- return rule(CpfRule::new);
- }
-
- @Override
- public StringTypeConfigurator cnpj() {
- return rule(CnpjRule::new);
- }
-
- @Override
- public StringTypeConfigurator regex(Pattern pattern) {
- return rule(position -> new RegexRule(position, pattern));
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/TypedRuleConfigurator.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/TypedRuleConfigurator.java
deleted file mode 100644
index e556849..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/configurator/TypedRuleConfigurator.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.configurator;
-
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-
-import java.util.function.Function;
-
-public interface TypedRuleConfigurator> {
-
- /**
- * apply the rule of not null validation.
- */
- T notNull();
-
- /**
- * apply the rule of only null validation.
- */
- T onlyNull();
-
- /**
- * apply the current depends configuration and return to the root configuration node.
- */
- T apply();
-
- /**
- * define a custom rule validation.
- */
- T rule(Function rule);
-
- /**
- * creates the rule configuration for the column at position.
- */
- GenericTypeConfigurator column(int position);
-
- /**
- * creates the dependency rule validation between columns.
- */
- RefRuleConfigurator depends(int column);
-
- /**
- * changes the current node rule validation.
- */
- void setRuleNode(RuleNode ruleNode);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/file/FileRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/file/FileRule.java
deleted file mode 100644
index 48a7bca..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/file/FileRule.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.file;
-
-import com.jonpereiradev.jfile.reader.rule.Rule;
-
-import java.io.File;
-
-public interface FileRule extends Rule {
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/line/LineColumnSizeRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/line/LineColumnSizeRule.java
deleted file mode 100644
index 7d71307..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/line/LineColumnSizeRule.java
+++ /dev/null
@@ -1,16 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.line;
-
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-
-public class LineColumnSizeRule implements LineRule {
-
- private final int size;
-
- public LineColumnSizeRule(int size) {
- this.size = size;
- }
-
- public boolean isValid(JFileLine fileLine) {
- return fileLine.getColumns().size() == size;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/rule/line/LineRule.java b/src/main/java/com/jonpereiradev/jfile/reader/rule/line/LineRule.java
deleted file mode 100644
index c3c83d5..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/rule/line/LineRule.java
+++ /dev/null
@@ -1,14 +0,0 @@
-package com.jonpereiradev.jfile.reader.rule.line;
-
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.rule.Rule;
-import org.apache.commons.lang3.StringUtils;
-
-public interface LineRule extends Rule {
-
- @Override
- default boolean canValidate(JFileLine fileLine) {
- return StringUtils.isNotBlank(fileLine.getContent());
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/stream/AbstractStreamReader.java b/src/main/java/com/jonpereiradev/jfile/reader/stream/AbstractStreamReader.java
deleted file mode 100644
index 6c974dd..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/stream/AbstractStreamReader.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.stream;
-
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-public abstract class AbstractStreamReader implements StreamReader {
-
- private final InputStream inputStream;
- private final Charset charset;
-
- protected AbstractStreamReader(InputStream inputStream, Charset charset) {
- this.inputStream = inputStream;
- this.charset = charset;
- }
-
- public InputStream getInputStream() {
- return inputStream;
- }
-
- public Charset getCharset() {
- return charset;
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/stream/DefaultStreamReader.java b/src/main/java/com/jonpereiradev/jfile/reader/stream/DefaultStreamReader.java
deleted file mode 100644
index d66edd2..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/stream/DefaultStreamReader.java
+++ /dev/null
@@ -1,67 +0,0 @@
-package com.jonpereiradev.jfile.reader.stream;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.nio.charset.Charset;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-final class DefaultStreamReader extends AbstractStreamReader {
-
- private final BufferedReader reader;
-
- DefaultStreamReader(InputStream inputStream, Charset charset) {
- super(inputStream, charset);
- this.reader = new BufferedReader(new InputStreamReader(inputStream, charset));
- }
-
- @Override
- public Iterator iterator() {
- return new DefaultStreamReaderIterator();
- }
-
- @Override
- public void close() throws IOException {
- reader.close();
- }
-
- private class DefaultStreamReaderIterator implements Iterator {
-
- private String currentLine;
-
- @Override
- public boolean hasNext() {
- if (currentLine == null) {
- try {
- currentLine = reader.readLine();
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- return currentLine != null;
- }
-
- @Override
- public String next() {
- if (currentLine == null) {
- try {
- currentLine = reader.readLine();
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
- }
-
- String line = currentLine;
- currentLine = null;
-
- if (line == null) {
- throw new NoSuchElementException("No more lines to read.");
- }
-
- return line;
- }
- }
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/stream/StreamReader.java b/src/main/java/com/jonpereiradev/jfile/reader/stream/StreamReader.java
deleted file mode 100644
index b01c3ff..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/stream/StreamReader.java
+++ /dev/null
@@ -1,23 +0,0 @@
-package com.jonpereiradev.jfile.reader.stream;
-
-import java.io.Closeable;
-import java.io.InputStream;
-import java.nio.charset.Charset;
-
-public interface StreamReader extends Iterable, Closeable {
-
- static StreamReader defaultStreamReader(InputStream inputStream, Charset charset) {
- return new DefaultStreamReader(inputStream, charset);
- }
-
- /**
- * @return the input stream with the file content.
- */
- InputStream getInputStream();
-
- /**
- * @return the charset of the file content.
- */
- Charset getCharset();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/validation/JFileValidatorEngine.java b/src/main/java/com/jonpereiradev/jfile/reader/validation/JFileValidatorEngine.java
deleted file mode 100644
index c9b3720..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/validation/JFileValidatorEngine.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.jonpereiradev.jfile.reader.validation;
-
-import com.jonpereiradev.jfile.reader.JFileReaderContext;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.rule.RuleViolation;
-
-import java.util.List;
-
-public interface JFileValidatorEngine {
-
- static JFileValidatorEngine defaultEngine(JFileReaderContext context) {
- return new JFileValidatorEngineImpl(context);
- }
-
- List validate(JFileLine line);
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/validation/JFileValidatorEngineImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/validation/JFileValidatorEngineImpl.java
deleted file mode 100644
index f303692..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/validation/JFileValidatorEngineImpl.java
+++ /dev/null
@@ -1,122 +0,0 @@
-package com.jonpereiradev.jfile.reader.validation;
-
-import com.jonpereiradev.jfile.reader.JFileReaderContext;
-import com.jonpereiradev.jfile.reader.file.JFileColumn;
-import com.jonpereiradev.jfile.reader.file.JFileLine;
-import com.jonpereiradev.jfile.reader.rule.RuleNode;
-import com.jonpereiradev.jfile.reader.rule.RuleViolation;
-import com.jonpereiradev.jfile.reader.rule.column.ArrayOfTypeRule;
-import com.jonpereiradev.jfile.reader.rule.column.ColumnRule;
-import com.jonpereiradev.jfile.reader.rule.column.RefRule;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.SortedSet;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-final class JFileValidatorEngineImpl implements JFileValidatorEngine {
-
- private final JFileReaderContext context;
-
- JFileValidatorEngineImpl(JFileReaderContext context) {
- this.context = context;
- }
-
- @Override
- public List validate(JFileLine line) {
- List violations = new ArrayList<>();
-
- checkLineRuleViolation(line, violations);
-
- if (violations.isEmpty()) {
- checkColumnRuleViolation(line, violations);
- }
-
- return Collections.unmodifiableList(violations);
- }
-
- private void checkLineRuleViolation(JFileLine line, List violations) {
- context.getRuleConfiguration().getLineRootNode().forEach(rule -> {
- if (rule.canValidate(line) && !rule.isValid(line)) {
- RuleViolation violation = new RuleViolation();
-
- violation.setRow(line.getRow());
- violation.setColumn(-1);
- violation.setContent(line.getContent());
- violation.setRule(rule.getClass().getSimpleName());
-
- violations.add(violation);
- }
- });
- }
-
- private void checkColumnRuleViolation(JFileLine line, List violations) {
- SortedSet columns = line.getColumns();
-
- columns.forEach(column -> {
- RuleNode rules = context.getRuleConfiguration().getColumnRootNode();
- violations.addAll(validateColumnRules(line, column, rules));
- });
- }
-
- private List validateColumnRules(JFileLine fileLine, JFileColumn column, RuleNode node) {
- Stream stream = node.getChildrens().stream();
- List filtered = stream.filter(o -> o.getPosition() == column.getPosition()).collect(Collectors.toList());
- List violations = new ArrayList<>();
-
- for (ColumnRule rule : filtered) {
- JFileColumn fileColumn = isRefRule(rule) ? getDependsColumn(fileLine, (RefRule) rule) : column;
-
- rule.setFileLine(fileLine);
-
- if (rule instanceof ArrayOfTypeRule) {
- ArrayOfTypeRule arrayOf = (ArrayOfTypeRule) rule;
- arrayOf.split(column).forEach(o -> violations.addAll(validateColumnRules(fileLine, o, rule.getRuleNode())));
- } else if (rule.canValidate(fileColumn)) {
- recursivelyValidate(fileLine, column, rule, violations);
- }
-
- if (!violations.isEmpty()) {
- break;
- }
- }
-
- return violations;
- }
-
- private void recursivelyValidate(JFileLine line, JFileColumn column, ColumnRule rule, List violations) {
- if (!rule.isValid(column)) {
- createViolation(line, column, rule, violations);
- } else {
- violations.addAll(validateColumnRules(line, column, rule.getRuleNode()));
- }
- }
-
- private void createViolation(JFileLine line, JFileColumn column, ColumnRule rule, List violations) {
- RuleViolation violation = new RuleViolation();
-
- violation.setRow(line.getRow());
- violation.setColumn(column.getPosition());
- violation.setContent(column.getText());
- violation.setRule(rule.getClass().getName());
-
- violations.add(violation);
- }
-
- private boolean isRefRule(ColumnRule rule) {
- return rule instanceof RefRule && ((RefRule) rule).getRefPosition() != -1;
- }
-
- private JFileColumn getDependsColumn(JFileLine line, RefRule refRule) {
- JFileColumn refColumn = line.getColumn(refRule.getRefPosition());
-
- if (refColumn == null) {
- throw new NullPointerException("Column doesn't exists at " + refRule.getRefPosition() + "position");
- }
-
- return refColumn;
- }
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/validation/Report.java b/src/main/java/com/jonpereiradev/jfile/reader/validation/Report.java
deleted file mode 100644
index 162013f..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/validation/Report.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.jonpereiradev.jfile.reader.validation;
-
-import com.jonpereiradev.jfile.reader.rule.RuleViolation;
-
-import java.util.List;
-
-public interface Report {
-
- static Report defaultReport() {
- return new ReportImpl();
- }
-
- void put(int row, RuleViolation violation);
-
- void put(int row, List violations);
-
- boolean isValid();
-
- boolean isInvalid();
-
- List getViolations(int row);
-
- List getViolations(int row, int position);
-
- List getViolations();
-
-}
diff --git a/src/main/java/com/jonpereiradev/jfile/reader/validation/ReportImpl.java b/src/main/java/com/jonpereiradev/jfile/reader/validation/ReportImpl.java
deleted file mode 100644
index 8dcd1db..0000000
--- a/src/main/java/com/jonpereiradev/jfile/reader/validation/ReportImpl.java
+++ /dev/null
@@ -1,80 +0,0 @@
-package com.jonpereiradev.jfile.reader.validation;
-
-import com.jonpereiradev.jfile.reader.rule.RuleViolation;
-
-import java.util.*;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-final class ReportImpl implements Report {
-
- private final Map violationsPerRow = new TreeMap<>();
-
- public void put(int row, RuleViolation violation) {
- if (!violationsPerRow.containsKey(row)) {
- violationsPerRow.put(row, new ReportLineValidation());
- }
-
- violationsPerRow.get(row).add(violation);
- }
-
- public void put(int row, List violations) {
- if (!violationsPerRow.containsKey(row)) {
- violationsPerRow.put(row, new ReportLineValidation());
- }
-
- violationsPerRow.get(row).addAll(violations);
- }
-
- @Override
- public boolean isValid() {
- return getViolations().isEmpty();
- }
-
- @Override
- public boolean isInvalid() {
- return !getViolations().isEmpty();
- }
-
- @Override
- public List getViolations(int row) {
- if (violationsPerRow.containsKey(row)) {
- return Collections.unmodifiableList(violationsPerRow.get(row).violations);
- }
-
- return Collections.emptyList();
- }
-
- @Override
- public List