程序員的量化交易之路(18)--Cointrader之Event實體(6)

轉載需註明:

事件,是Esper的重要概念。這裏我們定義個事件類,它是Temporal實體的派生類。

僅僅是對Temporal簡單的包裝。其代碼如下:


package org.cryptocoinpartners.schema;

import org.joda.time.Instant;

import javax.persistence.MappedSuperclass;


/**
 * Subclasses of Event may be posted to Context
 *
 * @author Tim Olson
 */
//是一個基類,在數據庫中不創建表格。
@MappedSuperclass
public abstract class Event extends Temporal {


    /**
     * If the Event's time has not been set when it is being published, it will be set to the current time of the
     * publishing Context
     */
    public void publishedAt(Instant instant) {
        if( getTime() == null )
            setTime(instant);
    }


    /** Most events should use this constructor to provide the time of the original happening, not the time of
     *  object creation */
    protected Event(Instant time) {
        super(time);
    }


    protected Event() {}


}


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章