mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-01 00:10:40 +01:00
Minor refactor to remove continue from for loop
This commit is contained in:
parent
ad2541963e
commit
2d8b3074a9
@ -338,13 +338,11 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
// Null check
|
// Null check
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
plugin.logError("YAML database request to store a null.");
|
plugin.logError("YAML database request to store a null.");
|
||||||
completableFuture.complete(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
return completableFuture;
|
|
||||||
}
|
}
|
||||||
if (!(instance instanceof DataObject)) {
|
if (!(instance instanceof DataObject)) {
|
||||||
plugin.logError("This class is not a DataObject: " + instance.getClass().getName());
|
plugin.logError("This class is not a DataObject: " + instance.getClass().getName());
|
||||||
completableFuture.complete(false);
|
return CompletableFuture.completedFuture(false);
|
||||||
return completableFuture;
|
|
||||||
}
|
}
|
||||||
// This is the Yaml Configuration that will be used and saved at the end
|
// This is the Yaml Configuration that will be used and saved at the end
|
||||||
YamlConfiguration config = new YamlConfiguration();
|
YamlConfiguration config = new YamlConfiguration();
|
||||||
@ -396,22 +394,21 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
handleConfigEntryComments(configEntry, config, yamlComments, parent);
|
handleConfigEntryComments(configEntry, config, yamlComments, parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkAdapter(field, config, storageLocation, value)) {
|
if (!checkAdapter(field, config, storageLocation, value)) {
|
||||||
continue;
|
// Set the filename if it has not be set already
|
||||||
}
|
if (filename.isEmpty() && method.getName().equals("getUniqueId")) {
|
||||||
// Set the filename if it has not be set already
|
// Save the name for when the file is saved
|
||||||
if (filename.isEmpty() && method.getName().equals("getUniqueId")) {
|
filename = getFilename(propertyDescriptor, instance, (String)value);
|
||||||
// Save the name for when the file is saved
|
}
|
||||||
filename = getFilename(propertyDescriptor, instance, (String)value);
|
// Collections need special serialization
|
||||||
}
|
if (Map.class.isAssignableFrom(propertyDescriptor.getPropertyType()) && value != null) {
|
||||||
// Collections need special serialization
|
serializeMap((Map<Object,Object>)value, config, storageLocation);
|
||||||
if (Map.class.isAssignableFrom(propertyDescriptor.getPropertyType()) && value != null) {
|
} else if (Set.class.isAssignableFrom(propertyDescriptor.getPropertyType()) && value != null) {
|
||||||
serializeMap((Map<Object,Object>)value, config, storageLocation);
|
serializeSet((Set<Object>)value, config, storageLocation);
|
||||||
} else if (Set.class.isAssignableFrom(propertyDescriptor.getPropertyType()) && value != null) {
|
} else {
|
||||||
serializeSet((Set<Object>)value, config, storageLocation);
|
// For all other data that doesn't need special serialization
|
||||||
} else {
|
config.set(storageLocation, serialize(value));
|
||||||
// For all other data that doesn't need special serialization
|
}
|
||||||
config.set(storageLocation, serialize(value));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// If the filename has not been set by now then we have a problem
|
// If the filename has not been set by now then we have a problem
|
||||||
@ -469,6 +466,16 @@ public class YamlDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if an adapter is to be used. If so, it is used and true returned, if not, fase is returned
|
||||||
|
* @param field Field
|
||||||
|
* @param config Yaml Config
|
||||||
|
* @param storageLocation Storage location
|
||||||
|
* @param value Value
|
||||||
|
* @return true if adapater used
|
||||||
|
* @throws IllegalAccessException exception
|
||||||
|
* @throws InvocationTargetException exception
|
||||||
|
*/
|
||||||
private boolean checkAdapter(Field field, YamlConfiguration config, String storageLocation, Object value) throws IllegalAccessException, InvocationTargetException {
|
private boolean checkAdapter(Field field, YamlConfiguration config, String storageLocation, Object value) throws IllegalAccessException, InvocationTargetException {
|
||||||
Adapter adapterNotation = field.getAnnotation(Adapter.class);
|
Adapter adapterNotation = field.getAnnotation(Adapter.class);
|
||||||
if (adapterNotation != null && AdapterInterface.class.isAssignableFrom(adapterNotation.value())) {
|
if (adapterNotation != null && AdapterInterface.class.isAssignableFrom(adapterNotation.value())) {
|
||||||
|
Loading…
Reference in New Issue
Block a user