Skip to content

Commit

Permalink
Update Serializable protocol to not use a property prefix.
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcsmith-net committed May 22, 2024
1 parent f1b5d5e commit b76cd53
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2023 Neil C Smith.
* Copyright 2024 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3 only, as
Expand Down Expand Up @@ -35,19 +35,18 @@
* usually be implemented by a root container.
* <p>
* The standard format is a hierarchical map. Annotation keys, including type,
* info and connections, are prefixed by <code>%</code>. Property keys are
* prefixed by <code>.</code>. Child keys are prefixed by <code>@</code> and the
* values are maps.
* info and connections, are prefixed by <code>%</code>. Child keys are prefixed
* by <code>@</code> and the values are maps. Property keys are not prefixed.
* <pre>
* {@code
* %type core:container
* %info ...
* %custom-annotation foo
* .property1 true
* property1 true
* @child1 {
* %type core:custom
* %info ...
* .property1 42
* property1 42
* }
* @child2 {
* %type core:custom
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2023 Neil C Smith.
* Copyright 2024 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3 only, as
Expand Down Expand Up @@ -44,7 +44,6 @@ public final class MapTreeWriter implements TreeWriter {

private static final String ANNOTATION_PREFIX = "%";
private static final String CHILD_PREFIX = "@";
private static final String PROPERTY_PREFIX = ".";

private static final String TYPE_KEY = ANNOTATION_PREFIX + "type";
private static final String INFO_KEY = ANNOTATION_PREFIX + "info";
Expand Down Expand Up @@ -97,7 +96,7 @@ public MapTreeWriter writeInfo(ComponentInfo info) {

@Override
public MapTreeWriter writeProperty(String id, Value value) {
map.put(PROPERTY_PREFIX + id, value);
map.put(id, value);
return this;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright 2023 Neil C Smith.
* Copyright 2024 Neil C Smith.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3 only, as
Expand Down Expand Up @@ -79,18 +79,18 @@ private PMap buildComparison() {
builder.put("%type", ComponentType.of("core:container"));
builder.put("%info", ContainerProtocol.API_INFO);
builder.put("%custom", PString.of("FOO"));
builder.put(".p1", 1);
builder.put(".p2", true);
builder.put("p1", 1);
builder.put("p2", true);
builder.put("@child1", PMap.builder()
.put("%type", ComponentType.of("core:type1"))
.put("%info", ComponentProtocol.API_INFO)
.put(".p1", "value")
.put("p1", "value")
.build()
);
builder.put("@child2", PMap.builder()
.put("%type", ComponentType.of("core:type2"))
.put("%info", ComponentProtocol.API_INFO)
.put(".p1", 42)
.put("p1", 42)
.build()
);
builder.put("%connections", PArray.of(
Expand Down

0 comments on commit b76cd53

Please sign in to comment.