Skip to content

Commit

Permalink
Merge pull request #3 from jonpereiradev/develop
Browse files Browse the repository at this point in the history
Release 0.8.0
  • Loading branch information
jonpereiradev authored Oct 5, 2020
2 parents afa2576 + 6cdb5ba commit ec016d0
Show file tree
Hide file tree
Showing 322 changed files with 11,630 additions and 6,346 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/deploy-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Deploy

on:
push:
branches:
- master

jobs:
deploy:
runs-on: ubuntu-18.04
steps:
- name: Check out Git repository
uses: actions/checkout@v2

- name: Install Java and Maven
uses: actions/setup-java@v1
with:
java-version: 1.8

- name: Cache Maven packages
uses: actions/cache@v2
with:
path: ~/.m2
key: ${{ runner.os }}-m2-${{ hashFiles('**/pom.xml') }}
restore-keys: ${{ runner.os }}-m2

- name: Test Maven package
run: mvn -B test --file pom.xml

- name: Build Maven package
run: mvn -B package --file pom.xml -DskipTests

- name: Deploy Sonatype
uses: samuelmeuli/action-maven-publish@v1
with:
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }}
nexus_username: ${{ secrets.OSSRH_USERNAME }}
nexus_password: ${{ secrets.OSSRH_PASSWORD }}
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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.
149 changes: 34 additions & 115 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,127 +1,46 @@
# JFile Reader

This project helps you to build functionalities that needs to read and validate files.
This project provides an easy use and extensible API for read, validate, and parse files into java objects.

## Installation

```xml
<dependency>
<groupId>com.github.jonpereiradev</groupId>
<artifactId>jfile-reader</artifactId>
<version>0.7.0</version>
<groupId>com.github.jonpereiradev</groupId>
<artifactId>jfile-reader</artifactId>
<version>${jfile-reader.version}</version>
</dependency>
```

## JFileReaderFactory

The JFileReaderFactory provides an API to read a file and instanciate the right class to handle the
type of file:

**Example**

```java
public class Main {

public static void main(String[] args) {
String regexColumnSeparator = "\\|";
Path path = Paths.get("path", "to", "file");
ReaderConfiguration readerConfiguration = ReaderConfiguration.utf8Reader(regexColumnSeparator);
JFileReader jFileReader = JFileReaderFactory.newInstance(path, readerConfiguration);
}
}
```

## Annotations

The annotations provided by the jfile reader are:

- __FileColumn:__ to map a column to a wrapper field;
- __DecimalFormatter:__ to map the pattern of a number object;
- __DateTimeFormatter:__ to map the pattern of a date object;

**Example**

```java
public class User {

@FileColumn(1)
private Integer type;

@FileColumn(2)
private Boolean active;

@FileColumn(3)
private String name;

@FileColumn(4)
@DecimalFormatter("#,##0.0#")
private BigDecimal currency;

@FileColumn(5)
@DateTimeFormatter("ddMMyyyy")
private LocalDate dateInactivation;

}
```

```java
public class Main {

public static void main(String[] args) {
String regexColumnSeparator = "\\|";
Path path = Paths.get("path", "to", "file");
ReaderConfiguration readerConfiguration = ReaderConfiguration.utf8Reader(regexColumnSeparator);

try (JFileReader jFileReader = JFileReaderFactory.newInstance(path, readerConfiguration)) {
jFileReader.forEach(User.class, user -> {
System.out.println(user.getType());
System.out.println(user.getActive());
System.out.println(user.getName());
System.out.println(user.getBigDecimal());
System.out.println(user.getDateInactivation());
});
}
}
}
```

## Validations

You can applly validations to the file using the class RuleConfigurator.

**Example**

```java
public class Main {

public static void main(String[] args) {
String regexColumnSeparator = "\\|";
Path path = Paths.get("path", "to", "file");
ReaderConfiguration readerConfiguration = ReaderConfiguration.utf8Reader(regexColumnSeparator);

RuleConfigurator
.defaultConfigurator(readerConfiguration)
.column(1)
.localDateType("dd/MM/yyyy")
.pastOrPresent()
.column(2)
.stringType()
.regex(Pattern.compile("\\d+"));

try (JFileReader jFileReader = JFileReaderFactory.newInstance(path, readerConfiguration)) {
List<RuleViolation> violations = jFileReader.validate();

if (!violations.isEmpty()) {
// handle violations
}

// it's ok? process lines
jFileReader.forEach(User.class, user -> System.out.println(user));
}
}
}
```

# License
## Release Note

**Version:** 0.8.0

- [x] Removing commons-lang dependency
- [x] Refactory JFileLine.getRow() method to JFileLine.getLineNumber() method
- [x] Refactory JFileColumn.getPosition() method to JFileColumn.getColumnNumber() method
- [x] Refactory JFileLine class to LineValue class
- [x] Refactory JFileColumn class to ColumnValue class
- [x] Moving JFileReader validate() method to JFileValidator class
- [X] Refactory Report class to ValidationReport class
- [X] Refactory Report isInvalid method to isNotValid method
- [X] Refactory ReaderConfiguration class to JFileReaderConfig class
- [X] Add throws IOException in JFileReaderFactory methods
- [x] Removing exception suppress from ColumnValue getter methods
- [X] Removing internal complexities
- [X] Removing JFileValidator.validate(fileReader) method
- [X] Adding JFileReader.stream() non-parallel support
- [X] String Rule for exactLength
- [X] Rename rule min and max to minLength and maxLength for string types
- [x] Enrich the API documentation
- [x] MIT License

**Version:** 0.7.0

- [x] Inclusion of method canValidate for Rules
- [x] LocalDate and LocalDateTime validation Rules
- [x] Benchmark implementation with JMH

## License

JFile-Reader is available under the [MIT license](https://tldrlegal.com/license/mit-license).
122 changes: 0 additions & 122 deletions checkstyle.xml

This file was deleted.

Loading

0 comments on commit ec016d0

Please sign in to comment.