|
2 | 2 |
|
3 | 3 | import net.openhft.chronicle.core.io.IOTools;
|
4 | 4 | import net.openhft.chronicle.wire.TextWire;
|
| 5 | +import net.openhft.chronicle.wire.WireType; |
5 | 6 |
|
6 | 7 | import java.io.IOException;
|
7 | 8 | import java.nio.charset.StandardCharsets;
|
@@ -51,13 +52,32 @@ public static <T> T loadFromFile(Class<?> classLoader, String filename, Properti
|
51 | 52 | return loadWithProperties(loadFile(classLoader, filename), properties);
|
52 | 53 | }
|
53 | 54 |
|
| 55 | + public static <T> T loadFromFile(Class<T> expectedClass, Class<?> classLoader, String filename, Properties properties) throws IOException { |
| 56 | + return loadWithProperties(expectedClass, loadFile(classLoader, filename), properties); |
| 57 | + } |
| 58 | + |
54 | 59 | @SuppressWarnings("unchecked")
|
55 | 60 | public static <T> T load(String fileAsString) {
|
56 | 61 | return (T) TextWire.from(replaceTokensWithProperties(fileAsString)).readObject();
|
57 | 62 | }
|
58 | 63 |
|
| 64 | + @SuppressWarnings("unchecked") |
| 65 | + public static <T> T loadWithProperties(String fileAsString) { |
| 66 | + return loadWithProperties(fileAsString, System.getProperties()); |
| 67 | + } |
| 68 | + |
59 | 69 | @SuppressWarnings("unchecked")
|
60 | 70 | public static <T> T loadWithProperties(String fileAsString, Properties properties) {
|
61 |
| - return (T) TextWire.from(replaceTokensWithProperties(fileAsString, properties)).readObject(); |
| 71 | + return loadWithProperties(null, fileAsString, properties); |
| 72 | + } |
| 73 | + |
| 74 | + @SuppressWarnings("unchecked") |
| 75 | + public static <T> T loadWithProperties(Class<T> expectedClass, String fileAsString) { |
| 76 | + return loadWithProperties(expectedClass, fileAsString, System.getProperties()); |
| 77 | + } |
| 78 | + |
| 79 | + @SuppressWarnings("unchecked") |
| 80 | + public static <T> T loadWithProperties(Class<T> expectedClass, String fileAsString, Properties properties) { |
| 81 | + return WireType.TEXT.fromString(expectedClass, replaceTokensWithProperties(fileAsString, properties)); |
62 | 82 | }
|
63 | 83 | }
|
0 commit comments