当前位置: 首页>>代码示例>>Java>>正文


Java Toml.to方法代码示例

本文整理汇总了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;
}
 
开发者ID:StallionCMS,项目名称:stallion-core,代码行数:23,代码来源:Sandbox.java

示例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;
}
 
开发者ID:mwanji,项目名称:humpty,代码行数:27,代码来源:Configuration.java

示例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;
}
 
开发者ID:strykeforce,项目名称:thirdcoast,代码行数:35,代码来源:TalonConfigurationBuilder.java

示例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);
}
 
开发者ID:Samoxive,项目名称:SafetyJim,代码行数:6,代码来源:Config.java


注:本文中的com.moandjiezana.toml.Toml.to方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。