Code Monkey home page Code Monkey logo

storebox's Issues

methods using @DefaultValue should cache value

Each time a get method using a @DefaultValue annotation is invoked the resource identifier is resolved to a value. Since this is static, it should only be needed to get it the first time and then store it in a cache private to the InvocationHandler.

Remove?

I can't remove values. Putting null causes exeption.

Using Enum as default value

Can you please help me how to define a shared preference that returns enum. I have defined my interface as below. please help me to understand what is it that I am not doing right.

public interface Preferences
{
    enum OAuthProvider
    {
        GOOGLE, FACEBOOK
    }

    @KeyByString("key_login_status")
    boolean getLoginStatus(boolean defaultLoginStatus);

    @KeyByString("key_login_status")
    void setLoginStatus(boolean value);

    @KeyByString("oauth_provider")
    OAuthProvider getOAuthProvider(OAuthProvider defaultOAuthProvider);

    @KeyByString("oauth_provider")
    @TypeAdapter(OAuthProvider)
    void setOAuthProvider(OAuthProvider value);
}

Set<String> support

Haven't had much time trying out your lib yet, but I like the idea. Just gave source a look but haven't noticed support for Set set & get operations.

improved type adapter declarations

Bind the type adapters at interface-level to keys, as opposed to requiring each method which uses a custom type to use the TypeAdapter annotation.

This should result in less duplication for the definitions, and should also pave the way for caching the type adapter instances when the invocation handler is created as opposed to instantiating them on each method invocation (where required) and then just throwing them away.

Clear method request

What if I want to clear all key-value pairs by using one single clear method?

add caching of method annotations

Caching the KeyByString, KeyByValue, RemoveMethod, RegisterChangeListenerMethod, UnregisterChangeListenerMethod should provide a speed-up so the annotations wouldn't be required to be read on each method invocation, but only the first time.

No way to create custom enum TypeAdapters

Because you can't access type from adaptFromPreferences(String value). For example, I want my prefenence return null if I renamed enum field. Now it will produce java.lang.IllegalArgumentException: No enum constant for...

or I may want to choose first enum field as default value for all enums etc.

Not wokring harness package

Not wokring harness package.

I wanted to use your class, but the IDE does not see the class CustomClassListTypeAdapter.

I added library through Gradle

allow other types through custom type adapters

To chain away from having to only support boolean/float/int/long/String due to the native SharedPreferences/Editor, type adapters could be added for serialising and de-serialising user-defined types. Or even build-in type adapters could be provided for some common types (ie Date).

investigate annotation processors

Could we do something like check that methods (whether single or pairs of set/get) annotated with @KeyByXXX have the same value/default/return types? Check invalid, or superfluous, annotations?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.