My goal is to locate and print any missing values in my data using the Set interface.
I have a POJO like below
public class Info {
private final String folder;
private final String version;
private final String key;
public static Builder builder() {
return new Builder();
}
public static Builder builder(Info info) {
return new Builder(info);
}
private Info(Builder builder) {
this.folder = builder.folder;
this.version = builder.version;
this.key = builder.key;
public String getFolder() {
return folder;
}
public String getVersion() {
return version;
}
public String getCreated() {
return created;
}
// toString(), hashCode(), equals()
// Builder class
public Builder withFolder(String folder){
this.folder = folder;
return this;
}
// withVersion(String version)
// withKey(String key)
public Info build(){
return new Info(this);
}
}
Using the below code, I create a list from my data source.
List<Info> newList = previousList.stream().map(m -> Info.builder()
.withFolder(m.getFolder())
.withKey(m.getKey())
.withVersion(m.getVersion())
.build())
.collect(Collectors.toList());
// Printed output is below
list.forEach(System.out::println);
Below is output similar to my list output. Two example folders and two example missing files are shown. For each key, there are multiple version numbers.
// Output
[folder=folderA, version=3.48.137, key=fileA-sources.jar]
[folder=folderA, version=3.48.128, key=fileA-sources.jar]
[folder=folderA, version=3.48.125, key=fileA-sources.jar]
[folder=folderA, version=3.48.137, key=fileA-javadoc.jar]
[folder=folderA, version=3.48.128, key=fileA-javadoc.jar]
[folder=folderA, version=3.48.125, key=fileA-javadoc.jar]
[folder=folderA, version=3.48.137, key=fileA.jar]
[folder=folderA, version=3.48.128, key=fileA.jar]
// Missing [folder=folderA, version= 3.48.125, key=fileA.jar]
[folder=folderB, version=1.7.16, key=fileB.pom]
[folder=folderB, version=1.7.14, key=fileB.pom]
[folder=folderB, version=1.7.12, key=fileB.pom]
[folder=folderB, version=1.7.16, key=fileB.jar]
[folder=folderB, version=1.7.14, key=fileB.jar]
// Missing [folder=folderB, version 1.7.12, key=fileB.jar]
Below is my stream to convert the list into a set.
Set<Info> set = list.stream().map(m -> Info.builder()
.withFolder(m.getFolderKey())
.withVersion(m.getVersion())
.withKey(m.getKey())
.build()).collect(Collectors.toSet());
My goal is to locate and print any missing values in my data using a Set. Specifically the version numbers.
I want to compare the version numbers that are part of fileA-sources.jar, fileA-javadoc.jar, and fileA.jar in order to find any that are missing. See above Output for a commented example of a missing entry.
My data contains seven different file types and there are many similar entries to the two above.
I'm pretty new to Java and most likely missing some very elementary things. I realize that my plan may be completely off, so any help or a point in the right direction is appreciated. Thank you.