Created
January 15, 2019 20:33
-
-
Save struberg/0bcb0eea66c47f9de42bd527967fdd67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface DocServer { | |
@ConfigProperty(name="serverport", defaultValue = "8080") | |
int port(); | |
String host(); | |
@ConfigProperty(defaultValue = "/doc") | |
String path(); | |
} | |
/** | |
* The single instance | |
* my.document.mainServer.port=8080 | |
* my.document.mainServer.host=http://localhost | |
* my.document.mainServer.path=/mydoc | |
* | |
* The list: | |
* my.document.allServers.0.port=8080 | |
* my.document.allServers.0.host=http://localhost | |
* my.document.allServers.0.path=/mydoc | |
* my.document.allServers.1.port=8080 | |
* my.document.allServers.1.host=http://localhost | |
* my.document.allServers.1.path=/mydoc | |
* my.document.allServers.karl.port=8080 | |
* my.document.allServers.karl.host=http://localhost | |
* my.document.allServers.karl.path=/mydoc | |
* | |
*/ | |
@Test | |
public void testSimpleTreeStructures() { | |
DocServer docServer = config.getValue("my.document.mainServer", DocServer.class); | |
DocServer[] docServers = config.getValue("my.document.allServers", DocServer[].class); | |
} | |
public interface Server { | |
int port(); | |
String host(); | |
String path(); | |
} | |
public interface ArchiveServer { | |
Server server(); | |
String name(); | |
boolean isPublic(); | |
} | |
@Test | |
public void testNestedTreeStructures() { | |
ArchiveServer archiveServer = config.getValue("my.document.nested.mainServer", ArchiveServer.class); | |
ArchiveServer[] archiveServers = config.getValue("my.document.nested.allServers", ArchiveServer[].class); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment