Qwylt

java.lang.module.spi
Class PackageConstraint

java.lang.Object
  extended by java.lang.module.spi.ImportConstraint
      extended by java.lang.module.spi.PackageConstraint

public abstract class PackageConstraint
extends ImportConstraint

An ImportConstraint for the domain of all candidate ModuleArchive instances for a single package name.

Since:
Jan 9, 2009
Author:
Bryan Atsatt

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.module.spi.ImportConstraint
ImportConstraint.Phase
 
Field Summary
static PackageConstraint HAS_ONLY_VALID_CANDIDATES
          A PREPARE and COMMIT phase PackageConstraint instance that removes all failed archives from the domain, and ensures that at least one remains.
static PackageConstraint HAS_PREFERRED_CANDIDATES_FIRST
          A PREPARE phase PackageConstraint instance that sorts the candidates in the domain first by connected state, then by version number in descending order.
 
Fields inherited from class java.lang.module.spi.ImportConstraint
HAS_NO_LOOPBACK_CONNECTIONS, HAS_RE_EXPORTS
 
Constructor Summary
PackageConstraint()
           
 
Method Summary
 void apply(ImportConstraint.Phase phase, ImportSpace domain)
          Applies this constraint if required for the specified phase, potentially reducing the set of candidates in the domain.
protected  ModuleArchive apply(ModuleArchive candidate, java.util.List<ConnectionError> errors)
          Apply the constraint to the specified candidate.
protected  void apply(java.lang.String packageName, java.util.List<? extends ModuleArchive> domain, ModuleArchive importer)
          Applies this constraint, potentially reducing the set of candidates in the domain.
protected  void assertValidDomain(java.util.List<? extends ModuleArchive> domain, java.lang.String packageName, java.util.List<ConnectionError> errors, ModuleArchive importer)
          Assert that the domain is not empty.
 
Methods inherited from class java.lang.module.spi.ImportConstraint
applyIn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

HAS_ONLY_VALID_CANDIDATES

public static final PackageConstraint HAS_ONLY_VALID_CANDIDATES
A PREPARE and COMMIT phase PackageConstraint instance that removes all failed archives from the domain, and ensures that at least one remains.


HAS_PREFERRED_CANDIDATES_FIRST

public static final PackageConstraint HAS_PREFERRED_CANDIDATES_FIRST
A PREPARE phase PackageConstraint instance that sorts the candidates in the domain first by connected state, then by version number in descending order.

Constructor Detail

PackageConstraint

public PackageConstraint()
Method Detail

apply

public void apply(ImportConstraint.Phase phase,
                  ImportSpace domain)
Applies this constraint if required for the specified phase, potentially reducing the set of candidates in the domain.

Specified by:
apply in class ImportConstraint
Parameters:
phase - The phase of the domain.
domain - The domain.
Throws:
ConnectionError - if the constraint is not satisfied.

apply

protected void apply(java.lang.String packageName,
                     java.util.List<? extends ModuleArchive> domain,
                     ModuleArchive importer)
Applies this constraint, potentially reducing the set of candidates in the domain.

Parameters:
packageName - The package name for the domain.
domain - The modifiable domain.
importer - The importer.
Throws:
ConnectionError - if the constraint is not satisfied.

apply

protected ModuleArchive apply(ModuleArchive candidate,
                              java.util.List<ConnectionError> errors)
Apply the constraint to the specified candidate.

Parameters:
candidate - The candidate.
errors - The errors list to add to if an error occurs.
Returns:
The candidate if it satisfies the constraint, a new instance if the candidate should be replaced, or null if the candidate should be removed.

assertValidDomain

protected void assertValidDomain(java.util.List<? extends ModuleArchive> domain,
                                 java.lang.String packageName,
                                 java.util.List<ConnectionError> errors,
                                 ModuleArchive importer)
Assert that the domain is not empty.

Parameters:
domain - The domain.
packageName - The package of the domain.
errors - The errors. May be null.
importer - The importer.
Throws:
ConnectionError - if the domain is empty.

Qwylt

Send comments or questions to Bryan Atsatt