All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.casper.sdk.model.transaction.scheduling.FutureTimestamp Maven / Gradle / Ivy

Go to download

SDK to streamline the 3rd party Java client integration processes. Such 3rd parties include exchanges & app developers.

The newest version!
package com.casper.sdk.model.transaction.scheduling;

import com.casper.sdk.exception.NoSuchTypeException;
import com.casper.sdk.model.clvalue.serde.Target;
import com.fasterxml.jackson.annotation.*;
import dev.oak3.sbs4j.SerializerBuffer;
import dev.oak3.sbs4j.exception.ValueSerializationException;
import lombok.*;
import org.joda.time.DateTime;

import java.util.Date;

/**
 * Execution should be scheduled for the specified timestamp or later.
 *
 * @author [email protected]
 */
@NoArgsConstructor
@AllArgsConstructor
@Setter
@Getter
@Builder
@JsonTypeName("FutureTimestamp")
public class FutureTimestamp implements TransactionScheduling {

    @JsonValue
    @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'")
    private String futureTimestamp;

    @JsonIgnore
    public Date asDate() {
        return futureTimestamp != null ? new DateTime(futureTimestamp).toDate() : null;
    }

    @Override
    public void serialize(final SerializerBuffer ser, final Target target) throws ValueSerializationException, NoSuchTypeException {
        ser.writeU8(getByteTag());
        ser.writeI64(asDate().getTime());
    }

    @Override
    public byte getByteTag() {
        return 2;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy