本文整理汇总了Java中com.moandjiezana.toml.Toml.to方法的典型用法代码示例。如果您正苦于以下问题:Java Toml.to方法的具体用法?Java Toml.to怎么用?Java Toml.to使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.moandjiezana.toml.Toml
的用法示例。
在下文中一共展示了Toml.to方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fromFile
import com.moandjiezana.toml.Toml; //导入方法依赖的package包/类
public static Sandbox fromFile(File file) {
Log.info("Look for sandbox.toml for file {0}", file.getAbsolutePath());
if (!file.isFile()) {
return null;
}
Log.info("Loadding sandbox.toml for file {0}", file.getAbsolutePath());
Toml boxToml = new Toml().read(file);
Sandbox box = boxToml.to(Sandbox.class);
Toml users = boxToml.getTable("users");
if (emptyInstance(users)) {
box.setUsers(new Users());
} else {
box.setUsers(users.to(Users.class));
}
Toml whitelist = boxToml.getTable("whitelist");
if (emptyInstance(whitelist)) {
box.setWhitelist(new Whitelist());
} else {
box.setWhitelist(whitelist.to(Whitelist.class));
}
return box;
}
示例2: load
import com.moandjiezana.toml.Toml; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static Configuration load(Toml toml) {
Configuration configuration = toml.to(Configuration.class);
configuration.globalOptions = toml.getTable("options").to(GlobalOptions.class);
Map<String, List<String>> map = toml.to(Map.class);
map.entrySet().stream()
.filter(e -> !e.getKey().toString().equals("options"))
.filter(e -> !e.getKey().toString().equals("bundle"))
.map(e -> {
String key = e.getKey().toString().substring(1, e.getKey().toString().length() -1);
Bundle bundle;
if (e.getValue() instanceof List) {
bundle = new Bundle(key, (List<String>) e.getValue());
} else {
List<String> assets = (List<String>) ((Map<String, Object>) e.getValue()).get("assets");
bundle = new Bundle(key, assets);
}
return bundle;
})
.forEach(configuration.bundle::add);
configuration.bundle.forEach(Bundle::normaliseAssets);
return configuration;
}
示例3: create
import com.moandjiezana.toml.Toml; //导入方法依赖的package包/类
/**
* Create a {@link TalonConfiguration} based on supplied config.
*
* @param config the configuration
* @return the TalonConfiguration
* @throws IllegalArgumentException if mode is missing from config
* @throws UnsupportedOperationException if mode not implemented yet
*/
@NotNull
public static TalonConfiguration create(Toml config) {
TalonConfiguration talonConfiguration = null;
CANTalon.TalonControlMode mode = getMode(config);
switch (mode) {
case Voltage:
talonConfiguration = config.to(VoltageTalonConfiguration.class);
break;
case Position:
talonConfiguration = config.to(PositionTalonConfiguration.class);
break;
case Speed:
talonConfiguration = config.to(SpeedTalonConfiguration.class);
break;
case MotionMagic:
talonConfiguration = config.to(MotionMagicTalonConfiguration.class);
break;
case PercentVbus:
case Current:
case Follower:
case MotionProfile:
case Disabled:
throw new UnsupportedOperationException(mode.name());
}
return talonConfiguration;
}
示例4: fromFileName
import com.moandjiezana.toml.Toml; //导入方法依赖的package包/类
public static Config fromFileName(String filename) throws IOException {
String fileContent = new String(Files.readAllBytes(Paths.get(filename)));
Toml toml = (new Toml()).read(fileContent);
return toml.to(Config.class);
}