コード例 #1
0
    @Override
    public Node representData(Object data) {
      ConfigurationSerializable serializable = (ConfigurationSerializable) data;
      Map<String, Object> values = new LinkedHashMap<>();
      values.put(
          ConfigurationSerialization.SERIALIZED_TYPE_KEY,
          ConfigurationSerialization.getAlias(serializable.getClass()));
      values.putAll(serializable.serialize());

      return super.representData(values);
    }
コード例 #2
0
    @Override
    public Object construct(Node node) {
      if (node.isTwoStepsConstruction()) {
        throw new YAMLException("Unexpected referential mapping structure. Node: " + node);
      }

      Map<?, ?> raw = (Map<?, ?>) super.construct(node);

      if (raw.containsKey(ConfigurationSerialization.SERIALIZED_TYPE_KEY)) {
        Map<String, Object> typed = new LinkedHashMap<>(raw.size());
        for (Map.Entry<?, ?> entry : raw.entrySet()) {
          typed.put(entry.getKey().toString(), entry.getValue());
        }

        try {
          return ConfigurationSerialization.deserializeObject(typed);
        } catch (IllegalArgumentException ex) {
          throw new YAMLException("Could not deserialize object", ex);
        }
      }

      return raw;
    }
コード例 #3
0
ファイル: MessagePart.java プロジェクト: sgdc3/PlotSquared
 static {
   ConfigurationSerialization.registerClass(MessagePart.class);
 }
コード例 #4
0
 static {
   ConfigurationSerialization.registerClass(FancyMessage.class);
 }