All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.phasetwo.service.model.WithAttributes Maven / Gradle / Ivy

There is a newer version: 0.79
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy