Skip to content

Commit

Permalink
Simplify adding tags to generated enum traits
Browse files Browse the repository at this point in the history
  • Loading branch information
JordonPhillips committed Jan 19, 2024
1 parent 29c8473 commit 187ec1f
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,9 +290,13 @@ static EnumDefinition enumDefinitionFromMember(MemberShape member) {
member.getTrait(DocumentationTrait.class).ifPresent(docTrait -> builder.documentation(docTrait.getValue()));
member.getTrait(DeprecatedTrait.class).ifPresent(deprecatedTrait -> builder.deprecated(true));

Optional<List<String>> tags = member.getTrait(TagsTrait.class).map(StringListTrait::getValues);
tags.ifPresent(builder::tags);
if (member.hasTrait(InternalTrait.class) && !tags.map(t -> t.contains("internal")).orElse(false)) {
List<String> tags = member.getTrait(Tags
Trait.class)
.map(StringListTrait::getValues)
.orElse(Collections.emptyList());

builder.tags(tags);
if (member.hasTrait(InternalTrait.class) && !tags.contains("internal")) {
builder.addTag("internal");
}
return builder.build();
Expand Down

0 comments on commit 187ec1f

Please sign in to comment.