package com.xeiam.xchange.cointrader.dto;

import java.util.Date;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;

@JsonNaming(PropertyNamingStrategy.LowerCaseWithUnderscoresStrategy.class)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class CointraderRequest {

  @JsonProperty private String t;

  // todo: use a nonce factory to avoid clashes
  public CointraderRequest() {
    t = String.format("%tc", new Date());
  }
}

@@ -60,16 +60,68 @@
 .Date;%0A%0A
+import com.fasterxml.jackson.annotation.JsonIgnore;%0A
 import c
@@ -506,155 +506,455 @@
 Json
-Property private String t;%0A%0A  // todo: use a nonce factory to avoid clashes%0A  public CointraderRequest() %7B%0A    t = String.format(%22%25tc%22, new Date())
+Ignore(true)%0A  private static long lastNonceTs = 0;%0A%0A  @JsonProperty private String t;%0A%0A  public CointraderRequest() %7B%0A    long nextNonceTs = getCurrentTimestamp();%0A    if (lastNonceTs == nextNonceTs) %7B%0A      nextNonceTs++;%0A    %7D%0A    lastNonceTs = nextNonceTs;%0A    t = String.format(%22%25tc%22, new Date(lastNonceTs * 1000));%0A  %7D%0A%0A  /** Current timestamp in seconds */%0A  private long getCurrentTimestamp() %7B%0A    return System.currentTimeMillis() / 1000
 ;%0A  

Improve nonce creation. Not using a nonce factory though since the creation is centralized in CointraderRequest anyway.