rafa.math.gen
Class GeneratorDependency

java.lang.Object
  extended by rafa.dep.SimpleDependency
      extended by rafa.math.gen.GeneratorDependency
All Implemented Interfaces:
Dependency

public class GeneratorDependency
extends SimpleDependency

Dependency of a NumberGenerator on another one. The path does not include any strategies, as the dependency of a generator on its strategy is taken for granted, and is absolute.

Author:
rafa

Nested Class Summary
static class GeneratorDependency.Property
          Property keys used to construct a dependency between generators.
 
Field Summary
 
Fields inherited from class rafa.dep.SimpleDependency
path, properties, target
 
Constructor Summary
GeneratorDependency(java.lang.Object target)
           
GeneratorDependency(java.lang.Object target, java.util.Map<java.lang.Object,java.lang.Object> properties)
           
 
Method Summary
protected  GeneratorDependency mergeWith(Dependency subDep)
          Merges this dependency with another sub-dependency on a given target.
 void validateCircularDependency()
          Checks that there will be no deadlocks due to circular dependencies, i.e.
 
Methods inherited from class rafa.dep.SimpleDependency
addProperty, getPath, getProperties, getTarget, search, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GeneratorDependency

public GeneratorDependency(java.lang.Object target)

GeneratorDependency

public GeneratorDependency(java.lang.Object target,
                           java.util.Map<java.lang.Object,java.lang.Object> properties)
Method Detail

mergeWith

protected GeneratorDependency mergeWith(Dependency subDep)
Merges this dependency with another sub-dependency on a given target.

Overrides:
mergeWith in class SimpleDependency
Parameters:
subDep - The sub-dependency.
Returns:
a merged GeneratorDependency whose target is that of the sub-dependency, and whose properties have been adjusted, or null if the dependencies don't chain.

validateCircularDependency

public void validateCircularDependency()
                                throws CircularDependencyException
Checks that there will be no deadlocks due to circular dependencies, i.e. the highest index of the dependency (DEPENDENCY_INDEX + DEPENDENCY_LENGTH) is always lower that the lowest dependent index (DEPENDENT_INDEX). This way, only dependencies on values already generated are allowed.
This method should be called when an object - holding this dependency - is dependent on itself - this dependency's target -, in order to check if the self-reference is allowed or not. Besides, it should be called for every other dependent object in the circle.

Specified by:
validateCircularDependency in interface Dependency
Overrides:
validateCircularDependency in class SimpleDependency
Throws:
CircularDependencyException


Copyright © 2008-2009. All Rights Reserved.