Skip to content

Latest commit

 

History

History
65 lines (52 loc) · 2.36 KB

robe-convert.md

File metadata and controls

65 lines (52 loc) · 2.36 KB

robe-convert


Convert bundle for dropwizard.It manages file importing and exporting between formats(xls, xlsx, xml, csv, tsv, json) to POJOs with the help of annotations. Annotations prevents the developer to write extra code for validating the procedure.

Motivation

Creating a basic system for different libraries. Helping user to do the most important importing and exporting operations with one annotation.

Getting started

You have to complete 3 steps in order to start using robe-convert bundle.

  • Add dependency (Maven sample)
<dependency>
  <groupId>io.robe</groupId>
  <artifactId>robe-convert</artifactId>
  <version>0.5.0</version>
</dependency>
  • Use @Convert annotation to makes you . Sample:
public class SamplePojo {

    @Convert(order = 0, unique = true, title = "User Id")
    private int id;

    @Convert(order = 0)
    private String name;
...

Now it is ready for import&export operations with all formats below.

  • User importer or exporter to complete the operation.
CSVImporter<SamplePojo> importer = new CSVImporter<>(SamplePojo.class);
List<SamplePojo> list = importer.importStream(new FileInputStream(outputFile.getPath()));

!!! You can look at the test classes for sample usage !!!

Details

Usage and details will be explained below.

Libraries

Usage

Please look at the test classes for sample usage. If you really want to see a quick demo ...

CSVExporter<SamplePojo> exporter = new CSVExporter(SamplePojo.class);
exporter.exportStream(outputStream, TestData.getData().iterator());

CSVImporter<SamplePojo> importer = new CSVImporter<>(SamplePojo.class);
List<SamplePojo> list = importer.importStream(new FileInputStream(outputFile.getPath()));

XLSExporter<SamplePojo> xlsExporter = new XLSExporter(SamplePojo.class, false);
xlsExporter.exportStream(outputStream, TestData.getData().iterator());

XLSImporter<SamplePojo> xlsImporter = new XLSImporter(SamplePojo.class, false);
List<SamplePojo> list = xlsImporter.importStream(new FileInputStream(outputFile.getPath()));