Package com.exedio.cope.util
Class Properties
- java.lang.Object
-
- com.exedio.cope.util.Properties
-
- Direct Known Subclasses:
DispatcherProperties
,FactoryProperties
,PoolProperties
,SamplerProperties
,VaultProperties
public class Properties extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Properties.Factory<T extends Properties>
class
Properties.Field<E>
static interface
Properties.Probe
Declares a method to be a probe.static class
Properties.ProbeAbortedException
static class
Properties.PropertiesField<T extends Properties>
static interface
Properties.Source
-
Field Summary
Fields Modifier and Type Field Description static Properties.Source
EMPTY_SOURCE
Deprecated.UseSources.EMPTY
insteadstatic Properties.Source
SYSTEM_PROPERTY_SOURCE
Deprecated.UseSources.SYSTEM_PROPERTIES
instead
-
Constructor Summary
Constructors Constructor Description Properties(Properties.Source source)
Properties(Properties.Source source, Properties.Source context)
Deprecated.UseProperties(Source)
instead.Properties(Properties source, String sourceDescription)
Deprecated.UseProperties(Source, Source)
instead.Properties(Properties source, String sourceDescription, Properties.Source context)
Deprecated.UseProperties(Source, Source)
instead.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
ensureEquality(Properties other)
void
ensureValidity(String... prefixes)
protected Properties.Field<Boolean>
field(String key, boolean defaultValue)
Deprecated.Usevalue(String, boolean)
insteadprotected Properties.Field<Integer>
field(String key, int defaultValue, int minimum)
Deprecated.Usevalue(String, int, int)
insteadprotected Properties.Field<Day>
field(String key, Day defaultValue)
Deprecated.Usevalue(String, Day)
insteadprotected <T extends Properties>
Properties.PropertiesField<T>field(String key, Properties.Factory<T> factory)
Deprecated.Usevalue(String, Factory)
insteadprotected Properties.Field<String>
field(String key, String defaultValue)
Deprecated.Usevalue(String, String)
insteadprotected Properties.Field<File>
fieldFile(String key)
Deprecated.UsevalueFile(String)
insteadProperties.Source
getContext()
String
getContext(String key)
Deprecated.UsegetContext()
instead.static Properties.Source
getContext(Properties properties, String description)
Deprecated.UsegetSource(java.util.Properties,String)
insteadProperties.Field<?>
getField(String key)
List<Properties.Field<?>>
getFields()
Set<String>
getOrphanedKeys()
List<? extends Callable<?>>
getProbes()
Returns all probes of this properties instance.String
getSource()
static Properties.Source
getSource(File file)
Deprecated.UseSources.load(File)
instead.static Properties.Source
getSource(Properties properties, String description)
Deprecated.UseSources.view(java.util.Properties, String)
instead.Properties.Source
getSourceObject()
static Properties.Source
getSystemPropertyContext()
Deprecated.UseSources.SYSTEM_PROPERTIES
insteadstatic Properties.Source
getSystemPropertySource()
Deprecated.UseSources.SYSTEM_PROPERTIES
insteadList<? extends Callable<?>>
getTests()
Deprecated.UseProperties.Probe
insteadstatic Properties
loadProperties(File file)
Deprecated.UseSources.loadProperties(File)
instead.protected IllegalPropertiesException
newException(String key, String detail)
protected IllegalPropertiesException
newException(String key, String detail, Throwable cause)
protected Properties.ProbeAbortedException
newProbeAbortedException(String message)
protected <T extends Properties>
Tvalnp(String key, Properties.Factory<T> factory)
Replacement forvalue(String, Factory)
to avoid javac problem:protected boolean
value(String key, boolean defaultValue)
protected <T extends Properties>
Tvalue(String key, boolean enabledDefault, Properties.Factory<T> factory)
protected int
value(String key, int defaultValue, int minimum)
protected Day
value(String key, Day defaultValue)
protected <T extends Properties>
Tvalue(String key, Properties.Factory<T> factory)
If calling this method causes javac problem:error: reference to value is ambiguous
, usevalnp(String, Factory)
instead.protected <E extends Enum<E>>
Evalue(String key, E defaultValue)
protected <E extends Enum<E>>
Evalue(String key, Class<E> valueClass)
protected String
value(String key, String defaultValue)
protected Charset
value(String key, Charset defaultValue)
protected Duration
value(String key, Duration defaultValue, Duration minimum)
protected Duration
value(String key, Duration defaultValue, Duration minimum, Duration maximum)
protected ZoneId
value(String key, ZoneId defaultValue)
protected File
valueFile(String key)
protected String
valueHidden(String key, String defaultValue)
protected MessageDigestFactory
valueMessageDigest(String key, String defaultValue)
protected Path
valuePath(String key)
protected <T,P>
ServiceFactory<T,P>valueService(String key, Class<? extends T> defaultValue, Class<T> superclass, Class<P> parameterType)
protected <T,P>
ServiceFactory<T,P>valueService(String key, Class<T> superclass, Class<P> parameterType)
Implementations ofsuperclass
to be instantiated byServiceFactory.newInstance(Object)
must have a suitable constructor: The type of the first parameter is specified by parameterparameterType
of this method.protected <T,P>
ServiceFactory<T,P>valueService(String key, String defaultValue, Class<T> superclass, Class<P> parameterType)
-
-
-
Field Detail
-
EMPTY_SOURCE
@Deprecated public static final Properties.Source EMPTY_SOURCE
Deprecated.UseSources.EMPTY
instead
-
SYSTEM_PROPERTY_SOURCE
@Deprecated public static final Properties.Source SYSTEM_PROPERTY_SOURCE
Deprecated.UseSources.SYSTEM_PROPERTIES
instead
-
-
Constructor Detail
-
Properties
public Properties(Properties.Source source)
-
Properties
@Deprecated public Properties(Properties.Source source, Properties.Source context)
Deprecated.UseProperties(Source)
instead. Using context is deprecated at all.
-
Properties
@Deprecated public Properties(Properties source, String sourceDescription)
Deprecated.UseProperties(Source, Source)
instead.
-
Properties
@Deprecated public Properties(Properties source, String sourceDescription, Properties.Source context)
Deprecated.UseProperties(Source, Source)
instead.
-
-
Method Detail
-
getTests
@Deprecated public List<? extends Callable<?>> getTests()
Deprecated.UseProperties.Probe
insteadThis default implementation returnsgetProbes()
.
-
getField
public final Properties.Field<?> getField(String key)
-
getFields
public final List<Properties.Field<?>> getFields()
-
getSourceObject
public final Properties.Source getSourceObject()
-
getSource
public final String getSource()
-
getContext
public final Properties.Source getContext()
- Throws:
IllegalStateException
- if there is no context for these properties.
-
value
protected final boolean value(String key, boolean defaultValue)
-
field
@Deprecated protected final Properties.Field<Boolean> field(String key, boolean defaultValue)
Deprecated.Usevalue(String, boolean)
instead
-
value
protected final int value(String key, int defaultValue, int minimum)
-
field
@Deprecated protected final Properties.Field<Integer> field(String key, int defaultValue, int minimum)
Deprecated.Usevalue(String, int, int)
instead
-
field
@Deprecated protected final Properties.Field<Day> field(String key, Day defaultValue)
Deprecated.Usevalue(String, Day)
instead
-
field
@Deprecated protected final Properties.Field<String> field(String key, String defaultValue)
Deprecated.Usevalue(String, String)
instead
-
fieldFile
@Deprecated protected final Properties.Field<File> fieldFile(String key)
Deprecated.UsevalueFile(String)
instead
-
value
protected final Duration value(String key, Duration defaultValue, Duration minimum, Duration maximum)
-
valueMessageDigest
protected final MessageDigestFactory valueMessageDigest(String key, String defaultValue)
-
valueService
protected final <T,P> ServiceFactory<T,P> valueService(String key, Class<T> superclass, Class<P> parameterType)
Implementations ofsuperclass
to be instantiated byServiceFactory.newInstance(Object)
must have a suitable constructor: The type of the first parameter is specified by parameterparameterType
of this method. The type of the second parameter is specified by annotation @ServiceProperties
at the implementation class. If there is no such annotation, the constructor must have one parameter only. Please note that @ServiceProperties
could beinherited
from a superclass.
-
valueService
protected final <T,P> ServiceFactory<T,P> valueService(String key, Class<? extends T> defaultValue, Class<T> superclass, Class<P> parameterType)
-
valueService
protected final <T,P> ServiceFactory<T,P> valueService(String key, String defaultValue, Class<T> superclass, Class<P> parameterType)
-
value
protected final <T extends Properties> T value(String key, Properties.Factory<T> factory)
If calling this method causes javac problem:error: reference to value is ambiguous
, usevalnp(String, Factory)
instead.
-
valnp
protected final <T extends Properties> T valnp(String key, Properties.Factory<T> factory)
Replacement forvalue(String, Factory)
to avoid javac problem:error: reference to value is ambiguous
https://bugs.java.com/bugdatabase/view_bug.do?bug_id=JDK-8170842
-
value
protected final <T extends Properties> T value(String key, boolean enabledDefault, Properties.Factory<T> factory)
-
field
@Deprecated protected final <T extends Properties> Properties.PropertiesField<T> field(String key, Properties.Factory<T> factory)
Deprecated.Usevalue(String, Factory)
instead
-
newException
protected final IllegalPropertiesException newException(String key, String detail)
-
newException
protected final IllegalPropertiesException newException(String key, String detail, Throwable cause)
-
ensureValidity
public final void ensureValidity(String... prefixes)
-
ensureEquality
public final void ensureEquality(Properties other)
-
newProbeAbortedException
protected final Properties.ProbeAbortedException newProbeAbortedException(String message)
-
getProbes
public final List<? extends Callable<?>> getProbes()
Returns all probes of this properties instance. Probes are methods annotated byProperties.Probe
. The result includes probes of super classes and probes ofnested
properties.- See Also:
getTests()
-
getContext
@Deprecated public final String getContext(String key)
Deprecated.UsegetContext()
instead.- Throws:
IllegalArgumentException
- if the context does not contain a value forkey
.IllegalStateException
- if there is no context for these properties.
-
getSystemPropertySource
@Deprecated public static final Properties.Source getSystemPropertySource()
Deprecated.UseSources.SYSTEM_PROPERTIES
instead
-
getSystemPropertyContext
@Deprecated public static final Properties.Source getSystemPropertyContext()
Deprecated.UseSources.SYSTEM_PROPERTIES
instead
-
getContext
@Deprecated public static final Properties.Source getContext(Properties properties, String description)
Deprecated.UsegetSource(java.util.Properties,String)
instead
-
getSource
@Deprecated public static final Properties.Source getSource(Properties properties, String description)
Deprecated.UseSources.view(java.util.Properties, String)
instead.
-
getSource
@Deprecated public static final Properties.Source getSource(File file)
Deprecated.UseSources.load(File)
instead.
-
loadProperties
@Deprecated public static final Properties loadProperties(File file)
Deprecated.UseSources.loadProperties(File)
instead.
-
-