protected PropertyValueGetter createScalarProperty()

in archaius2-core/src/main/java/com/netflix/archaius/ConfigProxyFactory.java [492:514]


    protected <T> PropertyValueGetter<T> createScalarProperty(final Type type, final String propName, Function<Object[], T> defaultValueSupplier) {
        LOG.debug("Creating scalar property `{}` for type `{}`", propName, type.getClass());
        final Property<T> prop = propertyRepository.get(propName, type);
        return new PropertyValueGetter<T>() {
            @Override
            public T invoke(Object[] args) {
                T value = prop.get();
                return value != null ? value : defaultValueSupplier.apply(null);
            }

            @SuppressWarnings({"unchecked"})
            @Override
            public T invokeIgnoreErrors(Object[] args) {
                T value;
                if (prop instanceof DefaultPropertyFactory.ErrorIgnoringProperty) {
                    value = ((DefaultPropertyFactory.ErrorIgnoringProperty<T>) prop).getIgnoreErrors();
                } else {
                    value = prop.get();
                }
                return value != null ? value : defaultValueSupplier.apply(null);
            }
        };
    }