程序员的量化交易之路(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() {}


}


上一篇:SpringMVC 处理静态资源 <mvc:default-servlet-handler/>


下一篇:iMazing免费试用版与付费版有何区别?