public abstract class StringValueResolver<T> extends Lang.F1<String,T>
A String value resolver resolves a 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
|
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(Lang.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, Lang.Break
Lang.FunctionApply this function to <T> type parameter.
In 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)Lang.Break - to short cut collecting operations (fold/reduce) on an containerpublic StringValueResolver<T> attribute(String key, Object value)
Set attribute of this resolver.
Note use this method only on new resolver instance instead of shared instance
key - the attribute keyvalue - the attribute valuepublic 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
attributes - the attributes mappublic StringValueResolver<T> clearAttributes()
Clear all attributes on this resolver
protected <V> V attribute(String key)
Get attribute of this resolver by key specified
V - the generic type variable of attribute valuekey - the attribute keypublic StringValueResolver<T> amended(AnnotationAware beanSpec)
Returns an amended copy of this resolver based on the AnnotationAware provided. This method allows resolver implementation to tune the resolving logic when a certain annotation is provided
By default return this resolver instance
beanSpec - the bean spec with annotation informationpublic static <T> StringValueResolver<T> wrap(Lang.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 © 2014–2019 OSGL (Open Source General Library). All rights reserved.