@Retention(value=RUNTIME) @Target(value=TYPE) @Documented public @interface ManualExportAllowed
Property's contained in the annotated class, for use
with frameworks that take configuration as key-value maps or similar.
Export is not allowed by default. This annotation applies to Properties in the annotated class
as well as those in inner classes/interfaces, however, inner classes can be excluded with
the ManualExportNotAllowed annotation.
useCanonicalName()} and useOutAliases() parameters specify which names for each
Property are included in the export, however, it is easy to rewrite or override the exported
names and values - See AndHow.export(Class[]) for details on performing an export.
Annotation example:
//Allow exports for this class & contained classes
@ManualExportAllowed
public class MyClass {
// Two 'out' alias names are spec'ed, so key-value pairs would be:
// int1out1 : [The value of INT1]
// int1out2 : [The value of INT1]
static IntProp INT1 = IntProp.builder()
.aliasOut("int1out1").aliasOut("int1out2").build();
// No 'out' names are spec'ed. Default annotation options export
// with the canonical name, e.g.: [package].MyClass.INT2.
static IntProp INT2 = IntProp.builder().build();
@ManualExportAllowed(
useCanonicalName = EXPORT_CANONICAL_NAME.NEVER,
useOutAliases = EXPORT_OUT_ALIASES.ALWAYS)
static interface Inner1 {
// No 'out' names are spec'ed. The canonical option is
// set to NEVER, so this property is not be included.
static StrProp STR1 = StrProp.builder().build();
}
//Inherits 'export allowed' from the containing class
static class Allowed { ... }
//Block export for other contained classes or interfaces
@ManualExportNotAllowed
static class No { ...Properties in here cannot be exported... }
}
| Modifier and Type | Optional Element and Description |
|---|---|
Exporter.EXPORT_CANONICAL_NAME |
useCanonicalName
Specifies when canonical names should be included in the list of export names.
|
Exporter.EXPORT_OUT_ALIASES |
useOutAliases
Specifies if out aliases should be included in the list of export names.
|
public abstract Exporter.EXPORT_CANONICAL_NAME useCanonicalName
The default, Exporter.EXPORT_CANONICAL_NAME.ONLY_IF_NO_OUT_ALIAS, will include a
Property's canonical name only if the Property has no out aliases specified.
Combinations of this option and useOutAliases can result in multiple names for the
same Property in the list of exported key-value pairs.
public abstract Exporter.EXPORT_OUT_ALIASES useOutAliases
'Out' aliases are alternate names for a Property for the purpose of export, so generally
they are intended to be included. Thus, the default is Exporter.EXPORT_OUT_ALIASES.ALWAYS.
Properties may have multiple out alias names and a canonical name, so its possible to have multiple names for the same Property in the list of exported key-value pairs.
Copyright © 2022. All rights reserved.