gpt4 book ai didi

com.sk89q.util.yaml.YAMLNode.()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-17 01:01:31 27 4
gpt4 key购买 nike

本文整理了Java中com.sk89q.util.yaml.YAMLNode.<init>()方法的一些代码示例,展示了YAMLNode.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YAMLNode.<init>()方法的具体详情如下:
包路径:com.sk89q.util.yaml.YAMLNode
类名称:YAMLNode
方法名:<init>

YAMLNode.<init>介绍

暂无

代码示例

代码示例来源:origin: EngineHub/WorldEdit

/**
 * This method returns an empty ConfigurationNode for using as a
 * default in methods that select a node from a node list.
 *
 * @param writeDefaults true to write default values when a property is requested that doesn't exist
 * @return a node
 */
public static YAMLNode getEmptyNode(boolean writeDefaults) {
  return new YAMLNode(new LinkedHashMap<>(), writeDefaults);
}

代码示例来源:origin: EngineHub/WorldEdit

/**
 * Adds a new node to the given path. The returned object is a reference
 * to the new node. This method will replace an existing node at
 * the same path. See {@code setProperty}.
 * 
 * @param path the path
 * @return a node for the path
 */
public YAMLNode addNode(String path) {
  Map<String, Object> map = new LinkedHashMap<>();
  YAMLNode node = new YAMLNode(map, writeDefaults);
  setProperty(path, map);
  return node;
}

代码示例来源:origin: EngineHub/WorldEdit

/**
 * Get a configuration node at a path. If the node doesn't exist or the
 * path does not lead to a node, null will be returned. A node has
 * key/value mappings.
 * 
 * @param path the path
 * @return node or null
 */
@Nullable
@SuppressWarnings("unchecked")
public YAMLNode getNode(String path) {
  Object raw = getProperty(path);
  if (raw instanceof Map) {
    return new YAMLNode((Map<String, Object>) raw, writeDefaults);
  }
  return null;
}

代码示例来源:origin: EngineHub/WorldEdit

/**
 * Get a list of nodes at a location. If the map at the particular location
 * does not exist or it is not a map, null will be returned.
 * 
 * @param path path to node (dot notation)
 * @return map of nodes
 */
@SuppressWarnings("unchecked")
public Map<String, YAMLNode> getNodes(String path) {
  Object o = getProperty(path);
  if (o == null) {
    return null;
  } else if (o instanceof Map) {
    Map<String, YAMLNode> nodes =
        new LinkedHashMap<>();
    for (Map.Entry<String, Object> entry : ((Map<String, Object>) o).entrySet()) {
      if (entry.getValue() instanceof Map) {
        nodes.put(entry.getKey(),
            new YAMLNode((Map<String, Object>) entry.getValue(), writeDefaults));
      }
    }
    return nodes;
  } else {
    return null;
  }
}

代码示例来源:origin: EngineHub/WorldEdit

/**
 * Gets a list of nodes. Non-valid entries will not be in the list.
 * There will be no null slots. If the list is not defined, the
 * default will be returned. 'null' can be passed for the default
 * and an empty list will be returned instead. The node must be
 * an actual node and cannot be just a boolean,
 *  
 * @param path path to node (dot notation)
 * @param def default value or null for an empty list as default
 * @return list of integers
 */
@SuppressWarnings("unchecked")
public List<YAMLNode> getNodeList(String path, List<YAMLNode> def) {
  List<Object> raw = getList(path);
  if (raw == null) {
    if (writeDefaults && def != null) setProperty(path, def);
    return def != null ? def : new ArrayList<>();
  }
  List<YAMLNode> list = new ArrayList<>();
  for (Object o : raw) {
    if (o instanceof Map) {
      list.add(new YAMLNode((Map<String, Object>) o, writeDefaults));
    }
  }
  return list;
}

代码示例来源:origin: EngineHub/WorldGuard

Map<String, Object> nodeMap = new HashMap<>();
map.put(region.getId(), nodeMap);
YAMLNode node = new YAMLNode(nodeMap, false);

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com