当前位置: 首页>>代码示例>>Java>>正文


Java StringValueResolver类代码示例

本文整理汇总了Java中org.osgl.util.StringValueResolver的典型用法代码示例。如果您正苦于以下问题:Java StringValueResolver类的具体用法?Java StringValueResolver怎么用?Java StringValueResolver使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


StringValueResolver类属于org.osgl.util包,在下文中一共展示了StringValueResolver类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: resolver

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
public <T> StringValueResolver<T> resolver(final Class<T> targetType) {
    StringValueResolver<T> r = resolvers.get(targetType);
    final Class<? extends Enum> clazz = $.cast(targetType);
    if (null == r && Enum.class.isAssignableFrom(targetType)) {
        if (app().config().enumResolvingCaseSensitive()) {
            r = new StringValueResolver<T>(targetType) {
                @Override
                public T resolve(String value) {
                    //TODO should we handle exception here?
                    return (T)Enum.valueOf(clazz, value);
                }
            };
        } else {
            r = new StringValueResolver<T>(targetType) {
                @Override
                public T resolve(String value) {
                    return (T) $.asEnum(clazz, value);
                }
            };
        }
        resolvers.put(targetType, r);
    }
    return r;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:25,代码来源:StringValueResolverManager.java

示例2: findContextSpecificLoader

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
@Override
protected ParamValueLoader findContextSpecificLoader(
        String bindName,
        Class<?> rawType,
        BeanSpec spec,
        Type type,
        Annotation[] annotations
) {
    boolean isArray = rawType.isArray();
    StringValueResolver resolver = findResolver(spec, rawType, isArray); //= isArray ? resolverManager.resolver(rawType.getComponentType(), spec) : resolverManager.resolver(rawType, spec);

    Required required = filter(annotations, Required.class);
    Optional optional = null == required ? filter(annotations, Optional.class) : null;
    if (null != required) {
        return new OptionLoader(bindName, required, resolver, spec);
    } else if (null != optional) {
        return new OptionLoader(bindName, optional, resolver, spec);
    }
    return isArray ? new CliVarArgumentLoader(rawType.getComponentType(), resolver) : new CliArgumentLoader(resolver);
}
 
开发者ID:actframework,项目名称:actframework,代码行数:21,代码来源:CliContextParamLoader.java

示例3: findIndirectAnnotatedResolver

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
private StringValueResolver findIndirectAnnotatedResolver(BeanSpec spec, Class rawType) {
    Annotation[] aa = spec.allAnnotations();
    for (Annotation a : aa) {
        Resolve resolve = AnnotationUtil.tagAnnotation(a, Resolve.class);
        if (null != resolve) {
            Class<? extends StringValueResolver>[] resolvers = resolve.value();
            for (Class<? extends StringValueResolver> resolverClass : resolvers) {
                StringValueResolver resolver = injector.get(resolverClass);
                resolver.attributes($.evaluate(a));
                if (rawType.isAssignableFrom(resolver.targetType())) {
                    return resolver;
                }
            }
        }
    }
    return null;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:18,代码来源:CliContextParamLoader.java

示例4: cast

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
private T cast(Object val, BeanSpec spec) {
    Class<?> type = spec.rawType();
    if (type.isInstance(val)) {
        return (T) val;
    }
    if ($.isSimpleType(type)) {
        StringValueResolver svr = StringValueResolver.predefined(type);
        if (null != svr) {
            return (T) svr.resolve(S.string(val));
        }
    }
    throw new InjectException("Cannot cast value type[%s] to required type[%]", val.getClass(), type);
}
 
开发者ID:osglworks,项目名称:java-di,代码行数:14,代码来源:ConfigurationValueLoader.java

示例5: collectionResolver

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
public <T extends Collection> StringValueResolver<T> collectionResolver(final Class<T> targetType, final Class<?> elementType, final char separator) {
    final StringValueResolver elementResolver = resolver(elementType);
    return new StringValueResolver<T>(targetType) {
        @Override
        public T resolve(String value) {
            T col = app().getInstance(targetType);
            List<String> parts = S.fastSplit(value, String.valueOf(separator));
            for (String part : parts) {
                col.add(elementResolver.resolve(part));
            }
            return col;
        }
    };
}
 
开发者ID:actframework,项目名称:actframework,代码行数:15,代码来源:StringValueResolverManager.java

示例6: found

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
@Override
protected void found(Class<? extends StringValueResolver> target, App app) {
    if (target == Param.DEFAULT_RESOLVER.class) {
        return;
    }
    if (target.isAnnotationPresent(NoAutoRegister.class)) {
        return;
    }
    StringValueResolver resolver = app.getInstance(target);
    app.resolverManager().register(resolver.targetType(), resolver);
}
 
开发者ID:actframework,项目名称:actframework,代码行数:12,代码来源:StringValueResolverFinder.java

示例7: StringValueResolverValueLoaderBase

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
public StringValueResolverValueLoaderBase(ParamKey key, StringValueResolver<?> resolver, Param param, DefaultValue def, Class<?> type, boolean simpleKeyOnly) {
    E.illegalArgumentIf(simpleKeyOnly && !key.isSimple());
    this.paramKey = key;
    this.stringValueResolver = resolver;
    this.defSpec = def;
    Object _defVal = defVal(param, type);
    if (null == _defVal && null != def) {
        _defVal = resolver.resolve(def.value());
    }
    this.defVal = _defVal;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:12,代码来源:StringValueResolverValueLoaderBase.java

示例8: findDirectAnnotatedResolver

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
private StringValueResolver findDirectAnnotatedResolver(BeanSpec spec, Class rawType) {
    Resolve resolve = spec.getAnnotation(Resolve.class);
    if (null != resolve) {
        Class<? extends StringValueResolver>[] resolvers = resolve.value();
        for (Class<? extends StringValueResolver> resolverClass : resolvers) {
            StringValueResolver resolver = injector.get(resolverClass);
            if (rawType.isAssignableFrom(resolver.targetType())) {
                return resolver;
            }
        }
    }
    return null;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:14,代码来源:CliContextParamLoader.java

示例9: OptionLoader

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
OptionLoader(String bindName, Optional optional, StringValueResolver resolver, BeanSpec beanSpec) {
    this.bindName = bindName;
    this.required = false;
    this.parseLeads(optional.lead());
    this.defVal = optional.defVal();
    this.requiredGroup = null;
    this.beanSpec = beanSpec;
    this.errorTemplate = errorTemplate(optional);
    this.resolver = resolver;
    CliContext.ParsingContextBuilder.foundOptional();
}
 
开发者ID:actframework,项目名称:actframework,代码行数:12,代码来源:OptionLoader.java

示例10: resolve

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
private <T> T resolve(String val, StringValueResolver<T> resolver) {
    if (null == errorTemplate) {
        return resolver.resolve(val);
    }
    try {
        return resolver.resolve(val);
    } catch (Exception e) {
        throw E.unexpected(errorTemplate, val);
    }
}
 
开发者ID:actframework,项目名称:actframework,代码行数:11,代码来源:OptionLoader.java

示例11: register

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
@Override
public void register() {
    StringValueResolver.addPredefinedResolver(targetType(), this);
}
 
开发者ID:actframework,项目名称:actframework,代码行数:5,代码来源:StringValueResolverPlugin.java

示例12: amended

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
@Override
public final StringValueResolver<T> amended(AnnotationAware beanSpec) {
    Pattern pattern = beanSpec.getAnnotation(Pattern.class);
    return null == pattern ? this : create(pattern.value());
}
 
开发者ID:actframework,项目名称:actframework,代码行数:6,代码来源:JodaDateTimeCodecBase.java

示例13: register

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
public <T> StringValueResolverManager register(Class<T> targetType, StringValueResolver<T> resolver) {
    resolvers.put(targetType, resolver);
    return this;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:5,代码来源:StringValueResolverManager.java

示例14: resolve

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
public <T> T resolve(String strVal, Class<T> targetType) {
    StringValueResolver<T> r = resolver(targetType);
    return null != r ? r.resolve(strVal) : null;
}
 
开发者ID:actframework,项目名称:actframework,代码行数:5,代码来源:StringValueResolverManager.java

示例15: registerPredefinedResolvers

import org.osgl.util.StringValueResolver; //导入依赖的package包/类
private void registerPredefinedResolvers() {
    resolvers.putAll(StringValueResolver.predefined());
}
 
开发者ID:actframework,项目名称:actframework,代码行数:4,代码来源:StringValueResolverManager.java


注:本文中的org.osgl.util.StringValueResolver类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。