Save yourself from Saving

Audience: Android programmers

What is this about?

This is a tool for Java developers who want to persist a Java Collection. This library is storing data in SQLite Database.

What’s a Floppy disk?

What’s a Floppy disk?

Topic: SaveList

Vision: To persist each java collection with one command and get the same with one command. Give away the boring saving work this library.

Let's start with List

Java Collection declared in Fields can be annotated to help this library to generate boilerplate code for you. This library uses annotation processor to generate code.

  • Eliminate SQLite implementation.

  • Saves the complete List of Class object with a key. Key should be unique and POJO Class should be Serializable

  • Gives back the Complete List associated with the key

public class PlayGround extends Activity {

    final String vehiclekey = "vehiclekey";

    @SaveList(key = vehiclekey)
    List<Vehicle> westCoastCars = new ArrayList<>();

    List<Vehicle> eastCoastCars = new ArrayList<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_play_ground);

        westCoastCars.add(new Vehicle("BMW", 3500));
        westCoastCars.add(new Vehicle("AUDI", 3500));
        westCoastCars.add(new Vehicle("TESLA", 3500));
        EscapeSQLBoiler.getEscapeSQLBoiler(this).saveMyList(vehiclekey, westCoastCars);

        eastCoastCars = EscapeSQLBoiler.getEscapeSQLBoiler(this).giveMyListSavedInKey(vehiclekey);
        for (Vehicle p : eastCoastCars) {
            System.out.println(p);
        }

    }
}

Remember:  Object-Relational Mapping (ORM) libraries can also save you from direct DB operation

Here we are trying to abstract from its implementation so that saving data can be changed independently. Today we are using SQLite. Tommorow it would be NoSQLite.

Wait !! (What’s NoSQLite)

Wait !! (What’s NoSQLite)

Library path

https://dl.bintray.com/bipinayetra/maven/com/bipinayetra/save-processor/

https://dl.bintray.com/bipinayetra/maven/com/bipinayetra/save-annotation/

Download

dependencies {
    annotationProcessor 'com.bipinayetra:save-processor:1.0.0'
    implementation 'com.bipinayetra:save-annotation:1.0.0'
}

To use Save List library, add the plugin to your buildscript:

allprojects {
    repositories {
        maven {
            url "https://dl.bintray.com/bipinayetra/maven"
        }
    }
}

Now make sure your class as Serializable type.

class Vehicle implements Serializable {
    String type;
    int engineCC;
...
}

You can also view this information on Blog GitHub Pages.


Bipin AyetraComment