Skip to content

Commit 024ff12

Browse files
committed
sonarqube cleanup.
1 parent 60e5e97 commit 024ff12

5 files changed

Lines changed: 14 additions & 44 deletions

File tree

src/main/java/org/hdf5javalib/dataclass/reference/HdfObjectReference.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@
1515
import java.lang.reflect.InvocationTargetException;
1616
import java.nio.ByteBuffer;
1717
import java.nio.ByteOrder;
18-
import java.util.ArrayList;
19-
import java.util.Arrays;
20-
import java.util.Collections;
21-
import java.util.List;
18+
import java.util.*;
2219
import java.util.concurrent.atomic.AtomicReference;
2320

2421
public class HdfObjectReference implements HdfReferenceInstance {
@@ -125,7 +122,7 @@ public String toString() {
125122
+ "\r\n\treferenceType=" + referenceType.getDescription()
126123
+ "\r\n\thdfDataObject=" + (hdfDataObject == null ? "ObjectId not decoded" : "ObjectName: " + hdfDataObject.getObjectName())
127124
+ (referenceType.getValue() > ReferenceDatatype.ReferenceType.DATASET_REGION1.getValue() ?
128-
"\r\n\tdataspaceSelectionInstance=" + (dataspaceSelectionInstance == null ? "no Dataspace Selection" : dataspaceSelectionInstance)
125+
"\r\n\tdataspaceSelectionInstance=" + (Objects.requireNonNullElse(dataspaceSelectionInstance, "no Dataspace Selection"))
129126
: "")
130127
+ "\r\n]";
131128

src/main/java/org/hdf5javalib/datatype/CompoundDatatype.java

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -313,11 +313,7 @@ public <T> T getInstance(Class<T> clazz, byte[] bytes) throws InvocationTargetEx
313313

314314
// Fall back to toPOJO for non-primitive, unregistered types
315315
if (!clazz.isPrimitive()) {
316-
// try {
317-
return toPOJO(clazz, bytes);
318-
// } catch (Exception e) {
319-
// throw new IllegalArgumentException("Failed to convert to POJO: " + clazz, e);
320-
// }
316+
return toPOJO(clazz, bytes);
321317
}
322318

323319
throw new UnsupportedOperationException("Unknown type: " + clazz);
@@ -345,17 +341,13 @@ public <T> T toPOJO(Class<T> clazz, byte[] bytes) throws InvocationTargetExcepti
345341
// Get cached member map (instance-level cache since members are per-instance)
346342
Map<String, CompoundMemberDatatype> nameToMemberMap = getCachedMemberMap();
347343

348-
// try {
349-
T instance;
350-
if (clazz.isRecord()) {
351-
instance = createRecordInstance(clazz, bytes, nameToMemberMap);
352-
} else {
353-
instance = createClassInstance(clazz, bytes, nameToFieldMap, nameToMemberMap);
354-
}
355-
return instance;
356-
// } catch (Exception e) {
357-
// throw new IllegalStateException("Failed to create instance of " + clazz.getName(), e);
358-
// }
344+
T instance;
345+
if (clazz.isRecord()) {
346+
instance = createRecordInstance(clazz, bytes, nameToMemberMap);
347+
} else {
348+
instance = createClassInstance(clazz, bytes, nameToFieldMap, nameToMemberMap);
349+
}
350+
return instance;
359351
}
360352

361353
// Helper method to get cached member map

src/main/java/org/hdf5javalib/datatype/CompoundMemberDatatype.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ public CompoundMemberDatatype(String name, int offset, int dimensionality, int d
8585
case VLEN -> computeVariableLengthMessageDataSize(name);
8686
case ARRAY -> computeArrayMessageDataSize(name);
8787
};
88-
// log.debug("CompoundMemberDatatype {}", this);
8988
}
9089

9190
private short computeFixedMessageDataSize(String name) {

src/main/java/org/hdf5javalib/datatype/FloatingPointDatatype.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -335,23 +335,13 @@ public double toDoubleValue(byte[] rawBuffer) {
335335
public ByteOrder getByteOrder() {
336336
boolean bit0 = classBitField.get(0);
337337
boolean bit6 = classBitField.get(6);
338-
if (!bit6 && !bit0) return ByteOrder.LITTLE_ENDIAN;
339-
if (!bit6 && bit0) return ByteOrder.BIG_ENDIAN;
340-
if (bit6 && !bit0) throw new IllegalArgumentException("Reserved byte order");
341-
if (bit6 && bit0) throw new UnsupportedOperationException("VAX-endian not supported");
342-
return ByteOrder.LITTLE_ENDIAN; // Default, should never reach here
343-
}
344338

345-
private int getSignLocation() {
346-
int signLoc = 0;
347-
for (int i = 8; i <= 15; i++) {
348-
if (classBitField.get(i)) {
349-
signLoc |= (1 << (i - 8));
350-
}
339+
if (bit6) {
340+
throw bit0 ? new UnsupportedOperationException("VAX-endian not supported")
341+
: new IllegalArgumentException("Reserved byte order");
351342
}
352-
return signLoc;
343+
return bit0 ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN;
353344
}
354-
355345
/**
356346
* Returns a string representation of this FloatingPointDatatype.
357347
*

src/main/java/org/hdf5javalib/package-info.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,6 @@
66
* <p>This package enables Java developers to access and manipulate HDF5 data without requiring external native libraries,
77
* making it suitable for scientific computing, data analysis, and applications dealing with large hierarchical datasets.</p>
88
*
9-
* <p>Key features include:
10-
* <ul>
11-
* <li>Reading of root-group datasets with robust datatype support.</li>
12-
* <li>No external dependencies beyond Java 17 or higher.</li>
13-
* <li>Maven integration for easy inclusion in projects.</li>
14-
* </ul>
15-
* </p>
16-
*
179
* <p>For detailed usage examples and reading capabilities, refer to the project documentation.</p>
1810
*
1911
* @since 0.1.3

0 commit comments

Comments
 (0)