KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jgap > BaseGeneticOperator


1 /*
2  * This file is part of JGAP.
3  *
4  * JGAP offers a dual license model containing the LGPL as well as the MPL.
5  *
6  * For licencing information please see the file license.txt included with JGAP
7  * or have a look at the top of class org.jgap.Chromosome which representatively
8  * includes the JGAP license policy applicable for any file delivered with JGAP.
9  */

10 package org.jgap;
11
12 import java.util.*;
13
14 /**
15  * Base class for any implementation of interface GeneticOperator.
16  *
17  * @author Klaus Meffert
18  * @since 3.0
19  */

20 public abstract class BaseGeneticOperator
21     implements GeneticOperator, Comparable JavaDoc {
22   /** String containing the CVS revision. Read out via reflection!*/
23   private final static String JavaDoc CVS_REVISION = "$Revision: 1.4 $";
24
25   private /*transient*/ Configuration m_configuration;
26
27   /**
28    * The only constructor in this class. Sets the immutable configuration.
29    * @param a_configuration the configuration to set (must not be null)
30    * @throws InvalidConfigurationException
31    * @author Klaus Meffert
32    * @since 3.0
33    */

34   public BaseGeneticOperator(Configuration a_configuration)
35       throws InvalidConfigurationException {
36     if (a_configuration == null) {
37       throw new InvalidConfigurationException("Configuration to set may not be"
38                                               +" null!");
39     }
40     m_configuration = a_configuration;
41   }
42
43   /**
44    * @todo make returned object immutable
45    * @return the configuration set
46    *
47    * @author Klaus Meffert
48    * @since 3.0
49    */

50   public Configuration getConfiguration() {
51     return m_configuration;
52   }
53
54   /**
55    * Compares this GeneticOperator against the specified object. The result is
56    * true if the argument is an instance of this class and is equal with respect
57    * to the data.
58    *
59    * @param a_other the object to compare against
60    * @return true: if the objects are the same, false otherwise
61    *
62    * @author Klaus Meffert
63    * @since 2.6
64    */

65   public boolean equals(final Object JavaDoc a_other) {
66     try {
67       /**@todo also compare Configuration*/
68       return compareTo(a_other) == 0;
69     }
70     catch (ClassCastException JavaDoc cex) {
71       return false;
72     }
73   }
74
75 }
76
Popular Tags