XmlNamespaceTrait extends AbstractTrait implements ToSmithyBuilder<XmlNamespaceTrait> { @Override protected Node createNode() { return new ObjectNode(MapUtils.of(), getSourceLocation()) .withMember(URI, Node.from(uri)) .withOptionalMember(PREFIX, getPrefix().map(Node::from)); } private  XmlNamespaceTrait(Builder builder); String getUri(); Optional<String> getPrefix(); static Builder builder(); @Override Builder toBuilder(); static final ShapeId ID; }
@Test public void omitsEmptiesFromSerializedNode() { TraitFactory provider = TraitFactory.createServiceFactory(); ObjectNode node = Node.objectNode() .withMember("uri", Node.from("https: Optional<Trait> trait = provider.createTrait( ShapeId.from("smithy.api#xmlNamespace"), ShapeId.from("ns.qux#foo"), node); assertTrue(trait.isPresent()); assertThat(trait.get(), instanceOf(XmlNamespaceTrait.class)); ObjectNode serialized = ((XmlNamespaceTrait) trait.get()).createNode().expectObjectNode(); assertFalse(serialized.getMember("prefix").isPresent()); }