|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.tostring0.AToString
com.rubecula.darwin.foundation.Best_<T>
T - the base type for the best fitpublic abstract class Best_<T extends ComparableValue>
Class to manage the best fit of something.
| Field Summary | |
|---|---|
protected static org.apache.commons.logging.Log |
LOG
|
| Fields inherited from interface net.sf.tostring0.IToString |
|---|
ANGBR_OPEN, ANGBRA_CLSE, BRA_CLSE, BRA_OPEN, BRCE_OPEN, BRCS_CLSE, COLON, LIST_SEPARATOR, MAX_ELEMENTS_DEFAULT, S_MT, S_PERCENT, SEPARATOR, SPACE |
| Constructor Summary | |
|---|---|
protected |
Best_(java.lang.String id,
java.util.Collection<T> candidates,
ProcessBest<T> processor)
Construct the Best_ object based on the identifier id, and
get the best value for the given candidates, using the
processor if not-null. |
protected |
Best_(java.lang.String id,
int convergence)
|
protected |
Best_(java.lang.String id,
ProcessBest<T> processor)
|
protected |
Best_(java.lang.String id,
ProcessBest<T> processor,
int convergence)
|
protected |
Best_(java.lang.String id,
T best,
ProcessBest<T> processor,
int convergence)
|
| Method Summary | |
|---|---|
protected int |
getConvergence()
|
java.lang.String |
getIdentifier()
|
T |
getObject()
|
ProcessBest<T> |
getProcessor()
|
java.lang.Number |
getValue()
Get the value which we can use to compare this object with other Valuable objects, for example in conjunction with Best
interface. |
protected abstract boolean |
isUnique(T candidate)
|
void |
reset()
Reset this Best object as if it had been newly constructed. |
protected void |
setConvergence(int convergence)
|
protected void |
setObject(T object)
Sets the object AND resets the count value. |
boolean |
update(java.util.Collection<T> candidates)
This method loops through each element of candidates and calls updateInternal(ComparableValue, boolean) for each candidate. |
boolean |
update(T candidate,
boolean override)
Method to conditionally update the best value. |
| Methods inherited from class net.sf.tostring0.AToString |
|---|
toString, toString, toStringBrief, toStringId |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
protected static final org.apache.commons.logging.Log LOG
| Constructor Detail |
|---|
protected Best_(java.lang.String id,
java.util.Collection<T> candidates,
ProcessBest<T> processor)
throws ValueException
id, and
get the best value for the given candidates, using the
processor if not-null.
id - candidates - processor -
ValueException
protected Best_(java.lang.String id,
int convergence)
id - the description of this "best" objectconvergence - XXX
protected Best_(java.lang.String id,
ProcessBest<T> processor)
id - the description of this "best" objectprocessor -
protected Best_(java.lang.String id,
ProcessBest<T> processor,
int convergence)
id - the description of this "best" objectprocessor - convergence - XXX
protected Best_(java.lang.String id,
T best,
ProcessBest<T> processor,
int convergence)
id - the description of this "best" objectbest - processor - the object which will process each new best object when an
update occurs.convergence - XXX| Method Detail |
|---|
public java.lang.String getIdentifier()
getIdentifier in interface net.sf.tostring0.IdentifiableIdentifiable.getIdentifier()public T getObject()
getObject in interface Best<T extends ComparableValue>XXX note that we must include this method explicitly because its
generic return type means it doesn't match as a bean method.public ProcessBest<T> getProcessor()
getProcessor in interface Best<T extends ComparableValue>
public java.lang.Number getValue()
throws ValueException
ValuableValuable objects, for example in conjunction with Best
interface.
NOTE: that this method gets called a lot. Therefore, if invoking it
requires a significant amount of work, the Valuable
implementation should consider caching the value.
getValue in interface ValuableValueException - which will in practice never be thrown by this method (since
we do not crown invalid candidates as best).Valuable.getValue()public void reset()
BestBest object as if it had been newly constructed.
reset in interface Best<T extends ComparableValue>Best.reset()
public boolean update(java.util.Collection<T> candidates)
throws ValueException
updateInternal(ComparableValue, boolean) for each candidate. On
an update, and provided that value of _processor is not null, we
invoke _processor with the new best object and best value.
Note that we do not really need to deal with convergence here, because we
are processing an entire collection. It doesn't therefore matter much
when the processor is actually triggered because it will be done
internally while this method is in play. However, in fact, convergence is
dealt with appropriately (assuming that convergence is greater
than zero. If it's zero, then the whole notion of convergence is moot.
update in interface Best<T extends ComparableValue>candidates -
ValueException
public boolean update(T candidate,
boolean override)
throws ValueException
Best
update in interface Best<T extends ComparableValue>candidate - XXXoverride - if true, then we consider convergence to be true even if the
count has not been reached.
ValueExceptionprotected int getConvergence()
protected abstract boolean isUnique(T candidate)
protected void setConvergence(int convergence)
convergence - the convergence to setprotected void setObject(T object)
object - the object to set
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||