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

org.tiogasolutions.notify.pub.domain.DomainSummary Maven / Gradle / Ivy

There is a newer version: 5.1.4
Show newest version
package org.tiogasolutions.notify.pub.domain;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.tiogasolutions.notify.pub.common.TopicInfo;
import org.tiogasolutions.notify.pub.common.TraitInfo;

import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

/**
 * Created by harlan on 5/22/15.
 */
public class DomainSummary {
  private final List topics;
  private final List traits;

  @JsonCreator
  public DomainSummary(@JsonProperty("topics") List topics,
                       @JsonProperty("traits") List traits) {
    this.topics = topics;
    this.traits = traits;
  }

  public List getTopics() {
    return topics;
  }

  public List getTraits() {
    return traits;
  }

  public Optional findTopicInfo(String topicName) {

    TopicInfo found = null;
    for(TopicInfo info : topics) {
      if (info.getName().equalsIgnoreCase(topicName)) {
        found = info;
      }
    }

    return topics.stream()
        .filter(t -> t.getName().equalsIgnoreCase(topicName))
        .findFirst();
  }

  public Optional findTraitInfo(String traitKey) {
    return traits.stream()
        .filter(t -> t.getKey().equalsIgnoreCase(traitKey))
        .findFirst();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy