uk.co.real_logic.artio.builder.ExecutionReportEncoder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of artio-session-codecs Show documentation
Show all versions of artio-session-codecs Show documentation
High-Performance FIX Gateway
/* Generated Fix Gateway message codec */
package uk.co.real_logic.artio.builder;
import uk.co.real_logic.artio.dictionary.Generated;
import org.agrona.MutableDirectBuffer;
import org.agrona.AsciiSequenceView;
import static uk.co.real_logic.artio.dictionary.generation.CodecUtil.*;
import static uk.co.real_logic.artio.dictionary.SessionConstants.*;
import uk.co.real_logic.artio.builder.Encoder;
import uk.co.real_logic.artio.builder.HeaderEncoder;
import uk.co.real_logic.artio.builder.TrailerEncoder;
import uk.co.real_logic.artio.fields.ReadOnlyDecimalFloat;
import uk.co.real_logic.artio.fields.DecimalFloat;
import uk.co.real_logic.artio.util.MutableAsciiBuffer;
import uk.co.real_logic.artio.util.AsciiBuffer;
import uk.co.real_logic.artio.fields.LocalMktDateEncoder;
import uk.co.real_logic.artio.fields.UtcTimestampEncoder;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import uk.co.real_logic.artio.dictionary.CharArraySet;
import org.agrona.collections.IntHashSet;
import org.agrona.collections.IntHashSet.IntIterator;
import uk.co.real_logic.artio.EncodingException;
import uk.co.real_logic.artio.dictionary.CharArrayWrapper;
import org.agrona.DirectBuffer;
import org.agrona.MutableDirectBuffer;
import org.agrona.concurrent.UnsafeBuffer;
import org.agrona.AsciiSequenceView;
import uk.co.real_logic.artio.builder.FieldBagEncoder;
import static java.nio.charset.StandardCharsets.US_ASCII;
import static uk.co.real_logic.artio.builder.Validation.CODEC_VALIDATION_ENABLED;
import static uk.co.real_logic.artio.builder.RejectUnknownField.CODEC_REJECT_UNKNOWN_FIELD_ENABLED;
import static uk.co.real_logic.artio.builder.RejectUnknownEnumValue.CODEC_REJECT_UNKNOWN_ENUM_VALUE_ENABLED;
import uk.co.real_logic.artio.*;
@Generated("uk.co.real_logic.artio")
public class ExecutionReportEncoder implements Encoder
{
public long messageType()
{
return 56L;
}
public ExecutionReportEncoder()
{
header.msgType("8");
}
private final TrailerEncoder trailer = new TrailerEncoder();
public TrailerEncoder trailer()
{
return trailer;
}
private final HeaderEncoder header = new HeaderEncoder();
public HeaderEncoder header()
{
return header;
}
private static final int orderIDHeaderLength = 3;
private static final byte[] orderIDHeader = new byte[] {51, 55, (byte) '='};
private static final int execIDHeaderLength = 3;
private static final byte[] execIDHeader = new byte[] {49, 55, (byte) '='};
private static final int execTypeHeaderLength = 4;
private static final byte[] execTypeHeader = new byte[] {49, 53, 48, (byte) '='};
private static final int ordStatusHeaderLength = 3;
private static final byte[] ordStatusHeader = new byte[] {51, 57, (byte) '='};
private static final int sideHeaderLength = 3;
private static final byte[] sideHeader = new byte[] {53, 52, (byte) '='};
private static final int transactTimeHeaderLength = 3;
private static final byte[] transactTimeHeader = new byte[] {54, 48, (byte) '='};
private final MutableDirectBuffer orderID = new UnsafeBuffer();
private byte[] orderIDInternalBuffer = orderID.byteArray();
private int orderIDOffset = 0;
private int orderIDLength = 0;
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final DirectBuffer value, final int offset, final int length)
{
orderID.wrap(value);
orderIDOffset = offset;
orderIDLength = length;
return this;
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final DirectBuffer value, final int length)
{
return orderID(value, 0, length);
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final DirectBuffer value)
{
return orderID(value, 0, value.capacity());
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final byte[] value, final int offset, final int length)
{
orderID.wrap(value);
orderIDOffset = offset;
orderIDLength = length;
return this;
}
/* OrderID = 37 */
public ExecutionReportEncoder orderIDAsCopy(final byte[] value, final int offset, final int length)
{
if (copyInto(orderID, value, offset, length))
{
orderIDInternalBuffer = orderID.byteArray();
}
orderIDOffset = 0;
orderIDLength = length;
return this;
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final byte[] value, final int length)
{
return orderID(value, 0, length);
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final byte[] value)
{
return orderID(value, 0, value.length);
}
/* OrderID = 37 */
public boolean hasOrderID()
{
return orderIDLength > 0;
}
/* OrderID = 37 */
public MutableDirectBuffer orderID()
{
return orderID;
}
/* OrderID = 37 */
public String orderIDAsString()
{
return orderID.getStringWithoutLengthAscii(orderIDOffset, orderIDLength);
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final CharSequence value)
{
if (toBytes(value, orderID))
{
orderIDInternalBuffer = orderID.byteArray();
}
orderIDOffset = 0;
orderIDLength = value.length();
return this;
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final AsciiSequenceView value)
{
final DirectBuffer buffer = value.buffer();
if (buffer != null)
{
orderID.wrap(buffer);
orderIDOffset = value.offset();
orderIDLength = value.length();
}
return this;
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final char[] value)
{
return orderID(value, 0, value.length);
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final char[] value, final int length)
{
return orderID(value, 0, length);
}
/* OrderID = 37 */
public ExecutionReportEncoder orderID(final char[] value, final int offset, final int length)
{
if (toBytes(value, orderID, offset, length))
{
orderIDInternalBuffer = orderID.byteArray();
}
orderIDOffset = 0;
orderIDLength = length;
return this;
}
private final MutableDirectBuffer execID = new UnsafeBuffer();
private byte[] execIDInternalBuffer = execID.byteArray();
private int execIDOffset = 0;
private int execIDLength = 0;
/* ExecID = 17 */
public ExecutionReportEncoder execID(final DirectBuffer value, final int offset, final int length)
{
execID.wrap(value);
execIDOffset = offset;
execIDLength = length;
return this;
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final DirectBuffer value, final int length)
{
return execID(value, 0, length);
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final DirectBuffer value)
{
return execID(value, 0, value.capacity());
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final byte[] value, final int offset, final int length)
{
execID.wrap(value);
execIDOffset = offset;
execIDLength = length;
return this;
}
/* ExecID = 17 */
public ExecutionReportEncoder execIDAsCopy(final byte[] value, final int offset, final int length)
{
if (copyInto(execID, value, offset, length))
{
execIDInternalBuffer = execID.byteArray();
}
execIDOffset = 0;
execIDLength = length;
return this;
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final byte[] value, final int length)
{
return execID(value, 0, length);
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final byte[] value)
{
return execID(value, 0, value.length);
}
/* ExecID = 17 */
public boolean hasExecID()
{
return execIDLength > 0;
}
/* ExecID = 17 */
public MutableDirectBuffer execID()
{
return execID;
}
/* ExecID = 17 */
public String execIDAsString()
{
return execID.getStringWithoutLengthAscii(execIDOffset, execIDLength);
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final CharSequence value)
{
if (toBytes(value, execID))
{
execIDInternalBuffer = execID.byteArray();
}
execIDOffset = 0;
execIDLength = value.length();
return this;
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final AsciiSequenceView value)
{
final DirectBuffer buffer = value.buffer();
if (buffer != null)
{
execID.wrap(buffer);
execIDOffset = value.offset();
execIDLength = value.length();
}
return this;
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final char[] value)
{
return execID(value, 0, value.length);
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final char[] value, final int length)
{
return execID(value, 0, length);
}
/* ExecID = 17 */
public ExecutionReportEncoder execID(final char[] value, final int offset, final int length)
{
if (toBytes(value, execID, offset, length))
{
execIDInternalBuffer = execID.byteArray();
}
execIDOffset = 0;
execIDLength = length;
return this;
}
private char execType;
private boolean hasExecType;
public boolean hasExecType()
{
return hasExecType;
}
/* ExecType = 150 */
public ExecutionReportEncoder execType(char value)
{
execType = value;
hasExecType = true;
return this;
}
/* ExecType = 150 */
public char execType()
{
return execType;
}
public ExecutionReportEncoder execType(ExecType value)
{
if (CODEC_VALIDATION_ENABLED)
{
if (value == ExecType.ARTIO_UNKNOWN)
{
throw new EncodingException("Invalid Value Field: execType Value: " + value );
}
if (value == ExecType.NULL_VAL)
{
return this;
}
}
return execType(value.representation());
}
private char ordStatus;
private boolean hasOrdStatus;
public boolean hasOrdStatus()
{
return hasOrdStatus;
}
/* OrdStatus = 39 */
public ExecutionReportEncoder ordStatus(char value)
{
ordStatus = value;
hasOrdStatus = true;
return this;
}
/* OrdStatus = 39 */
public char ordStatus()
{
return ordStatus;
}
public ExecutionReportEncoder ordStatus(OrdStatus value)
{
if (CODEC_VALIDATION_ENABLED)
{
if (value == OrdStatus.ARTIO_UNKNOWN)
{
throw new EncodingException("Invalid Value Field: ordStatus Value: " + value );
}
if (value == OrdStatus.NULL_VAL)
{
return this;
}
}
return ordStatus(value.representation());
}
private final InstrumentEncoder instrument = new InstrumentEncoder();
public InstrumentEncoder instrument()
{
return instrument;
}
private char side;
private boolean hasSide;
public boolean hasSide()
{
return hasSide;
}
/* Side = 54 */
public ExecutionReportEncoder side(char value)
{
side = value;
hasSide = true;
return this;
}
/* Side = 54 */
public char side()
{
return side;
}
public ExecutionReportEncoder side(Side value)
{
if (CODEC_VALIDATION_ENABLED)
{
if (value == Side.ARTIO_UNKNOWN)
{
throw new EncodingException("Invalid Value Field: side Value: " + value );
}
if (value == Side.NULL_VAL)
{
return this;
}
}
return side(value.representation());
}
private final MutableDirectBuffer transactTime = new UnsafeBuffer();
private byte[] transactTimeInternalBuffer = transactTime.byteArray();
private int transactTimeOffset = 0;
private int transactTimeLength = 0;
/* TransactTime = 60 */
public ExecutionReportEncoder transactTime(final DirectBuffer value, final int offset, final int length)
{
transactTime.wrap(value);
transactTimeOffset = offset;
transactTimeLength = length;
return this;
}
/* TransactTime = 60 */
public ExecutionReportEncoder transactTime(final DirectBuffer value, final int length)
{
return transactTime(value, 0, length);
}
/* TransactTime = 60 */
public ExecutionReportEncoder transactTime(final DirectBuffer value)
{
return transactTime(value, 0, value.capacity());
}
/* TransactTime = 60 */
public ExecutionReportEncoder transactTime(final byte[] value, final int offset, final int length)
{
transactTime.wrap(value);
transactTimeOffset = offset;
transactTimeLength = length;
return this;
}
/* TransactTime = 60 */
public ExecutionReportEncoder transactTimeAsCopy(final byte[] value, final int offset, final int length)
{
if (copyInto(transactTime, value, offset, length))
{
transactTimeInternalBuffer = transactTime.byteArray();
}
transactTimeOffset = 0;
transactTimeLength = length;
return this;
}
/* TransactTime = 60 */
public ExecutionReportEncoder transactTime(final byte[] value, final int length)
{
return transactTime(value, 0, length);
}
/* TransactTime = 60 */
public ExecutionReportEncoder transactTime(final byte[] value)
{
return transactTime(value, 0, value.length);
}
/* TransactTime = 60 */
public boolean hasTransactTime()
{
return transactTimeLength > 0;
}
/* TransactTime = 60 */
public MutableDirectBuffer transactTime()
{
return transactTime;
}
/* TransactTime = 60 */
public String transactTimeAsString()
{
return transactTime.getStringWithoutLengthAscii(transactTimeOffset, transactTimeLength);
}
public long encode(final MutableAsciiBuffer buffer, final int offset)
{
final long startMessageResult = header.startMessage(buffer, offset);
final int bodyStart = Encoder.offset(startMessageResult);
int position = bodyStart + Encoder.length(startMessageResult);
if (orderIDLength > 0)
{
buffer.putBytes(position, orderIDHeader, 0, orderIDHeaderLength);
position += orderIDHeaderLength;
buffer.putBytes(position, orderID, orderIDOffset, orderIDLength);
position += orderIDLength;
buffer.putSeparator(position);
position++;
}
else if (CODEC_VALIDATION_ENABLED)
{
throw new EncodingException("Missing Field: OrderID");
}
if (execIDLength > 0)
{
buffer.putBytes(position, execIDHeader, 0, execIDHeaderLength);
position += execIDHeaderLength;
buffer.putBytes(position, execID, execIDOffset, execIDLength);
position += execIDLength;
buffer.putSeparator(position);
position++;
}
else if (CODEC_VALIDATION_ENABLED)
{
throw new EncodingException("Missing Field: ExecID");
}
if (hasExecType)
{
buffer.putBytes(position, execTypeHeader, 0, execTypeHeaderLength);
position += execTypeHeaderLength;
position += buffer.putCharAscii(position, execType);
buffer.putSeparator(position);
position++;
}
else if (CODEC_VALIDATION_ENABLED)
{
throw new EncodingException("Missing Field: ExecType");
}
if (hasOrdStatus)
{
buffer.putBytes(position, ordStatusHeader, 0, ordStatusHeaderLength);
position += ordStatusHeaderLength;
position += buffer.putCharAscii(position, ordStatus);
buffer.putSeparator(position);
position++;
}
else if (CODEC_VALIDATION_ENABLED)
{
throw new EncodingException("Missing Field: OrdStatus");
}
position += instrument.encode(buffer, position);
if (hasSide)
{
buffer.putBytes(position, sideHeader, 0, sideHeaderLength);
position += sideHeaderLength;
position += buffer.putCharAscii(position, side);
buffer.putSeparator(position);
position++;
}
else if (CODEC_VALIDATION_ENABLED)
{
throw new EncodingException("Missing Field: Side");
}
if (transactTimeLength > 0)
{
buffer.putBytes(position, transactTimeHeader, 0, transactTimeHeaderLength);
position += transactTimeHeaderLength;
buffer.putBytes(position, transactTime, transactTimeOffset, transactTimeLength);
position += transactTimeLength;
buffer.putSeparator(position);
position++;
}
position += trailer.startTrailer(buffer, position);
final int messageStart = header.finishHeader(buffer, bodyStart, position - bodyStart);
return trailer.finishMessage(buffer, messageStart, position);
}
public void reset()
{
header.reset();
trailer.reset();
resetMessage();
}
public void resetMessage()
{
this.resetOrderID();
this.resetExecID();
this.resetExecType();
this.resetOrdStatus();
this.resetSide();
this.resetTransactTime();
instrument.reset();
}
public void resetOrderID()
{
orderIDLength = 0;
orderID.wrap(orderIDInternalBuffer);
}
public void resetExecID()
{
execIDLength = 0;
execID.wrap(execIDInternalBuffer);
}
public void resetExecType()
{
execType = MISSING_CHAR;
}
public void resetOrdStatus()
{
ordStatus = MISSING_CHAR;
}
public void resetSide()
{
side = MISSING_CHAR;
}
public void resetTransactTime()
{
transactTimeLength = 0;
transactTime.wrap(transactTimeInternalBuffer);
}
public String toString()
{
return appendTo(new StringBuilder()).toString();
}
public StringBuilder appendTo(final StringBuilder builder)
{
return appendTo(builder, 1);
}
public StringBuilder appendTo(final StringBuilder builder, final int level)
{
builder.append("{\n"); indent(builder, level);
builder.append("\"MessageName\": \"ExecutionReport\",\n");
builder.append(" \"header\": ");
header.appendTo(builder, level + 1);
builder.append("\n");
if (hasOrderID())
{
indent(builder, level);
builder.append("\"OrderID\": \"");
appendBuffer(builder, orderID, orderIDOffset, orderIDLength);
builder.append("\",\n");
}
if (hasExecID())
{
indent(builder, level);
builder.append("\"ExecID\": \"");
appendBuffer(builder, execID, execIDOffset, execIDLength);
builder.append("\",\n");
}
if (hasExecType())
{
indent(builder, level);
builder.append("\"ExecType\": \"");
builder.append(execType);
builder.append("\",\n");
}
if (hasOrdStatus())
{
indent(builder, level);
builder.append("\"OrdStatus\": \"");
builder.append(ordStatus);
builder.append("\",\n");
}
indent(builder, level);
builder.append("\"Instrument\": ");
instrument.appendTo(builder, level + 1);
builder.append("\n");
if (hasSide())
{
indent(builder, level);
builder.append("\"Side\": \"");
builder.append(side);
builder.append("\",\n");
}
if (hasTransactTime())
{
indent(builder, level);
builder.append("\"TransactTime\": \"");
appendBuffer(builder, transactTime, transactTimeOffset, transactTimeLength);
builder.append("\",\n");
}
indent(builder, level - 1);
builder.append("}");
return builder;
}
public ExecutionReportEncoder copyTo(final Encoder encoder)
{
return copyTo((ExecutionReportEncoder)encoder);
}
public ExecutionReportEncoder copyTo(final ExecutionReportEncoder encoder)
{
encoder.reset();
if (hasOrderID())
{
encoder.orderIDAsCopy(orderID.byteArray(), 0, orderIDLength);
}
if (hasExecID())
{
encoder.execIDAsCopy(execID.byteArray(), 0, execIDLength);
}
if (hasExecType())
{
encoder.execType(this.execType());
}
if (hasOrdStatus())
{
encoder.ordStatus(this.ordStatus());
}
instrument.copyTo(encoder.instrument());
if (hasSide())
{
encoder.side(this.side());
}
if (hasTransactTime())
{
encoder.transactTimeAsCopy(transactTime.byteArray(), 0, transactTimeLength);
}
return encoder;
}
}