Giter Club home page Giter Club logo

configurable's Introduction

configurable

Simply save and load field values to/from a file by adding an annotation to a field.

Behavior

  • class is registered
  • Registration is looking for existing config file
  • if found: apply all stored configs to all classes
  • values are converted from String to Object and vice versa (see String2ValueConverter)

Limitations

  • fields must not be final

Usage

Here are some hints, how to use the lib. Refer to ConfigRegistration.java for more info.

Annotate a field:

@Configurable(comment = "Document this field", defValue = "false", spezis = {	"TYPE1", "TYPE2" })
private static boolean fieldBool;

options:

  • comment: document the field
  • defValue: default value if no value is stored yet. Optional for static fields, but recommended
  • spezis: 0 or more "specializations". Makes it possible to store different values at the same time
  • defValueSpezis: if you use spezis, use this instead of defValue
  • category: force config category. This is useful if you have muliple different categories (files) in one class.

Register a class:

<fields with @Configurable:>

static
{
	ConfigRegistration.registerClass("yourCategory", <your class>.class);
}

<no @Configurables!!>

Register a callback

ConfigRegistration.registerConfigurableCallback("<your category>", new IConfigObserver()
{
    @Override
    public void afterApply(IConfigClient configClient)
    {
        // called after all values were applied.
    }
});

Apply config and spezis

If you have instance (non-static) fields, you have to apply the config after instantiation. If you want to apply a different spezi, you have to do so as well:

ConfigRegistration.applySpezis(obj, cat, spezi);

Save values to file

ConfigRegistration.save("<yourCategory>");

Files are saved as config/.xml

configurable's People

Contributors

dependabot[bot] avatar g3force avatar

Stargazers

 avatar

Watchers

 avatar  avatar

configurable's Issues

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.