Skip to content

Commit

Permalink
Add MetadataContainer#toBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeregorix committed Sep 1, 2024
1 parent 3575b09 commit b89e9d0
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ public String toString() {
.toString();
}

public MetadataContainer.Builder toBuilder() {
final Builder builder = new Builder();
builder.loader = this.loader;
builder.license = this.license;
builder.mappings = this.mappings;
builder.globalMetadata = this.globalMetadata;
builder.metadata.addAll(this.metadata);
return builder;
}

public static final class Builder {

final Set<StandardPluginMetadata> metadata = new LinkedHashSet<>();
Expand Down Expand Up @@ -150,6 +160,13 @@ public Builder globalMetadata(final Inheritable globalMetadata) {
}

public Builder metadata(final List<StandardPluginMetadata> metadata) {
Objects.requireNonNull(metadata, "metadata");
this.metadata.clear();
this.metadata.addAll(metadata);
return this;
}

public Builder addMetadata(final List<StandardPluginMetadata> metadata) {
this.metadata.addAll(Objects.requireNonNull(metadata, "metadata"));
return this;
}
Expand Down

0 comments on commit b89e9d0

Please sign in to comment.