@Retention(value=RUNTIME) @Target(value={TYPE,METHOD}) public @interface ConditionalOnProperty
Conditional
that checks if the specified properties have a specific value. By
default the properties must be present in the Environment
and
not equal to false
. The havingValue()
and
matchIfMissing()
attributes allow further customizations.
The havingValue()
attribute can be used to specify the value that the property
should have. The table below shows when a condition matches according to the property
value and the havingValue()
attribute:
Property Value | havingValue="" |
havingValue="true" |
havingValue="false" |
havingValue="foo" |
---|---|---|---|---|
"true" |
yes | yes | no | no |
"false" |
no | no | yes | no |
"foo" |
yes | no | no | yes |
If the property is not contained in the Environment
at all, the
matchIfMissing()
attribute is consulted. By default missing attributes do not
match.
Modifier and Type | Optional Element and Description |
---|---|
String |
havingValue
The string representation of the expected value for the properties.
|
boolean |
matchIfMissing
Specify if the condition should match if the property is not set.
|
String[] |
name
The name of the properties to test.
|
String |
prefix
A prefix that should be applied to each property.
|
boolean |
relaxedNames
If relaxed names should be checked.
|
String[] |
value
Alias for
name() . |
public abstract String prefix
public abstract String[] name
app.config
and one value is my-value
, the fully key would be
app.config.my-value
Use the dashed notation to specify each property, that is all lower case with a "-"
to separate words (e.g. my-long-property
).
public abstract String havingValue
false
.Copyright © 2016 Pivotal Software, Inc.. All rights reserved.