VariableSink.java

/*
 * Created on 2007/02/05
 * Copyright (C) 2007 Koga Laboratory. All rights reserved.
 *
 */
package org.mklab.tool.control.system.sink;

import org.mklab.nfc.matrix.ComplexNumericalMatrix;
import org.mklab.nfc.matrix.RealNumericalMatrix;
import org.mklab.nfc.scalar.ComplexNumericalScalar;
import org.mklab.nfc.scalar.RealNumericalScalar;
import org.mklab.tool.control.system.parameter.Parameter;


/**
 * 変数への出力器を表わすクラスです。
 * 
 * @author koga
 * @version $Revision: 1.12 $, 2007/02/05
  * @param <RS> type of real scalar
 * @param <RM> type of real matrix
 * @param <CS> type of complex scalar
 * @param <CM> type of complex matrix
*/
public class VariableSink<RS extends RealNumericalScalar<RS,RM,CS,CM>, RM extends RealNumericalMatrix<RS,RM,CS,CM>, CS extends ComplexNumericalScalar<RS,RM,CS,CM>, CM extends ComplexNumericalMatrix<RS,RM,CS,CM>> extends MatrixExportSink<RS,RM,CS,CM> {

  /** 変数の名前 */
  @Parameter(name = "name", description = "VariableSink.1", internationalization = true)
  private String variableName = "y"; //$NON-NLS-1$

  /**
   * 新しく生成された<code>VariableSink</code>オブジェクトを初期化します。
   * @param sunit unit of scalar
   */
  public VariableSink(RS sunit) {
    super(sunit);
  }

  /**
   * @see org.mklab.tool.control.system.sink.Exporter#close()
   */
  public void close() {
    // nothing
  }

  /**
   * @see org.mklab.tool.control.system.sink.Exporter#isActive()
   */
  public boolean isActive() {
    if (0 < getDataLength()) {
      return true;
    }
    return false;
  }

  /**
   * @see org.mklab.tool.control.system.sink.Exporter#exportData()
   */
  public void exportData() {
    //
  }

  /**
   * 名前を返します。
   * 
   * @return 名前
   */
  public String getVariableName() {
    return this.variableName;
  }

  /**
   * 名前を設定します。
   * 
   * @param variableName 名前
   */
  public void setVariableName(final String variableName) {
    this.variableName = variableName;
  }

  /**
   * @see org.mklab.tool.control.system.SystemOperator#equals(java.lang.Object)
   */
  @Override
  public boolean equals(Object o) {
    if (this == o) {
      return true;
    }
    if (!super.equals(o)) {
      return false;
    }
    if (o == null) {
      return false;
    }
    if (o.getClass() != getClass()) {
      return false;
    }
    VariableSink<RS,RM,CS,CM> castedObj = (VariableSink<RS,RM,CS,CM>)o;
    return ((this.variableName == null ? castedObj.variableName == null : this.variableName.equals(castedObj.variableName)));
  }

  /**
   * @see org.mklab.tool.control.system.SystemOperator#hashCode()
   */
  @Override
  public int hashCode() {
    int hashCode = super.hashCode();
    hashCode = 31 * hashCode + (this.variableName == null ? 0 : this.variableName.hashCode());
    return hashCode;
  }
}