mirror of
https://github.com/tiennm99/zfoo.git
synced 2026-06-02 00:15:43 +00:00
fix[storage]: Fix record class generation protocol error.
This commit is contained in:
@@ -429,7 +429,8 @@ public class ProtocolAnalysis {
|
||||
try {
|
||||
var registrationList = new ArrayList<IFieldRegistration>();
|
||||
List<Field> fields = fieldsEntry.getKey();
|
||||
if (clazz.isRecord()) {
|
||||
boolean isRecord = clazz.isRecord();
|
||||
if (isRecord) {
|
||||
fields = fieldsEntry.getValue();
|
||||
}
|
||||
for (var field : fields) {
|
||||
@@ -437,7 +438,7 @@ public class ProtocolAnalysis {
|
||||
}
|
||||
|
||||
Constructor constructor;
|
||||
if (clazz.isRecord()) {
|
||||
if (isRecord) {
|
||||
constructor = ReflectionUtils.getConstructor(clazz, fields.stream().map(p -> p.getType()).toList().toArray(new Class[]{}));
|
||||
} else {
|
||||
constructor = clazz.getDeclaredConstructor();
|
||||
@@ -447,8 +448,12 @@ public class ProtocolAnalysis {
|
||||
var protocol = new ProtocolRegistration();
|
||||
protocol.setId(protocolId);
|
||||
protocol.setConstructor(constructor);
|
||||
protocol.setFields(ArrayUtils.listToArray(fieldsEntry.getKey(), Field.class));
|
||||
protocol.setOriginalFields(ArrayUtils.listToArray(fieldsEntry.getValue(), Field.class));
|
||||
if (isRecord) {
|
||||
protocol.setFields(ArrayUtils.listToArray(fieldsEntry.getValue(), Field.class));
|
||||
protocol.setOriginalFields(ArrayUtils.listToArray(fieldsEntry.getValue(), Field.class));
|
||||
} else {
|
||||
protocol.setFields(ArrayUtils.listToArray(fieldsEntry.getKey(), Field.class));
|
||||
}
|
||||
protocol.setFieldRegistrations(ArrayUtils.listToArray(registrationList, IFieldRegistration.class));
|
||||
protocol.setModule(module.getId());
|
||||
return protocol;
|
||||
|
||||
@@ -86,7 +86,7 @@ public class StorageInt<K, V> extends StorageObject<K, V> {
|
||||
|
||||
@Override
|
||||
public Collection<V> getAll() {
|
||||
return dataMap.values().stream().collect(Collectors.toUnmodifiableList());
|
||||
return dataMap.values().stream().toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -86,7 +86,7 @@ public class StorageLong<K, V> extends StorageObject<K, V> {
|
||||
|
||||
@Override
|
||||
public Collection<V> getAll() {
|
||||
return dataMap.values().stream().collect(Collectors.toUnmodifiableList());
|
||||
return dataMap.values().stream().toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -145,7 +145,7 @@ public class StorageObject<K, V> implements IStorage<K, V> {
|
||||
@Override
|
||||
public List<V> getList() {
|
||||
Collection<V> all = getAll();
|
||||
return all.stream().collect(Collectors.toUnmodifiableList());
|
||||
return all.stream().toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user