Java Code Examples for org.apache.deltaspike.core.api.config.ConfigResolver#Converter

The following examples show how to use org.apache.deltaspike.core.api.config.ConfigResolver#Converter . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseConfigPropertyProducer.java    From deltaspike with Apache License 2.0 6 votes vote down vote up
public <T> ConfigResolver.TypedResolver<T> asResolver(final String key, final String stringDefault,
                                                      final Type ipCls,
                                                      final Class<? extends ConfigResolver.Converter> converterType,
                                                      final String parameterizedBy,
                                                      final boolean projectStageAware, final boolean evaluate)
{
    final ConfigResolver.UntypedResolver<String> untypedResolver = ConfigResolver.resolve(key);
    final ConfigResolver.TypedResolver<T> resolver =
            (ConfigResolver.Converter.class == converterType ?
                    untypedResolver.as(Class.class.cast(ipCls)) :
                    untypedResolver.as(ipCls, BeanProvider.getContextualReference(converterType)))
                    .withCurrentProjectStage(projectStageAware);
    if (!ConfigProperty.NULL.equals(stringDefault))
    {
        resolver.withStringDefault(stringDefault);
    }
    if (!ConfigProperty.NULL.equals(parameterizedBy))
    {
        resolver.parameterizedBy(parameterizedBy);
    }
    return resolver.evaluateVariables(evaluate);
}
 
Example 2
Source File: BaseConfigPropertyProducer.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public <T> T readEntry(final String key, final String stringDefault, final Type ipCls,
                       final Class<? extends ConfigResolver.Converter> converterType,
                       final String parameterizedBy, final boolean projectStageAware, final boolean evaluate)
{
    final ConfigResolver.TypedResolver<T> resolver = asResolver(
            key, stringDefault, ipCls, converterType, parameterizedBy, projectStageAware, evaluate);
    return resolver.getValue();
}
 
Example 3
Source File: TypedResolverImpl.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <N> ConfigResolver.TypedResolver<N> as(Class<N> clazz, ConfigResolver.Converter<N> converter)
{
    configEntryType = clazz;
    this.converter = converter;

    return (ConfigResolver.TypedResolver<N>) this;
}
 
Example 4
Source File: TypedResolverImpl.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("unchecked")
public <N> ConfigResolver.TypedResolver<N> as(Type clazz, ConfigResolver.Converter<N> converter)
{
    configEntryType = clazz;
    this.converter = converter;

    return (ConfigResolver.TypedResolver<N>) this;
}
 
Example 5
Source File: ConfigurationExtension.java    From deltaspike with Apache License 2.0 5 votes vote down vote up
public void collectDynamicTypes(@Observes ProcessBean<?> processBean)
{
    for (final InjectionPoint ip : processBean.getBean().getInjectionPoints())
    {
        final ConfigProperty annotation = ip.getAnnotated().getAnnotation(ConfigProperty.class);
        if (annotation == null || annotation.converter() == ConfigResolver.Converter.class)
        {
            continue;
        }

        dynamicConfigTypes.add(ip.getType());
    }
}