Class RulesBuilder
java.lang.Object
org.cojen.boxtin.RulesBuilder
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final class
Builder of rules at the class level.static final class
Builder of rules at the module level.static final class
Builder of rules at the package level. -
Constructor Summary
ConstructorsConstructorDescriptionConstruct an instance which uses the boot module layer for discovering modules, packages, and classes.RulesBuilder
(ModuleLayer layer) Construct an instance which uses the given module layer for discovering modules, packages, and classes. -
Method Summary
Modifier and TypeMethodDescriptionallowAll()
Allow access to all packages, superseding all previous rules.applyAllowRules
(RulesApplier applier) Applies only the allow rules from the given applier to this builder.applyDenyRules
(RulesApplier applier) Applies only the deny rules from the given applier to this builder.applyRules
(RulesApplier applier) Applies all the rules from the given applier to this builder.build()
Returns an immutable set of rules based on what's been defined so far.denyAll()
Deny access to all packages, superseding all previous rules.Define specific rules against the given module, which can supersede all previous rules.Define specific rules against the given module, which can supersede all previous rules.Returns theModuleLayer
used by this builder.validate()
Validates that all classes are loadable, and that all class members are found.Validates that all classes are loadable, and that all class members are found.
-
Constructor Details
-
RulesBuilder
public RulesBuilder()Construct an instance which uses the boot module layer for discovering modules, packages, and classes. -
RulesBuilder
Construct an instance which uses the given module layer for discovering modules, packages, and classes.
-
-
Method Details
-
moduleLayer
Returns theModuleLayer
used by this builder. -
applyRules
Applies all the rules from the given applier to this builder.- Returns:
- this
-
applyDenyRules
Applies only the deny rules from the given applier to this builder.- Returns:
- this
-
applyAllowRules
Applies only the allow rules from the given applier to this builder.- Returns:
- this
-
denyAll
Deny access to all packages, superseding all previous rules. This action is recursive, denying access to all packages, classes, constructors, etc.- Returns:
- this
-
allowAll
Allow access to all packages, superseding all previous rules. This action is recursive, allowing access to all packages, classes, constructors, etc.- Returns:
- this
-
forModule
Define specific rules against the given module, which can supersede all previous rules.- Parameters:
name
- fully qualified module name- Throws:
IllegalArgumentException
- if the module isn't found
-
forModule
Define specific rules against the given module, which can supersede all previous rules.- Parameters:
name
- fully qualified module nameminVersion
- optional minimummodule version number
to support (inclusive)maxVersion
- optional maximummodule version number
to support (exclusive)- Throws:
IllegalArgumentException
- if the module isn't found, or if the version is out of bounds, or if the min/max versions provided aren't parseable
-
validate
Validates that all classes are loadable, and that all class members are found. An exception is thrown if validation fails.- Returns:
- this
- Throws:
NullPointerException
- if layer is nullIllegalStateException
- if validation fails
-
validate
Validates that all classes are loadable, and that all class members are found. An exception is thrown if validation fails.- Parameters:
reporter
- pass non-null for reporting multiple validation failures- Returns:
- this
- Throws:
NullPointerException
- if layer is nullIllegalStateException
- if validation fails
-
build
Returns an immutable set of rules based on what's been defined so far.- Throws:
IllegalStateException
- if a package is defined in multiple modules
-