首页 > 代码库 > 程序猿的量化交易之路(18)--Cointrader之Event实体(6)

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



程序猿的量化交易之路(18)--Cointrader之Event实体(6)