Package com.iizix
Class CircularReferenceFinder<INPUT,TARGET>
- java.lang.Object
- com.iizix.CircularReferenceFinder<INPUT,TARGET>
- Direct Known Subclasses:
ExtendsCircularReferenceFinder
public class CircularReferenceFinder<INPUT,TARGET> extends java.lang.ObjectHelper class to find circular references.- Author:
- Christopher Mindus
Constructor Summary
Constructors Constructor Description CircularReferenceFinder(INPUT input, ICircularReference<INPUT,TARGET> finder)Constructs the circular reference finder.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetChainCount()Gets the count of chains for all references.java.lang.StringgetError()Gets the error message.TARGETgetFirstTarget()Gets the first target found.TARGETgetLastTarget()Gets the last target found, it is the same value as the first if just one reference chain exists.booleanhasMultipleTargets()Checks if at least one input caused multiple targets.protected java.lang.StringinputToString(INPUT input)Converts aninputto a String.booleanisValid()Checks if the reference is valid and that it is not circular.protected java.lang.StringoutputToString(TARGET target)Converts atargetto a String.protected java.lang.StringparamString()The parameter string.java.lang.StringtoString()Converts to a String representation.
Constructor Detail
CircularReferenceFinder
public CircularReferenceFinder(INPUT input, ICircularReference<INPUT,TARGET> finder)
Constructs the circular reference finder.- Parameters:
input- The input reference.finder- The finder implementing instance.
Method Detail
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
public java.lang.String getError()
Gets the error message.- Returns:
- Error string for circular finder check, or null for no error.
getFirstTarget
public TARGET 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
public TARGET 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
protected java.lang.String inputToString(INPUT input)
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
protected java.lang.String outputToString(TARGET target)
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
public java.lang.String toString()
Converts to a String representation.- Overrides:
toStringin classjava.lang.Object
paramString
protected java.lang.String paramString()
The parameter string. Subclasses can override to provide additional parameters, normally appended at the end of the string.- Returns:
- The parameter string.