protected static class PropertyExportImpl.PropertyExportWrap extends Object implements PropertyExport
| Constructor and Description |
|---|
PropertyExportWrap(PropertyExport inner)
Construct a wrapper instance that wraps 'inner' and delegates to it for all methods.
|
| Modifier and Type | Method and Description |
|---|---|
Exporter.EXPORT_CANONICAL_NAME |
getCanonicalNameOption()
Option read from the containing
ManualExportAllowed annotation to determine if the
canonical name of the Property should be included. |
Class<?> |
getContainingClass()
The class directly containing the Property.
|
List<String> |
getExportNames()
The complete list of export names for this property, which may be null, empty or many.
|
Exporter.EXPORT_OUT_ALIASES |
getOutAliasOption()
Option read from the containing
ManualExportAllowed annotation to determine if 'out'
aliases of the Property should be included. |
Property<?> |
getProperty()
The Property being exported.
|
Object |
getValue()
Fetch the Object value of the Property, e.g., an Integer Property will return an Integer.
|
String |
getValueAsString()
Fetch the value as a String from the Property.
|
PropertyExport |
mapNames(List<String> exportNames)
Intended for using with Java
stream()s, this method maps this instance to a new one
with new export names. |
PropertyExport |
mapValue(Object value)
Intended for using with Java
stream()s, this method maps this instance to a new one
with a new Object value for the Property, i.e., the 'value' part of a key-value pair. |
PropertyExport |
mapValueAsString(String value)
Intended for using with Java
stream()s, this method maps this instance to a new one
with a new String value for the Property, i.e., the 'value' part of a key-value pair. |
public PropertyExportWrap(PropertyExport inner)
inner - The instance to delegate to for methods.public Property<?> getProperty()
PropertyExportgetProperty in interface PropertyExportpublic Class<?> getContainingClass()
PropertyExportgetContainingClass in interface PropertyExportpublic Exporter.EXPORT_CANONICAL_NAME getCanonicalNameOption()
PropertyExportManualExportAllowed annotation to determine if the
canonical name of the Property should be included.
If included, the canonical name would be included in the list of names returned from
PropertyExport.getExportNames() and then ultimately as one of the names in the final key-value
pairs.
getCanonicalNameOption in interface PropertyExportpublic Exporter.EXPORT_OUT_ALIASES getOutAliasOption()
PropertyExportManualExportAllowed annotation to determine if 'out'
aliases of the Property should be included.
'Out' aliases are alternate names for a Property for the purpose of export, so generally
they are intended to be included.
getOutAliasOption in interface PropertyExportpublic List<String> getExportNames()
PropertyExport
This method builds and returns the default export name list based on the
PropertyExport.getCanonicalNameOption() & PropertyExport.getOutAliasOption() options, or, if
PropertyExport.mapNames(List) was used to construct this instance, the list of names specified.
See AndHow.export(Class[]) for an example that remaps export names.
getExportNames in interface PropertyExportpublic Object getValue()
PropertyExport
Nominally this is the same as getProperty().getValue(), however,
PropertyExport.mapValue(Object) can be used to rewrite the value.
Take care to map the method that will be used by the collector you have chosen:
PropertyExport.getValueAsString(): use PropertyExport.mapValueAsString(String)PropertyExport.getValue(): use PropertyExport.mapValue(Object)getValue in interface PropertyExportpublic String getValueAsString()
PropertyExport
Nominally this is the same as getProperty().getValueAsString(), however,
PropertyExport.mapValueAsString(String) can be used to rewrite the value.
Take care to map the method that will be used by the collector you have chosen:
PropertyExport.getValueAsString(): use PropertyExport.mapValueAsString(String)PropertyExport.getValue(): use PropertyExport.mapValue(Object)
Implementation note: The nominal implementation of this method should call
getProperty().getValueAsString() and not delegate to PropertyExport.getValue(), since the
type returned by getValue may be overridden and not match the Property type.
getValueAsString in interface PropertyExportpublic PropertyExport mapNames(List<String> exportNames)
PropertyExportstream()s, this method maps this instance to a new one
with new export names.
Calling PropertyExport.getExportNames() on the new instance returns the new exportNames.
Specifying an empty or null list of names will remove this Property from export.
See AndHow.export(Class[]) for an example that remaps export names.
mapNames in interface PropertyExportexportNames - A new list of export names to be used, rather than the default ones.public PropertyExport mapValue(Object value)
PropertyExportstream()s, this method maps this instance to a new one
with a new Object value for the Property, i.e., the 'value' part of a key-value pair.
Calling PropertyExport.getValue() on the new instance returns the new value, which may be null.
This example uses mapValue() to multiply Property values by 2 if they are integers:
Map<String, Object> export =
AndHow.instance().export(MyClass.class)
.map(p -> p.mapValue(
(p.getValue() != null && p.getValue() instanceof Integer)
? (Integer)p.getValue() * 2:p.getValue()) )
.collect(ExportCollector.objectMap());
Take care to map the method that will be used by the collector you have chosen:
PropertyExport.getValueAsString(): use PropertyExport.mapValueAsString(String)PropertyExport.getValue(): use PropertyExport.mapValue(Object)mapValue in interface PropertyExportvalue - The new value to return for the value of this Property.public PropertyExport mapValueAsString(String value)
PropertyExportstream()s, this method maps this instance to a new one
with a new String value for the Property, i.e., the 'value' part of a key-value pair.
Calling PropertyExport.getValueAsString() on the new instance returns the new value, which may be null.
This example uses mapValueAsString() to convert Property values to uppercase:
Map<String, String> export =
AndHow.instance().export(MyClass.class)
.map( p -> p.mapValueAsString( p.getValueAsString() != null
? p.getValueAsString().toUpperCase():null) )
.collect(ExportCollector.stringMap());
Take care to map the method that will be used by the collector you have chosen:
PropertyExport.getValueAsString(): use PropertyExport.mapValueAsString(String)PropertyExport.getValue(): use PropertyExport.mapValue(Object)mapValueAsString in interface PropertyExportvalue - The new value to return for the String value of this Property.Copyright © 2022. All rights reserved.