diff --git a/database/src/main/java/com/georgev22/library/utilities/EntityRepository.java b/database/src/main/java/com/georgev22/library/utilities/EntityRepository.java index a5452cb..90f323d 100644 --- a/database/src/main/java/com/georgev22/library/utilities/EntityRepository.java +++ b/database/src/main/java/com/georgev22/library/utilities/EntityRepository.java @@ -75,12 +75,12 @@ public interface EntityRepository { * @param entityClass The class to check for the constructor. * @throws NoSuchConstructorException If no suitable constructor is found. */ - default void checkForConstructorWithSingleVarargString(@NotNull Class entityClass) throws NoSuchConstructorException { + default void checkForConstructorWithSingleString(@NotNull Class entityClass) throws NoSuchConstructorException { Constructor[] constructors = entityClass.getConstructors(); for (Constructor constructor : constructors) { Parameter[] parameters = constructor.getParameters(); - if (parameters.length == 1 && parameters[0].getType().equals(String.class) && parameters[0].isVarArgs()) { + if (parameters.length == 1 && parameters[0].getType().equals(String.class)) { return; } } diff --git a/database/src/main/java/com/georgev22/library/utilities/MongoDBEntityRepository.java b/database/src/main/java/com/georgev22/library/utilities/MongoDBEntityRepository.java index 544a392..746bb64 100644 --- a/database/src/main/java/com/georgev22/library/utilities/MongoDBEntityRepository.java +++ b/database/src/main/java/com/georgev22/library/utilities/MongoDBEntityRepository.java @@ -91,7 +91,7 @@ public CompletableFuture load(@NotNull String entityId) { if (document != null) { try { - this.checkForConstructorWithSingleVarargString(this.entityClass); + this.checkForConstructorWithSingleString(this.entityClass); V entity = this.entityClass.getConstructor(String.class).newInstance(entityId); for (Map.Entry key : document.entrySet()) { diff --git a/database/src/main/java/com/georgev22/library/utilities/MySQLEntityRepository.java b/database/src/main/java/com/georgev22/library/utilities/MySQLEntityRepository.java index 3b15d8b..fddbe1d 100644 --- a/database/src/main/java/com/georgev22/library/utilities/MySQLEntityRepository.java +++ b/database/src/main/java/com/georgev22/library/utilities/MySQLEntityRepository.java @@ -134,7 +134,7 @@ public CompletableFuture load(@NotNull String entityId) { return null; } if (resultSet.next()) { - this.checkForConstructorWithSingleVarargString(this.entityClass); + this.checkForConstructorWithSingleString(this.entityClass); V entity = this.entityClass.getConstructor(String.class).newInstance(entityId); for (int i = 0; i < resultSet.getMetaData().getColumnCount(); i++) { String columnName = resultSet.getMetaData().getColumnName(i + 1); diff --git a/database/src/main/java/com/georgev22/library/utilities/YamlEntityRepository.java b/database/src/main/java/com/georgev22/library/utilities/YamlEntityRepository.java index 92b03a4..ec87635 100644 --- a/database/src/main/java/com/georgev22/library/utilities/YamlEntityRepository.java +++ b/database/src/main/java/com/georgev22/library/utilities/YamlEntityRepository.java @@ -91,7 +91,7 @@ public CompletableFuture load(@NotNull String entityId) { YamlConfiguration config = YamlConfiguration.loadConfiguration(file); try { - this.checkForConstructorWithSingleVarargString(this.entityClass); + this.checkForConstructorWithSingleString(this.entityClass); V entity = this.entityClass.getConstructor(String.class).newInstance(entityId); for (String key : config.getKeys(false)) { entity.setValue(key, config.get(key));