Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
* A configuration is a map from name to values,
* as such the contract for configuration is to map
* what names are associated with each values
* and provide a convenient mechanism for instantiating full maps
*
* The contract between this library
* User defines 2 interfaces: the configuration interface is a read-only interface,
* representing the completed (ready to consume) configuration
* example:
*
*
* interface MyConfiguration {
* String myProperty1()
* int whateverName()
* MyValueClass myPropety3()
* // A configuration most likely needs to be composited hierarchically
* MySubConfiguration subConfiguration()
* // ... and so on
* }
*
*
* That's on one hand, the read-only interface defines the finished product (the sausage)
*
* In addition the client needs to declare how the sausage is made with a builder interface
*
* interface MyConfigurationBuilder {
*
* // All setters method will "return this" allowing setters chaining
* // A setter is any method that takes one parameter and return the bvuilder type
* MyConfigurationBuilder myProperty1 ( String val_ );
* MyConfigurationBuilder whateverName ( int val_ );
* MyConfigurationBuilder myProperty3( MyValueClass val_ );
* MyConfigurationBuilder subConfiguration ( MySubConfiguration sub_ );
* // ...
*
* // special methods
* // done finishes the building phase, and constructs the finished product
* // It'll throw IllegalStateException if not all properties have been set
* MyConfiguration done();
* }
*
*
*/
public class ReflectiveConfigurator {
/**
* DefaultsToString can be attached to any string read-property
* specifying that in case the property is not explicitly set by the builder
* it will be defaulted to the anotation value
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public static @interface DefaultsToString {
String val();
}
/**
* Declare default value for int propety that it annotates
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public static @interface DefaultsToInteger {
int val();
}
/**
* When the configuration value is a class
* provides the default value in case the property is not set in the builder
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public static @interface DefaultsToClass {
Class> val();
}
/**
* Apply a function to the supplied value
*/
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD})
public static @interface TransformBy {
Class extends Function