Skip to content

Commit

Permalink
[NCL-5611] Fixing MultiValuedMapProtobufWrapper various issues
Browse files Browse the repository at this point in the history
  • Loading branch information
thescouser89 committed Aug 17, 2021
1 parent 7ee24b5 commit 550091e
Showing 1 changed file with 6 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.jboss.pnc.build.finder.protobuf;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;

import org.apache.commons.collections4.MultiValuedMap;
Expand All @@ -32,7 +31,7 @@
* @param <V> The value type
*/
public class MultiValuedMapProtobufWrapper<K, V> extends HashSetValuedHashMap<K, V> {
private static final long serialVersionUID = 20211111L;
private static final long serialVersionUID = -4929571021288563518L;

/**
* Constructor wrapping around the MultiValuedMap
Expand All @@ -49,13 +48,13 @@ public MultiValuedMapProtobufWrapper(MultiValuedMap<K, V> map) {
* @param entries
*/
@ProtoFactory
MultiValuedMapProtobufWrapper(List<MultiValuedMapProtobufEntry<K, V>> entries) {
MultiValuedMapProtobufWrapper(Collection<MultiValuedMapProtobufEntry<K, V>> entries) {
super();
entries.forEach(a -> this.putAll(a.key, a.values));
}

@ProtoField(number = 1)
List<MultiValuedMapProtobufEntry<K, V>> getEntries() {
Collection<MultiValuedMapProtobufEntry<K, V>> getEntries() {
return this.asMap()
.entrySet()
.stream()
Expand All @@ -76,12 +75,12 @@ List<MultiValuedMapProtobufEntry<K, V>> getEntries() {
* @see ProtobufSerializer
*/
static class MultiValuedMapProtobufEntry<K, V> {

private K key;
private Collection<V> values;

// Required by Protostream
MultiValuedMapProtobufEntry() {

}

MultiValuedMapProtobufEntry(K key, Collection<V> values) {
Expand All @@ -91,7 +90,7 @@ static class MultiValuedMapProtobufEntry<K, V> {

@SuppressWarnings("unchecked")
@ProtoFactory
MultiValuedMapProtobufEntry(WrappedMessage key, List<WrappedMessage> values) {
MultiValuedMapProtobufEntry(WrappedMessage key, Collection<WrappedMessage> values) {
this.key = (K) key.getValue();
this.values = values.stream().map(a -> (V) a.getValue()).collect(Collectors.toList());
}
Expand All @@ -102,7 +101,7 @@ WrappedMessage getKey() {
}

@ProtoField(number = 2)
List<WrappedMessage> getValues() {
Collection<WrappedMessage> getValues() {
return this.values.stream().map(WrappedMessage::new).collect(Collectors.toList());
}
}
Expand Down

0 comments on commit 550091e

Please sign in to comment.