aboutsummaryrefslogtreecommitdiff
path: root/spark-common/src/main/java/me/lucko/spark/common/sampler
diff options
context:
space:
mode:
authorLuck <git@lucko.me>2024-09-05 20:37:25 +0100
committerLuck <git@lucko.me>2024-09-05 20:37:37 +0100
commit8986c711cef445650ceef832a3ac999819cd06a0 (patch)
tree3a53b128d88ad5f3028c0651e1c2b03a0cbd5288 /spark-common/src/main/java/me/lucko/spark/common/sampler
parented33fd51cefabfd04df4376dc2118f31ce93a90d (diff)
downloadspark-8986c711cef445650ceef832a3ac999819cd06a0.tar.gz
spark-8986c711cef445650ceef832a3ac999819cd06a0.tar.bz2
spark-8986c711cef445650ceef832a3ac999819cd06a0.zip
Include datapacks info in sampler proto
Diffstat (limited to 'spark-common/src/main/java/me/lucko/spark/common/sampler')
-rw-r--r--spark-common/src/main/java/me/lucko/spark/common/sampler/source/SourceMetadata.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/spark-common/src/main/java/me/lucko/spark/common/sampler/source/SourceMetadata.java b/spark-common/src/main/java/me/lucko/spark/common/sampler/source/SourceMetadata.java
index 9410b80..d023a68 100644
--- a/spark-common/src/main/java/me/lucko/spark/common/sampler/source/SourceMetadata.java
+++ b/spark-common/src/main/java/me/lucko/spark/common/sampler/source/SourceMetadata.java
@@ -33,15 +33,16 @@ import java.util.function.Function;
*/
public class SourceMetadata {
- public static <T> List<SourceMetadata> gather(Collection<T> sources, Function<? super T, String> nameFunction, Function<? super T, String> versionFunction, Function<? super T, String> authorFunction) {
+ public static <T> List<SourceMetadata> gather(Collection<T> sources, Function<? super T, String> name, Function<? super T, String> version, Function<? super T, String> author, Function<? super T, String> description) {
ImmutableList.Builder<SourceMetadata> builder = ImmutableList.builder();
for (T source : sources) {
- String name = nameFunction.apply(source);
- String version = versionFunction.apply(source);
- String author = authorFunction.apply(source);
-
- SourceMetadata metadata = new SourceMetadata(name, version, author);
+ SourceMetadata metadata = new SourceMetadata(
+ name.apply(source),
+ version.apply(source),
+ author.apply(source),
+ description.apply(source)
+ );
builder.add(metadata);
}
@@ -51,11 +52,13 @@ public class SourceMetadata {
private final String name;
private final String version;
private final String author;
+ private final String description;
- public SourceMetadata(String name, String version, String author) {
+ public SourceMetadata(String name, String version, String author, String description) {
this.name = name;
this.version = version;
this.author = author;
+ this.description = description;
}
public String getName() {
@@ -78,6 +81,9 @@ public class SourceMetadata {
if (this.author != null) {
builder.setAuthor(this.author);
}
+ if (this.description != null) {
+ builder.setDescription(this.description);
+ }
return builder.build();
}