Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2023 EPAM Systems, Inc.
Copyright 2026 EPAM Systems, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.epam.deltix.qsrv.hf.pub.md.*;
import com.epam.deltix.timebase.messages.SchemaElement;
import com.epam.deltix.timebase.messages.SchemaIgnore;
import com.epam.deltix.util.annotations.TimestampNs;
import com.epam.deltix.util.collections.generated.ObjectArrayList;
import com.epam.deltix.util.lang.Util;

Expand Down Expand Up @@ -217,7 +218,7 @@ private boolean searchPublicProperties (Class<?> cls) throws NoSuchFieldExceptio
// setter/getter for the nanoseconds precision has suffix "Ns"
try {
if (field.getType() instanceof DateTimeDataType && ((DateTimeDataType) field.getType()).hasNanosecondPrecision()) {
if (!method.getName().endsWith(fieldName + "Ns"))
if (method.getAnnotation(TimestampNs.class) == null)
method = cls.getMethod(method.getName() + "Ns");
}
} catch (NoSuchMethodException e) {
Expand All @@ -240,8 +241,10 @@ private boolean searchPublicProperties (Class<?> cls) throws NoSuchFieldExceptio
if (schemaElement != null && isValidGetterJavaBeanNotation(method, fieldName, isBooleanField)) {
// setter/getter for the nanoseconds precision has suffix "Ns"
try {
if (field.getType() instanceof DateTimeDataType && ((DateTimeDataType) field.getType()).hasNanosecondPrecision())
method = cls.getMethod(method.getName() + "Ns");
if (field.getType() instanceof DateTimeDataType && ((DateTimeDataType) field.getType()).hasNanosecondPrecision()) {
if (method.getAnnotation(TimestampNs.class) == null)
method = cls.getMethod(method.getName() + "Ns");
}
} catch (NoSuchMethodException e) {
LOG.warn("Nanosecond getter with name \"" + (method.getName() + "Ns") + "\" is not found in class " + cls);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package com.epam.deltix.test.qsrv.hf.pub;

import com.epam.deltix.qsrv.hf.pub.codec.CodecFactory;
import com.epam.deltix.qsrv.hf.pub.md.Introspector;
import com.epam.deltix.qsrv.hf.pub.md.RecordClassDescriptor;
import com.epam.deltix.timebase.messages.InstrumentMessage;
import com.epam.deltix.timebase.messages.*;
import com.epam.deltix.util.annotations.TimestampNs;
import com.epam.deltix.util.memory.MemoryDataInput;
import com.epam.deltix.util.memory.MemoryDataOutput;
import org.junit.Test;

import static com.epam.deltix.qsrv.hf.pub.md.Introspector.*;
import static org.junit.Assert.assertEquals;

public class Test_RecordCodecsTime {

public static class TestMessage extends InstrumentMessage {

@TimestampNs
private long customTime;

public TestMessage() {
}

@SchemaType(encoding = "NANOSECOND",dataType = SchemaDataType.TIMESTAMP)
@SchemaElement(name="customTime")
@TimestampNs
public long getCustomTime() {
return customTime;
}

public void setCustomTime(@TimestampNs long customTime) {
this.customTime = customTime;
}
}

private CodecFactory factory;

private void setUpComp () {
factory = CodecFactory.newCompiledCachingFactory();
}

private void setUpIntp () {
factory = CodecFactory.newInterpretingCachingFactory();
}

@Test
public void testInterpretted () throws Exception {
setUpIntp();
testAllTypeFields();
}

@Test
public void testCompiled () throws Exception {
setUpIntp();
testAllTypeFields();
}

private void testAllTypeFields () throws Exception {
//final RecordClassDescriptor rcd = Test_RecordCodecsBase.getRCD(TestMessage.class);
final TestMessage msg = new TestMessage();

msg.setCustomTime(123456789L);
TestMessage decoded = (TestMessage)encodeDecode(msg, TestMessage.class);
assertEquals(123456789L, decoded.getCustomTime());

}

private InstrumentMessage encodeDecode(InstrumentMessage msg, Class<?> outClass) throws IntrospectionException {

RecordClassDescriptor rcd = (RecordClassDescriptor) introspectSingleClass(msg.getClass());

MemoryDataOutput out = new MemoryDataOutput();
factory.createFixedBoundEncoder(cd -> msg.getClass(), rcd).encode(msg, out);

MemoryDataInput in = new MemoryDataInput(out);
return (InstrumentMessage) factory.createFixedBoundDecoder(
cd -> outClass, rcd).decode(in);

}

}
Loading