diff --git a/src/main/java/net/openhft/chronicle/wire/utils/ConfigLoader.java b/src/main/java/net/openhft/chronicle/wire/utils/ConfigLoader.java index 7b16afb5fc..b81e57e445 100644 --- a/src/main/java/net/openhft/chronicle/wire/utils/ConfigLoader.java +++ b/src/main/java/net/openhft/chronicle/wire/utils/ConfigLoader.java @@ -2,6 +2,7 @@ import net.openhft.chronicle.core.io.IOTools; import net.openhft.chronicle.wire.TextWire; +import net.openhft.chronicle.wire.WireType; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -51,13 +52,32 @@ public static T loadFromFile(Class classLoader, String filename, Properti return loadWithProperties(loadFile(classLoader, filename), properties); } + public static T loadFromFile(Class expectedClass, Class classLoader, String filename, Properties properties) throws IOException { + return loadWithProperties(expectedClass, loadFile(classLoader, filename), properties); + } + @SuppressWarnings("unchecked") public static T load(String fileAsString) { return (T) TextWire.from(replaceTokensWithProperties(fileAsString)).readObject(); } + @SuppressWarnings("unchecked") + public static T loadWithProperties(String fileAsString) { + return loadWithProperties(fileAsString, System.getProperties()); + } + @SuppressWarnings("unchecked") public static T loadWithProperties(String fileAsString, Properties properties) { - return (T) TextWire.from(replaceTokensWithProperties(fileAsString, properties)).readObject(); + return loadWithProperties(null, fileAsString, properties); + } + + @SuppressWarnings("unchecked") + public static T loadWithProperties(Class expectedClass, String fileAsString) { + return loadWithProperties(expectedClass, fileAsString, System.getProperties()); + } + + @SuppressWarnings("unchecked") + public static T loadWithProperties(Class expectedClass, String fileAsString, Properties properties) { + return WireType.TEXT.fromString(expectedClass, replaceTokensWithProperties(fileAsString, properties)); } }