org.tiogasolutions.notify.pub.domain.DomainSummary Maven / Gradle / Ivy
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();
}
}