Package com.iizix
Class CircularReferenceFinder<INPUT,TARGET>
java.lang.Object
com.iizix.CircularReferenceFinder<INPUT,TARGET>
- Direct Known Subclasses:
ExtendsCircularReferenceFinder
Helper class to find circular references.
- Author:
- Christopher Mindus
Constructor Summary
ConstructorsConstructorDescriptionCircularReferenceFinder(INPUT input, ICircularReference<INPUT, TARGET> finder) Constructs the circular reference finder.Method Summary
Modifier and TypeMethodDescriptionintGets the count of chains for all references.getError()Gets the error message.Gets the first target found.Gets the last target found, it is the same value as the first if just one reference chain exists.booleanChecks if at least one input caused multiple targets.protected StringinputToString(INPUT input) Converts aninputto a String.booleanisValid()Checks if the reference is valid and that it is not circular.protected StringoutputToString(TARGET target) Converts atargetto a String.protected StringThe parameter string.toString()Converts to a String representation.
Constructor Details
CircularReferenceFinder
Constructs the circular reference finder.- Parameters:
input- The input reference.finder- The finder implementing instance.
Method Details
isValid
public boolean isValid()Checks if the reference is valid and that it is not circular.- Returns:
- true if no error is set, i.e. error is null.
getError
Gets the error message.- Returns:
- Error string for circular finder check, or null for no error.
getFirstTarget
Gets the first target found.This target is ONLY set if there was a single target reference found, and is null if there are more than one.
- Returns:
- The first target found, or null for none.
getLastTarget
Gets the last target found, it is the same value as the first if just one reference chain exists. In case of a circular reference error, the last target is the circular reference error cause.- Returns:
- The last target found, or null for none.
getChainCount
public int getChainCount()Gets the count of chains for all references. This value is an indication to the complexity of the references, and is only really useful if there can be only one reference target per input.- Returns:
- The chain count.
hasMultipleTargets
public boolean hasMultipleTargets()Checks if at least one input caused multiple targets. If this method returns true, the methodsgetFirstTarget(),getLastTarget()andgetChainCount()should not be used.- Returns:
- true if a problem exists with multiple targets, false otherwise.
inputToString
Converts aninputto a String.Override to provide a method for input.toString().
- Parameters:
input- The input reference.- Returns:
- The
inputString representation, "null" for null input.
outputToString
Converts atargetto a String.Override to provide a method for target.toString().
- Parameters:
target- The target reference (i.e.getFirstTarget()orgetLastTarget()).- Returns:
- The
targetString representation, "null" for null target.
toString
Converts to a String representation.paramString
The parameter string. Subclasses can override to provide additional parameters, normally appended at the end of the string.- Returns:
- The parameter string.