
com.fluxtion.runtime.dataflow.groupby.GroupBy Maven / Gradle / Ivy
package com.fluxtion.runtime.dataflow.groupby;
import lombok.Value;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
public interface GroupBy {
KeyValue, ?> KV_KEY_VALUE = new KeyValue<>(null, null);
Map toMap();
Collection values();
default V lastValue() {
return null;
}
default KeyValue lastKeyValue() {
return emptyKey();
}
@SuppressWarnings("unchecked")
static KeyValue emptyKey() {
return (KeyValue) KV_KEY_VALUE;
}
@Value
class KeyValue {
K key;
V value;
public Double getValueAsDouble() {
return (Double) value;
}
public Long getValueAsLong() {
return (Long) value;
}
public Integer getValueAsInt() {
return (Integer) value;
}
}
static GroupBy emptyCollection() {
return new EmptyGroupBy<>();
}
class EmptyGroupBy implements GroupBy {
@Override
public V lastValue() {
return null;
}
@Override
public KeyValue lastKeyValue() {
return null;
}
@Override
public Map toMap() {
return Collections.emptyMap();
}
@Override
public Collection values() {
return Collections.emptyList();
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy