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 org.apache.commons.logging.Log; 019 import org.apache.commons.logging.LogFactory; 020 021 import de.kumpe.hadooptimizer.EsWrappableMutator; 022 import de.kumpe.hadooptimizer.Mutator; 023 024 /** 025 * The {@link IdentityMutator} effectively does nothing, it just passes the 026 * input-individual through. 027 * 028 * @param <I> 029 * the individuals' type 030 * 031 * @author <a href="http://kumpe.de/christian/java">Christian Kumpe</a> 032 */ 033 public final class IdentityMutator<I> implements Mutator<I>, EsWrappableMutator { 034 private static final long serialVersionUID = 1L; 035 private static final Log log = LogFactory.getLog(IdentityMutator.class); 036 037 public IdentityMutator() { 038 if (log.isDebugEnabled()) { 039 log.debug("Constructing new IdentityMutator."); 040 } 041 } 042 043 @Override 044 public I mutate(final I individual) { 045 return individual; 046 } 047 048 @Override 049 public double[] mutate(final double[] individual, final double increment) { 050 return individual; 051 } 052 053 @Override 054 public double getMinIncrement() { 055 return 0; 056 } 057 058 @Override 059 public String toString() { 060 return "IdentityMutator []"; 061 } 062 }