001 /* 002 * Copyright 2011 Christian Kumpe http://kumpe.de/christian/java 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package de.kumpe.hadooptimizer.impl; 017 018 import java.util.Collection; 019 020 import org.apache.commons.logging.Log; 021 import org.apache.commons.logging.LogFactory; 022 023 import de.kumpe.hadooptimizer.EvaluationResult; 024 import de.kumpe.hadooptimizer.Halter; 025 import de.kumpe.hadooptimizer.Stoppable; 026 027 /** 028 * This {@link Halter}'s {@link #halt(Collection)} will always return false, 029 * thus never halt. 030 * 031 * @param <I> 032 * the individuals' type 033 * 034 * @author <a href="http://kumpe.de/christian/java">Christian Kumpe</a> 035 */ 036 public final class NeverHalter<I> implements Halter<I>, Stoppable { 037 private static final long serialVersionUID = 1L; 038 private static final Log log = LogFactory.getLog(NeverHalter.class); 039 040 private volatile boolean stop = false; 041 042 public NeverHalter() { 043 if (log.isDebugEnabled()) { 044 log.debug("Constructing new NeverHalter."); 045 } 046 } 047 048 @Override 049 public boolean halt(final Collection<EvaluationResult<I>> evaluationResults) { 050 return stop; 051 } 052 053 @Override 054 public void stop() { 055 stop = true; 056 } 057 058 @Override 059 public String toString() { 060 return "NeverHalter []"; 061 } 062 }