All Downloads are FREE. Search and download functionalities are using the official Maven repository.

framework.annotation.Stringer Maven / Gradle / Ivy

package framework.annotation;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import framework.Tool.Traverser;

/**
 * Value from string
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Stringer {
    /**
     * @return value
     */
    Class> value();

    /**
     * From string and to string
     * 
     * @param  Value type
     */
    interface FromTo {
        /**
         * @param text Text
         * @return Value
         */
        T fromString(String text);

        /**
         * @param value Value
         * @param traverser Callback handler
         */
        default void toString(T value, Traverser traverser) {
            traverser.value(String.valueOf(value), value.getClass(), true);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy