public class ManualExportService extends Object
Manual exports are initiated via AndHow.export(Class[]) - See
that method for usage details and examples.
| Constructor and Description |
|---|
ManualExportService() |
| Modifier and Type | Method and Description |
|---|---|
Stream<PropertyExport> |
doManualExport(List<Class<?>> exportRoots,
Collection<GroupProxy> groupList)
Perform an export for a list of Classes.
|
protected void |
exportClass(Class<?> clazz,
Exporter.EXPORT_CANONICAL_NAME canNameOpt,
Exporter.EXPORT_OUT_ALIASES outAliasOpt,
Collection<GroupProxy> groupList,
Collection<PropertyExport> propExports)
Export the Properties contained in a single class with no recursion.
|
protected void |
exportClassAndChildren(Class<?> clazz,
Exporter.EXPORT_CANONICAL_NAME canonicalOption,
Exporter.EXPORT_OUT_ALIASES outAliasOption,
Set<Class<?>> alreadyExportedClasses,
Collection<GroupProxy> groupList,
Collection<PropertyExport> propExports)
Export this class and all contained, nested inner classes if permitted.
|
protected Optional<ManualExportAllowed> |
findEffectiveAllowAnnotation(Class<?> clazz)
Returns the effective
ManualExportAllowed annotation instance if it exists. |
protected Optional<ManualExportAllowed> |
getAllowAnnotation(Class<?> clazz)
Gets the
ManualExportAllowed annotation directly on this class. |
protected boolean |
isManualExportDisallowed(Class<?> clazz)
Returns
true if manual export is explicitly annotated to not be allowed
on this class. |
public Stream<PropertyExport> doManualExport(List<Class<?>> exportRoots, Collection<GroupProxy> groupList) throws IllegalAccessException
An export takes place as follows:
ManualExportAllowed, an exception is thrown.exportClassAndChildren(java.lang.Class<?>, org.yarnandtail.andhow.api.Exporter.EXPORT_CANONICAL_NAME, org.yarnandtail.andhow.api.Exporter.EXPORT_OUT_ALIASES, java.util.Set<java.lang.Class<?>>, java.util.Collection<org.yarnandtail.andhow.api.GroupProxy>, java.util.Collection<org.yarnandtail.andhow.export.PropertyExport>), all Propertys in the class are
discovered and a PropertyExport instance made for each one.ManualExportAllowed annotation that might set different export options.
Only classes for which a GroupProxy exists have Properties and the proxies have the
list of Properties contained in each class.
exportRoots - The list of classes who's Properties should be exported.groupList - The list of GroupProxy's, created during AndHow initialization.IllegalAccessException - If any of the exportRoots are not annotated (directly or
indirectly via a containing class) with ManualExportAllowed.protected void exportClassAndChildren(Class<?> clazz, Exporter.EXPORT_CANONICAL_NAME canonicalOption, Exporter.EXPORT_OUT_ALIASES outAliasOption, Set<Class<?>> alreadyExportedClasses, Collection<GroupProxy> groupList, Collection<PropertyExport> propExports)
findEffectiveAllowAnnotation(java.lang.Class<?>), otherwise incorrect export options
will be used and/or non-exportable (ie private) Properties exported.
Contained classes that are discovered and annotated with ManualExportNotAllowed will
not be exported and no further search within those classes is performed.
The alreadyExportedClasses collection is used to prevent export of classes already
exported. This can happen when this method is called on a list of classes, some of which may
overlap in their contained classes.
clazz - The class (and potentially its contained classes) to export.canonicalOption - The option as annotated on passed class or a class that contains it.outAliasOption - The option as annotated on passed class or a class that contains it.alreadyExportedClasses - Class which have already been exported, to prevent duplicate
exports when a user passes classes nested classes (i.e. a parent class and an inner class).protected void exportClass(Class<?> clazz, Exporter.EXPORT_CANONICAL_NAME canNameOpt, Exporter.EXPORT_OUT_ALIASES outAliasOpt, Collection<GroupProxy> groupList, Collection<PropertyExport> propExports)
clazz - The class to exportcanNameOpt - canonical name optionoutAliasOpt - out alias names optiongroupList - The GroupProxy collection, created during AndHow initialization.propExports - The collection to add the exports to, one per Property.protected Optional<ManualExportAllowed> findEffectiveAllowAnnotation(Class<?> clazz) throws IllegalStateException
ManualExportAllowed annotation instance if it exists.
The effective annotation may be on the clazz itself or a containing class if the clazz is an
inner class. If no annotation is found or a ManualExportNotAllowed annotation is found
closer in the inner class hierarchy, then this class is not manually exportable.
clazz - Determine if this class or its container is annotated for manual export.IllegalStateException - If this class is annotated to both allow and disallow manual exports.protected Optional<ManualExportAllowed> getAllowAnnotation(Class<?> clazz)
ManualExportAllowed annotation directly on this class.
clazz - The class to find the annotation on.protected boolean isManualExportDisallowed(Class<?> clazz)
true if manual export is explicitly annotated to not be allowed
on this class.
This does not consider containing classes, it only checks if there is a 'not allowed' annotation on this class exclusively.
clazz - The class to checkCopyright © 2022. All rights reserved.