public abstract class AbstractStringResources extends BaseResources
This class retrieves all resources as stored in string format based upon BaseResources.getOptionalStringImpl(String)
.
Constructor and Description |
---|
AbstractStringResources(Class<?> contextClass,
Optional<Resources> parentResources)
Context class constructor.
|
Modifier and Type | Method and Description |
---|---|
Optional<Boolean> |
getOptionalBoolean(String key)
Retrieves a Boolean resource that may not be present.
|
Optional<Double> |
getOptionalDouble(String key)
Retrieves a floating point resource that may not be present.
|
Optional<Integer> |
getOptionalInt(String key)
Retrieves an integer resource that may not be present.
|
boolean |
hasResource(String key)
Determines whether a resource of some type exists for the given resource key.
|
dereferenceString, getOptionalDereferencedString, getOptionalString, getOptionalStringImpl
getContextClass, getParentResources
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBoolean, getDouble, getInt, getString, requireResource
public AbstractStringResources(@Nonnull Class<?> contextClass, @Nonnull Optional<Resources> parentResources)
contextClass
- The context with which these resources are related; usually the class of the object requesting the resource.parentResources
- The parent resources for fallback lookup.NullPointerException
- if the given context class and/or parent resources is null
.public boolean hasResource(@Nonnull String key) throws ResourceConfigurationException
This method searches the parent resources hierarchy if no resource is available in this instance.
This implementation delegates to BaseResources.getOptionalStringImpl(String)
.
key
- The resource key.true
if a resource of type type could be retrieved from these resources using the given key.ResourceConfigurationException
- if there is a resource value stored in an invalid format.public Optional<Boolean> getOptionalBoolean(String key) throws ResourceConfigurationException
This implementation parses the value using Boolean.valueOf(String)
.
key
- The resource key.ResourceConfigurationException
- if there is a resource value stored in an invalid format.public Optional<Double> getOptionalDouble(String key) throws ResourceConfigurationException
This implementation parses the value using Double.valueOf(String)
.
key
- The resource key.ResourceConfigurationException
- if there is a resource value stored in an invalid format.public Optional<Integer> getOptionalInt(String key) throws ResourceConfigurationException
This implementation parses the value using Integer.valueOf(String)
.
key
- The resource key.ResourceConfigurationException
- if there is a resource value stored in an invalid format.Copyright © 2016 GlobalMentor, Inc.. All rights reserved.