Fix checkstyle violation

This commit is contained in:
Braydon 2023-12-17 21:22:20 -05:00
parent b28d9e0645
commit 2626ba7ffd

@ -30,10 +30,9 @@ import java.util.UUID;
* document is universal between all {@link IDatabase}'s. * document is universal between all {@link IDatabase}'s.
* *
* @author Braydon * @author Braydon
* @param <V> the type of value this document holds
*/ */
@Getter @ToString @Getter @ToString
public class Document<V> { public class Document {
/** /**
* The key to use for the id field. * The key to use for the id field.
*/ */
@ -52,10 +51,8 @@ public class Document<V> {
* a tuple that contains the Java field, as well as * a tuple that contains the Java field, as well as
* the field value. * the field value.
* </p> * </p>
*
* @see V for value type
*/ */
private final Map<String, Tuple<java.lang.reflect.Field, V>> mappedData = Collections.synchronizedMap(new LinkedHashMap<>()); private final Map<String, Tuple<java.lang.reflect.Field, Object>> mappedData = Collections.synchronizedMap(new LinkedHashMap<>());
@SneakyThrows @SneakyThrows
public Document(@NonNull Object element) { public Document(@NonNull Object element) {
@ -88,7 +85,7 @@ public class Document<V> {
value = value.toString(); value = value.toString();
} }
mappedData.put(key, new Tuple<>(field, (V) value)); // Store in our map mappedData.put(key, new Tuple<>(field, value)); // Store in our map
} }
assert idKey != null; // We need an id key assert idKey != null; // We need an id key
if (rawDataField != null) { // We have a raw data field, set it if (rawDataField != null) { // We have a raw data field, set it
@ -97,7 +94,7 @@ public class Document<V> {
} }
this.idKey = idKey; // Set our id key this.idKey = idKey; // Set our id key
Tuple<java.lang.reflect.Field, V> key = mappedData.get(idKey); // Get the id from the data map Tuple<java.lang.reflect.Field, Object> key = mappedData.get(idKey); // Get the id from the data map
if (key == null) { // The element is missing an id field if (key == null) { // The element is missing an id field
throw new IllegalArgumentException("No @Id annotated field found in " + clazz.getSimpleName()); throw new IllegalArgumentException("No @Id annotated field found in " + clazz.getSimpleName());
} }
@ -111,14 +108,10 @@ public class Document<V> {
* @see #mappedData for stored data * @see #mappedData for stored data
*/ */
@NonNull @NonNull
public Map<String, V> toMappedData() { public Map<String, Object> toMappedData() {
Map<String, V> mappedData = new LinkedHashMap<>(); // The mapped data Map<String, Object> mappedData = new LinkedHashMap<>(); // The mapped data
try { for (Map.Entry<String, Tuple<java.lang.reflect.Field, Object>> entry : this.mappedData.entrySet()) {
for (Map.Entry<String, Tuple<java.lang.reflect.Field, V>> entry : this.mappedData.entrySet()) { mappedData.put(entry.getKey(), entry.getValue().getRight());
mappedData.put(entry.getKey(), entry.getValue().getRight());
}
} catch (Exception ex) {
ex.printStackTrace();
} }
return mappedData; return mappedData;
} }