YamlNode

버킷 ConfigurationSection에 대응하는 SigYaml의 yaml node 입니다.

Usage

String originalYaml = """
hello: HELLO!
test:
  name: "qsef1256"
  desc:
    - "First"
    - "Second"
integer: 100
long: 235723895723985723
double: 0.00001
boolean: true
character: "a"
""";

YamlNode node = controller.read(originalYaml);

String hello = node.getString("hello");

int integer = node.getInteger("integer");
long longNum = node.getLong("long");
double doubleNum = node.getDouble("double");
boolean bool = node.getBoolean("boolean");
char character = node.getCharacter("character");

YamlNode test = node.getMap("test");
String name = test.getString("name");
List<String> desc = test.getStringList("desc");

Programmatic create

Feature

  • 기본적인 get, getList, getMap, put, remove, isType

  • getPath, getPathList, 오류 시 path trace

  • getKeys, getNodeMap(원본데이터)

  • 기본 값(def) 및 지정되지 않았을 시 exception

  • 기본 데이터 타입은 Map<String, Object> 입니다.

  • 기본 구현체는 YamlNodeImpl입니다.

  • 값 변환에 SigParser 모듈을 사용합니다.

Difference

  • Bukkit specific 한 부분 (OfflinePlayer, Vector, ItemStack, Color, ConfigurationSection, ConfigurationSerializable)

  • getKeys(deep: true)

  • type check methods (is~), isType은 존재

  • getParent()

  • comment related feature

Origin value

get~ 메서드를 통해 가져오는 값은 방어적 복사가 되어 있으며, 일반적인 방법으로 원본 값을 수정할 수 없습니다.

getOrigin~put 메서드를 통해서 원본 값을 가져와 수정할 수 있습니다.

YamlNodeAdapter

YamlNode 를 가지고 있는 클래스가 있다면 YamlNodeAdapter를 통해 제공된 YamlNode의 기능을 사용할 수 있게 할 수 있습니다.

Migration

SerializedMap

마이그레이션 시 아래의 차이점을 주의하세요.

  • containsKey -> has

  • YamlNode는 반드시 기본 값을 명시 해야 합니다.

Last updated