
io.phasetwo.service.model.WithAttributes Maven / Gradle / Ivy
package io.phasetwo.service.model;
import com.google.common.collect.ImmutableList;
import java.util.List;
import java.util.Map;
import java.util.stream.Stream;
public interface WithAttributes {
Map> getAttributes();
default Stream getAttributesStream(String name) {
List attrs = getAttributes().get(name);
if (attrs != null && attrs.size() > 0) {
return attrs.stream();
} else {
return Stream.empty();
}
}
default String getFirstAttribute(String name) {
List attrs = getAttributes().get(name);
if (attrs != null && attrs.size() > 0) {
return attrs.get(0);
} else {
return null;
}
}
void removeAttributes();
void removeAttribute(String name);
void setAttribute(String name, List values);
default void setSingleAttribute(String name, String value) {
setAttribute(name, ImmutableList.of(value));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy