public abstract class StringValueResolver<T> extends Osgl.F1<String,T>
string value into
a certain type of object instance.| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Object> |
attributes |
| Modifier | Constructor and Description |
|---|---|
|
StringValueResolver() |
protected |
StringValueResolver(Class<T> targetType) |
| Modifier and Type | Method and Description |
|---|---|
static <T> void |
addPredefinedResolver(Class<T> type,
StringValueResolver<T> resolver) |
StringValueResolver<T> |
amended(AnnotationAware beanSpec)
Returns an amended copy of this resolver based on the
AnnotationAware
provided. |
T |
apply(String s)
Apply this function to <T> type parameter.
|
protected <V> V |
attribute(String key)
Get attribute of this resolver by key specified
|
StringValueResolver<T> |
attribute(String key,
Object value)
Set attribute of this resolver.
|
StringValueResolver<T> |
attributes(Map<String,Object> attributes)
Set attributes to this resolver
Note use this method only on new resolver instance instead of shared instance
|
StringValueResolver<T> |
clearAttributes()
Clear all attributes on this resolver
|
Type |
genericTargetType() |
static void |
main(String[] args) |
static Map<Class,StringValueResolver> |
predefined() |
static <T> StringValueResolver<T> |
predefined(Class<T> type) |
abstract T |
resolve(String value) |
Class<T> |
targetType() |
static <T> StringValueResolver<T> |
wrap(Osgl.Function<String,T> func,
Class<T> targetType) |
andThen, andThen, applyOrElse, compose, compose, compose, compose, compose, compose, curry, invert, lift, orElse, timesbreakOutpublic Type genericTargetType()
public final T apply(String s) throws NotAppliedException, Osgl.Break
Osgl.FunctionIn case implementing a partial function, it can throw out an
NotAppliedException if the function is not defined for
the given parameter(s)
s - the argumentU type resultNotAppliedException - if the function doesn't apply to the parameter(s)Osgl.Break - to short cut collecting operations (fold/reduce) on an containerpublic StringValueResolver<T> attribute(String key, Object value)
key - the attribute keyvalue - the attribute valuepublic StringValueResolver<T> attributes(Map<String,Object> attributes)
attributes - the attributes mappublic StringValueResolver<T> clearAttributes()
protected <V> V attribute(String key)
V - the generic type variable of attribute valuekey - the attribute keypublic StringValueResolver<T> amended(AnnotationAware beanSpec)
AnnotationAware
provided. This method allows resolver implementation to tune the
resolving logic when a certain annotation is provided
By default return `this` resolver instancebeanSpec - the bean spec with annotation informationpublic static <T> StringValueResolver<T> wrap(Osgl.Function<String,T> func, Class<T> targetType)
public static <T> void addPredefinedResolver(Class<T> type, StringValueResolver<T> resolver)
public static Map<Class,StringValueResolver> predefined()
public static <T> StringValueResolver<T> predefined(Class<T> type)
public static void main(String[] args)
Copyright © 2017. All Rights Reserved.