⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 geneticevent.java

📁 一个开源的用java开发的遗传算法的封装好的工程
💻 JAVA
字号:
/*
 * This file is part of JGAP.
 *
 * JGAP offers a dual license model containing the LGPL as well as the MPL.
 *
 * For licencing information please see the file license.txt included with JGAP
 * or have a look at the top of class org.jgap.Chromosome which representatively
 * includes the JGAP license policy applicable for any file delivered with JGAP.
 */
package org.jgap.event;

import java.util.EventObject;

/**
 * Represents events that are fired via the EventManager when various
 * genetic events occur. The specific kind of event is conveyed through the
 * event name. Standard event names are provided as constants in this class.
 *
 * @author Neil Rotstan
 * @author Klaus Meffert
 * @since 1.0
 */
public class GeneticEvent
    extends EventObject {
  /** String containing the CVS revision. Read out via reflection!*/
  private final static String CVS_REVISION = "$Revision: 1.8 $";

  /**
   * Multi-purpose value object
   */
  private Object m_value;

  /**
   * Public constant representing the name of the event that is fired each
   * time a Genotype is finished with a single evolution cycle.
   */
  public static final String GENOTYPE_EVOLVED_EVENT =
      "genotype_evolved_event";

  public static final String GPGENOTYPE_EVOLVED_EVENT =
      "gpgenotype_evolved_event";

  public static final String GPGENOTYPE_NEW_BEST_SOLUTION =
      "gpgenotype_best_solution";

  /**
   * References the name of this event instance.
   */
  private final String m_eventName;

  /**
   * Constructs a new GeneticEvent of the given name.
   *
   * @param a_eventName the name of the event
   * @param a_source the genetic object that acted as the source of the event.
   * The type of this object will be dependent on the kind of event (which can
   * be identified by the event name). It may not be null
   *
   * @throws IllegalArgumentException if the given source object is null
   *
   * @author Neil Rotstan
   * @since 1.0
   */
  public GeneticEvent(final String a_eventName, final Object a_source) {
    super(a_source);
    m_eventName = a_eventName;
  }

  /**
   * Constructs a new GeneticEvent of the given name.
   *
   * @param a_eventName the name of the event
   * @param a_source the genetic object that acted as the source of the event.
   * The type of this object will be dependent on the kind of event (which can
   * be identified by the event name). It may not be null
   * @param a_value informative value of the event
   *
   * @throws IllegalArgumentException if the given source object is null
   *
   * @author Neil Rotstan
   * @since 1.0
   */
  public GeneticEvent(final String a_eventName, final Object a_source,
                      final Object a_value) {
    this(a_eventName, a_source);
    m_value = a_value;
  }

  /**
   * Retrieves the name of this event, which can be used to identify the
   * type of event.
   *
   * @return the name of this GeneticEvent instance
   *
   * @author Neil Rotstan
   * @since 1.0
   */
  public String getEventName() {
    return m_eventName;
  }

  /**
   * @return multi-purpose value of the event
   *
   * @author Klaus Meffert
   * @since 3.0
   */
  public Object getValue() {
    return m_value;
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -