Package com.demonwav.hypo.core
Class HypoContext
java.lang.Object
com.demonwav.hypo.core.HypoContext
- All Implemented Interfaces:
AutoCloseable
Core context for Hypo executions. A context contains 4 major components:
- The core
provider- The classes to analyze - The context
provider- Additional classes on the classpath for completing the analysis of the core provider - The current
configuration- Global configuration values - The current
executor- The shared executor to use for all multi-threaded work
When a context is closed both providers are closed and the
executor is shut down. The context should never be closed while processes in the executor are
still running. To put that another way, any operations which use the executor should wait for all submitted jobs to
complete before continuing.
Create new instances with builder().
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class for creating new instances ofHypoContext. -
Constructor Summary
ConstructorsConstructorDescriptionHypoContext(@NotNull HypoConfig config, @NotNull ClassDataProvider provider, @NotNull ClassDataProvider contextProvider)Create a new instance ofHypoContext. -
Method Summary
Modifier and TypeMethodDescriptionstatic HypoContext.Builderbuilder()Create a newbuilderfor creating new instances ofHypoContext.voidclose()Returns theconfig.Returns the contextprovider.Returns the currentexecutor, if there is one.Returns the coreprovider.
-
Constructor Details
-
HypoContext
HypoContext(@NotNull @NotNull HypoConfig config, @NotNull @NotNull ClassDataProvider provider, @NotNull @NotNull ClassDataProvider contextProvider)Create a new instance ofHypoContext. Usebuilder()instead.
-
-
Method Details
-
getConfig
Returns theconfig.- Returns:
- The
config.
-
getProvider
Returns the coreprovider.- Returns:
- The core
provider.
-
getContextProvider
Returns the contextprovider.- Returns:
- The context
provider.
-
getExecutor
Returns the currentexecutor, if there is one. If there isn't one already created, a new executor will be created according to theconfigurationand returned. This executor will be used for all subsequent requests until this context isclosed.This method is thread safe: Multiple threads may call it concurrently and they will all receive the same executor. Concurrent accesses to this method while the executor is being created will all receive the same executor.
- Returns:
- The current
executor.
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
builder
Create a newbuilderfor creating new instances ofHypoContext.- Returns:
- A new
HypoContext.Builderinstance.
-