All Projects → nolia → Noodle

nolia / Noodle

Licence: MIT license
Simple object storage for Android

Programming Languages

java
68154 projects - #9 most used programming language
groovy
2714 projects
kotlin
9241 projects

Projects that are alternatives of or similar to Noodle

Tupl
The Unnamed Persistence Library
Stars: ✭ 83 (+50.91%)
Mutual labels:  nosql, persistence
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+1203.64%)
Mutual labels:  nosql, persistence
Ardb
A redis protocol compatible nosql, it support multiple storage engines as backend like Google's LevelDB, Facebook's RocksDB, OpenLDAP's LMDB, PerconaFT, WiredTiger, ForestDB.
Stars: ✭ 1,707 (+3003.64%)
Mutual labels:  nosql, persistence
soda-for-java
SODA (Simple Oracle Document Access) for Java is an Oracle library for writing Java apps that work with JSON (and not only JSON!) in the Oracle Database. SODA allows your Java app to use the Oracle Database as a NoSQL document store.
Stars: ✭ 61 (+10.91%)
Mutual labels:  nosql, persistence
Data
ATK Data - Data Access Framework for high-latency databases (Cloud SQL/NoSQL).
Stars: ✭ 243 (+341.82%)
Mutual labels:  nosql, persistence
datanucleus-core
DataNucleus core persistence support - the basis for anything in DataNucleus
Stars: ✭ 112 (+103.64%)
Mutual labels:  persistence
gorm-neo4j
GORM for Neo4j
Stars: ✭ 16 (-70.91%)
Mutual labels:  nosql
AloeDB
Light, Embeddable, NoSQL database for Deno 🦕
Stars: ✭ 111 (+101.82%)
Mutual labels:  nosql
javaer-mind
Java 程序员进阶学习的思维导图
Stars: ✭ 66 (+20%)
Mutual labels:  nosql
iOS-Developer-Nanodegree
Learn how to program apps for the iPhone and iPad
Stars: ✭ 20 (-63.64%)
Mutual labels:  persistence
WordPress-FluxC-Android
WordPress Network and Persistence layer based on the Flux architecture
Stars: ✭ 53 (-3.64%)
Mutual labels:  persistence
nedb-repl
The command-line tool for NeDB
Stars: ✭ 19 (-65.45%)
Mutual labels:  nosql
derivejs
DeriveJS is a reactive ODM - Object Document Mapper - framework, a "wrapper" around a database, that removes all the hassle of data-persistence by handling it transparently in the background, in a DRY manner.
Stars: ✭ 54 (-1.82%)
Mutual labels:  persistence
workshop-intro-to-cassandra
Learn Apache Cassandra fundamentals in this hands-on workshop
Stars: ✭ 208 (+278.18%)
Mutual labels:  nosql
dynamodb-onetable
DynamoDB access and management for one table designs with NodeJS
Stars: ✭ 508 (+823.64%)
Mutual labels:  nosql
malware-persistence
Collection of malware persistence and hunting information. Be a persistent persistence hunter!
Stars: ✭ 109 (+98.18%)
Mutual labels:  persistence
merkle-db
High-scalability analytics database built on immutable merkle-trees
Stars: ✭ 44 (-20%)
Mutual labels:  nosql
jpa-unit
JUnit extension to test javax.persistence entities
Stars: ✭ 28 (-49.09%)
Mutual labels:  persistence
aiohttp-client-cache
An async persistent cache for aiohttp requests
Stars: ✭ 63 (+14.55%)
Mutual labels:  persistence
acebase
A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
Stars: ✭ 288 (+423.64%)
Mutual labels:  nosql

logo

Build Status

Noodle is a simple object storage for Android.

Download

Get it from JitPack.

repositories {
    ...
    maven { url 'https://jitpack.io' }
}

dependencies {
    compile 'com.github.nolia:Noodle:master-SNAPSHOT'
}

Usage

You can use Noodle both as a key-value storage and as collection persistence framework. To initialize Noodle you can use builder:

Noodle noodle = Noodle.with(context).build();

Key-value storage

You can put any type of object to the storage.

noodle.put("Android7", "Nougat").now();

Get stored value.

T value = noodle.get("myObject", T.class).now();

Remove the data.

boolean isRemoved = noodle.delete("toRemove").now();

Collections

Using collections is also really simple: no schema, no relations, no consistency rules, no thread-contained objects. Just create Noodle instance and register types you want to store. The only requirement, that class should have an annotated id field with type of Long or long.

class Book {

  @Id
  long id;

  String title;
  String author;

  public Book(String title, String author) {
    this.title = title;
    this.author = author;
  }
}

Noodle noodle = Noodle.with(context)
  .addType(Book.class)
  .build();

Alternatively, if you don't want or not able to add annotation to the class, you can use Description. You can provide either the name of the field (that it would be set with reflection mechanism):

Noodle noodle = Noodle.with(context)
  .addType(Book.class, Description.of(Book.class)
    .withIdField("id")
    .build()
  );

Or you can specify get and set methods:

Noodle noodle = Noodle.with(context)
  .registerType(Book.class, Description.of(Book.class)
    .withGetIdOperator(book -> book.id))
    .withSetIdOperator((book, id) -> book.id = id)
    .build()
  );

This allows you to use other types as an Id field.

Collections allow you to list, put, delete, get (by id) and filter your objects.

collection = noodle.collectionOf(Book.class);

Book book = new Book("I Robot", "Isaac Asimov");

// Get all.
List<Book> list = collection.all().now();

collection.put(book).now();
// Now, book object has updated id.

// Update:
book.title = "I, Robot";
collection.put(book).now();

// Delete:
collection.delete(book.id).now();

Filter

List<Book> search(final String query) {
  return collection.filter(new Collection.Predicate<Book>() {
    @Override
    public boolean test(final Book book) {
      return book.title.contains(query)
          || book.authorName.contains(query);
    }
  }).now();
}

Filtering is happening in memory, by pulling objects one by one and testing with provided predicate.

Threading

Each operation on collections and key-value storage is synchronized on Storage level. This means that can be only one read/write operation at a time.

All methods return Result object, which wraps the actual results, that you can access either with synchronous now() method, or with callback and get() method.

collection.filter(new Collection.Predicate<Book>() {
      @Override
      public boolean test(final Book book) {
        return book.title.contains(query);
      }
    })
    .executeOn(Executors.newSingleThreadExecutor())
    .withCallback(new Result.Callback<List<Book>>() {
      @Override
      public void onReady(final List<Book> books) {
        adapter.setBooks(books);
      }

      @Override
      public void onError(final Exception e) {
        Log.e(TAG, 'Error getting books:', e);
        Toast.makeText(context, "Could not get your books :(", Toast.LENGTH_SHORT).show();
      }
    })
    .get();

Rx Support

If you prefer RxJava, Noodle is got you covered. You can convert any Result of the operation to Observable:

collection.put(book)
    .toRxObservable()
    .subscribe();

Notes:

  • RxJava v2 is used, so incompatible with version 1
  • Noodle does not ship RxJava transitively, so you have to provide it as a dependency
  • When doing get and delete operations, if item is not found, Noodle is returning null. But if using rx wrapper, due to that it does not allow null emissions, you will get NullPointerException in the onError callback.

Configure

Noodle noodle = Noodle.with(context)
    .converter(converter)
    .filePath(path)
    .encryption(encryption)
    .build();

Every component is pluggable, but Noodle provides defaults:

  • converter - Gson for converting objects to JSON and then to byte arrays
  • encryption - NoEncryption is by default, so nothing is encrypted, but you can easily implement one (it only has 2 methods)

Features:

  • Key-value storage
  • Simple collection storage
  • Simple annotation processing for entities ids
  • Rx Support
  • Encryption

License

MIT license, see more here.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].