Coder Social home page Coder Social logo

sconf4j's Introduction

License Build Status Quality Gate GitHub issues Sputnik

Simple Configurator for Java

The Simple Configurator for Java software library provides a simple configurator interface which enables a Java application to read configuration data from properties easily.

Basic usage

String prefix = "prefix";
ExampleConfiguration config = ConfiguratorFactory.configurator(ConfigurationOwner.class).get(ExampleConfiguration.class, properties, prefix);

Based on interface definition

    public interface ExampleConfiguration {   

        public int getIndex();

        public String getName();

        public boolean isSomething();

        @Mapping(value = Integer.class)
        public ArrayList<Integer> getArray();

        public int getDefined();

        public int getDefined(int defaultValueIfNoExist);

        public Class<?> getType();

        public Enum getEnum();

        public char getC();

        public Inner[][] getOthers();

        public interface Inner {

            public String getField();

            public String getField2();
        }

        public enum Enum {
            ONE,
            TWO
        }
    }

Data from properties

Properties properties = new Properties();
properties.setProperty("prefix.index", "111");
properties.setProperty("prefix.defined", "1");
properties.setProperty("prefix.others.0.0.field", "field-0.0-1");
properties.setProperty("prefix.others.0.0.field2", "field-0.0-2");
properties.setProperty("prefix.others.0.1.field", "field-0.1-1");
properties.setProperty("prefix.others.0.1.field2", "field-0.1-2");
properties.setProperty("prefix.others.1.0.field", "field-1.0-1");
properties.setProperty("prefix.others.1.0.field2", "field-1.0-2");
properties.setProperty("prefix.others.1.1.field", "field-1.1-1");
properties.setProperty("prefix.others.1.1.field2", "field-1.1-2");
properties.setProperty("prefix.others.2.0.field", "field-2.0-1");
properties.setProperty("prefix.others.2.1.field2", "field-2.1-2");
properties.setProperty("prefix.others.2.2.field", "field-2.2-1");
properties.setProperty("prefix.others.3.0.field2", "field-3.0-2");
properties.setProperty("prefix.name", "supername");
properties.setProperty("prefix.something", "True");
properties.setProperty("prefix.array.0", "10");
properties.setProperty("prefix.array.1", "1");
properties.setProperty("prefix.array.2", "1");
properties.setProperty("prefix.array.3", "3");
properties.setProperty("prefix.array.4", "3");
properties.setProperty("prefix.array.5", "3");
properties.setProperty("prefix.enum", "ONE");
properties.setProperty("prefix.type", "java.lang.String");
properties.setProperty("prefix.c", "c");

Maven install

mvn clean install

Maven local repository dependency

<dependency>
    <groupId>com.github.dperezcabrera</groupId>
    <artifactId>sconf4j</artifactId>
    <version>0.0.1-SNAPSHOT</version>
</dependency>

sconf4j's People

Contributors

dperezcabrera avatar

Watchers

James Cloos avatar  avatar

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.