use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class MorphingPortableReader method readBoolean.
@Override
public boolean readBoolean(String fieldName) throws IOException {
FieldDefinition fd = cd.getField(fieldName);
if (fd == null) {
return false;
}
validateTypeCompatibility(fd, BOOLEAN);
return super.readBoolean(fieldName);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class MorphingPortableReader method readIntArray.
@Override
public int[] readIntArray(String fieldName) throws IOException {
FieldDefinition fd = cd.getField(fieldName);
if (fd == null) {
return null;
}
validateTypeCompatibility(fd, INT_ARRAY);
return super.readIntArray(fieldName);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class MorphingPortableReader method readLongArray.
@Override
public long[] readLongArray(String fieldName) throws IOException {
FieldDefinition fd = cd.getField(fieldName);
if (fd == null) {
return null;
}
validateTypeCompatibility(fd, LONG_ARRAY);
return super.readLongArray(fieldName);
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class PortableContextImpl method getFieldDefinition.
@Override
public // TODO cache the result
FieldDefinition getFieldDefinition(ClassDefinition classDef, String name) {
FieldDefinition fd = classDef.getField(name);
if (fd == null) {
if (name.contains(".")) {
String[] fieldNames = NESTED_FIELD_PATTERN.split(name);
if (fieldNames.length <= 1) {
return fd;
}
ClassDefinition currentClassDef = classDef;
for (int i = 0; i < fieldNames.length; i++) {
fd = currentClassDef.getField(fieldNames[i]);
if (fd == null) {
fd = currentClassDef.getField(extractAttributeNameNameWithoutArguments(fieldNames[i]));
}
// This is not enough to fully implement issue: https://github.com/hazelcast/hazelcast/issues/3927
if (i == fieldNames.length - 1) {
break;
}
if (fd == null) {
throw new IllegalArgumentException("Unknown field: " + name);
}
currentClassDef = lookupClassDefinition(fd.getFactoryId(), fd.getClassId(), fd.getVersion());
if (currentClassDef == null) {
throw new IllegalArgumentException("Not a registered Portable field: " + fd);
}
}
} else {
fd = classDef.getField(extractAttributeNameNameWithoutArguments(name));
}
}
return fd;
}
use of com.hazelcast.nio.serialization.FieldDefinition in project hazelcast by hazelcast.
the class PortablePositionFactoryTest method createSinglePortablePosition.
@Test
public void createSinglePortablePosition() {
// GIVEN
FieldDefinition fd = new FieldDefinitionImpl(1, "field", FieldType.PORTABLE, 0);
int streamPosition = 100;
int factoryId = 123, classId = 546;
boolean nil = false, leaf = true;
// WHEN
PortablePosition p = PortablePositionFactory.createSinglePortablePosition(fd, streamPosition, factoryId, classId, nil, leaf);
// THEN
assertFalse(p.isNull());
assertFalse(p.isEmpty());
assertFalse(p.isNullOrEmpty());
assertEquals(nil, p.isNull());
assertEquals(leaf, p.isLeaf());
assertFalse(p.isAny());
assertEquals(fd.getType(), p.getType());
assertEquals(-1, p.getLen());
assertEquals(classId, p.getClassId());
assertEquals(factoryId, p.getFactoryId());
assertEquals(-1, p.getIndex());
assertEquals(streamPosition, p.getStreamPosition());
assertFalse(p.isMultiPosition());
assertAsMultiPositionThrowsException(p);
}
Aggregations