protected Validation validate ( Move < ? super SolutionType > move ) { Validation val = null ; // check cache if ( cache != null ) { val = cache . getCachedMoveValidation ( move ) ; } if ( val != null ) { // cache hit: return cached value return val ; } else { // cache miss: validate and cache val = getProblem ( ) . validate ( move , getCurrentSolution ( ) , getCurrentSolutionValidation ( ) ) ; if ( cache != null ) { cache . cacheMoveValidation ( move , val ) ; } return val ; } }
Validates a move to be applied to the current solution . If this move has been validated before and the obtained validation is still available in the cache the cached validation will be returned . Else the validation will be computed and offered to the cache .