Class MetaDataProducerHelper
Note that all of the public methods here use sortMetaDataProducers,
which by default will sort by the sortOrder specified in the producer objects,
then by the type that they return, and finally by their class simple name, then
full name.
But - this sorting by class names was added in 0.40.0. Prior to that,
there was no tie breaker on the sort. To restore the previous behavior, set
the system property qqq.MetaDataProducerHelper.disableNameTiebreaker
to true.
By default, a class that can't be used as a producer (e.g., it has no
no-arg constructor, its constructor throws, or its annotations are wrong), or
a producer that fails while running, is logged as a warning and skipped. To
fail fast instead (throw a QException), set
QInstance.withFailOnMetaDataProducerError(true), or the system
property qqq.metaData.failOnProducerError to true.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic List<MetaDataProducerInterface<?>> findProducers(QInstance instance, String packageName) Find (but do not run) the meta-data producers in (and under) a package.static List<MetaDataProducerInterface<?>> findProducers(String packageName) Find (but do not run) the meta-data producers in (and under) a package.Getter for tableMetaDataCustomizerstatic booleanisFailOnProducerError(QInstance instance) Check if producer errors should fail fast (throw a QException) instead of being logged as warnings: true if the instance's failOnMetaDataProducerError flag is on, or if the system propertyqqq.metaData.failOnProducerErroristrue.static voidprocessAllMetaDataProducersInPackage(QInstance instance, String packageName) Recursively find all classes in the given package, that implement MetaDataProducerInterface run them, and add their output to the given qInstance.static voidprocessAllMetaDataProducersInPackage(QInstance instance, String packageName, MetaDataCustomizerInterface<QTableMetaData> tableMetaDataCustomizer) Recursively find all classes in the given package, that implement MetaDataProducerInterface run them, and add their output to the given qInstance - using the provided tableMetaDataCustomizer to help with all RecordEntity's that are configured to make tables.voidsetTableMetaDataCustomizer(MetaDataCustomizerInterface<QTableMetaData> tableMetaDataCustomizer) Setter for tableMetaDataCustomizerstatic voidsortMetaDataProducers(List<MetaDataProducerInterface<?>> producers) sort a list of producers: First by the sortOrder specified in the producer objects.voidwithTableMetaDataCustomizer(MetaDataCustomizerInterface<QTableMetaData> tableMetaDataCustomizer) Fluent setter for tableMetaDataCustomizer
-
Field Details
-
FAIL_ON_PRODUCER_ERROR_PROPERTY
- See Also:
-
-
Constructor Details
-
MetaDataProducerHelper
public MetaDataProducerHelper()
-
-
Method Details
-
processAllMetaDataProducersInPackage
public static void processAllMetaDataProducersInPackage(QInstance instance, String packageName, MetaDataCustomizerInterface<QTableMetaData> tableMetaDataCustomizer) throws QException Recursively find all classes in the given package, that implement MetaDataProducerInterface run them, and add their output to the given qInstance - using the provided tableMetaDataCustomizer to help with all RecordEntity's that are configured to make tables. Note - they'll be sorted by the sortOrder they provide.- Throws:
QException
-
findProducers
public static List<MetaDataProducerInterface<?>> findProducers(String packageName) throws QException Find (but do not run) the meta-data producers in (and under) a package. With no QInstance, only the system property can turn on fail-fast - seeisFailOnProducerError(QInstance).- Throws:
QException
-
findProducers
public static List<MetaDataProducerInterface<?>> findProducers(QInstance instance, String packageName) throws QException Find (but do not run) the meta-data producers in (and under) a package.A class that can't be used as a producer (e.g., it has no no-arg constructor, its constructor throws, or its annotations are wrong) is logged as a warning and skipped - unless fail-fast is on for the given instance (see
isFailOnProducerError(QInstance)), in which case a QException is thrown.- Parameters:
instance- only used to check if fail-fast is on. May be null.- Throws:
QException
-
sortMetaDataProducers
sort a list of producers: First by the sortOrder specified in the producer objects. Second based on their types, so kinds that depend on other kinds come later. Third, by class simple name, and 4th by full class name, to give stable ordering (unless opt'ed out by system property).Note, we use simple name before full name, in case, for some reason, you wanted to control the sort by naming your classes a certain way - easier to change Simple names than packages.
-
processAllMetaDataProducersInPackage
public static void processAllMetaDataProducersInPackage(QInstance instance, String packageName) throws QException Recursively find all classes in the given package, that implement MetaDataProducerInterface run them, and add their output to the given qInstance. Note - they'll be sorted by the sortOrder they provide. A producer that fails is logged as a warning and skipped - unless fail-fast is on for the instance (see isFailOnProducerError), in which case a QException is thrown.- Throws:
QException
-
isFailOnProducerError
Check if producer errors should fail fast (throw a QException) instead of being logged as warnings: true if the instance's failOnMetaDataProducerError flag is on, or if the system propertyqqq.metaData.failOnProducerErroristrue.The system property is read on every call (not cached), so tests can change it - and this isn't a hot code path.
- Parameters:
instance- may be null, in which case only the system property is checked.
-
getTableMetaDataCustomizer
Getter for tableMetaDataCustomizer -
setTableMetaDataCustomizer
public void setTableMetaDataCustomizer(MetaDataCustomizerInterface<QTableMetaData> tableMetaDataCustomizer) Setter for tableMetaDataCustomizer -
withTableMetaDataCustomizer
public void withTableMetaDataCustomizer(MetaDataCustomizerInterface<QTableMetaData> tableMetaDataCustomizer) Fluent setter for tableMetaDataCustomizer
-