diff --git a/buildSrc/src/main/groovy/nucleodb.library.gradle b/buildSrc/src/main/groovy/nucleodb.library.gradle index 1de966f..cfabd24 100644 --- a/buildSrc/src/main/groovy/nucleodb.library.gradle +++ b/buildSrc/src/main/groovy/nucleodb.library.gradle @@ -3,7 +3,7 @@ plugins { } group = 'com.nucleodb' -version = '1.9.23' +version = '1.9.24' repositories { mavenCentral() diff --git a/library/src/main/java/com/nucleocore/library/database/utils/DataEntry.java b/library/src/main/java/com/nucleocore/library/database/utils/DataEntry.java index b26414f..d4d8b8c 100644 --- a/library/src/main/java/com/nucleocore/library/database/utils/DataEntry.java +++ b/library/src/main/java/com/nucleocore/library/database/utils/DataEntry.java @@ -2,7 +2,9 @@ import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.MapperFeature; import com.fasterxml.jackson.databind.ObjectMapper; import com.nucleocore.library.database.modifications.Create; import org.jetbrains.annotations.NotNull; @@ -39,15 +41,12 @@ public DataEntry(Create create) throws ClassNotFoundException, JsonProcessingExc } - public DataEntry(DataEntry toCopy) { - try { - for (Field field : DataEntry.class.getDeclaredFields()) { - if(field.isAnnotationPresent(SkipCopy.class)) continue; - field.set(this, field.get(toCopy)); - } - }catch (Exception e){ - e.printStackTrace(); - } + public T copy(Class clazz) throws JsonProcessingException { + ObjectMapper om = new ObjectMapper() + .enable(MapperFeature.ACCEPT_CASE_INSENSITIVE_ENUMS) + .findAndRegisterModules() + .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + return om.readValue(om.writeValueAsString(this), clazz); } public DataEntry() {