Programmer's path to quantitative transaction (24) -- RemoteEvent remote event entity of Cointrader (11); programmer's path to quantitative transaction

Source: Internet
Author: User

Programmer's path to quantitative transaction (24) -- RemoteEvent remote event entity of Cointrader (11); programmer's path to quantitative transaction

Reprint need to indicate the source: http://blog.csdn.net/minimicall,http://cloudtrader.top/

In the quantitative transaction system, some events are sent remotely, such as the stock price data. Therefore, we define a remote event entity in this section.

It is a base class and does not generate data tables separately. The Code is as follows:

package org.cryptocoinpartners.schema;import javax.annotation.Nullable;import javax.persistence.Basic;import javax.persistence.MappedSuperclass;import javax.persistence.Transient;import org.hibernate.annotations.Type;import org.joda.time.Instant;@MappedSuperclasspublic abstract class RemoteEvent extends Event {    /**     * @return the time when this event object was created.  it may be later than getTime() due to transmission delays     */    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentInstantAsMillisLong")    @Basic(optional = false)    public Instant getTimeReceived() {        return timeReceived;    }    @Transient    public long getTimestampReceived() {        return timestampReceived;    }    @Basic(optional = true)    public String getRemoteKey() {        return remoteKey;    }    @Override    public void publishedAt(Instant instant) {        super.publishedAt(instant);        if (timeReceived == null)            timeReceived = instant;        this.timestampReceived = timeReceived.getMillis();    }    protected RemoteEvent(Instant time, @Nullable String remoteKey) {        this(time, Instant.now(), remoteKey);    }    protected RemoteEvent(Instant time, Instant timeReceived, @Nullable String remoteKey) {        super(time);        this.remoteKey = remoteKey;        this.timeReceived = timeReceived;        this.timestampReceived = timeReceived.getMillis();    }    // JPA    protected RemoteEvent() {    }    protected void setTimeReceived(Instant timeReceived) {        this.timeReceived = timeReceived;        this.timestampReceived = timeReceived.getMillis();    }    protected void setRemoteKey(@Nullable String remoteKey) {        this.remoteKey = remoteKey;    }    private Instant timeReceived;    private long timestampReceived;    private String remoteKey;}


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.