org.graylog.plugins.pipelineprocessor.events.RulesChangedEvent Maven / Gradle / Ivy
/**
* This file is part of Graylog.
*
* Graylog is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Graylog is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Graylog. If not, see .
*/
package org.graylog.plugins.pipelineprocessor.events;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.auto.value.AutoValue;
import com.google.common.collect.Sets;
import java.util.Set;
import static java.util.Collections.emptySet;
@AutoValue
public abstract class RulesChangedEvent {
@JsonProperty
public abstract Set deletedRuleIds();
@JsonProperty
public abstract Set updatedRuleIds();
public static Builder builder() {
return new AutoValue_RulesChangedEvent.Builder().deletedRuleIds(emptySet()).updatedRuleIds(emptySet());
}
public static RulesChangedEvent updatedRuleId(String id) {
return builder().updatedRuleId(id).build();
}
public static RulesChangedEvent deletedRuleId(String id) {
return builder().deletedRuleId(id).build();
}
@JsonCreator
public static RulesChangedEvent create(@JsonProperty("deleted_rule_ids") Set deletedIds, @JsonProperty("updated_rule_ids") Set updatedIds) {
return builder().deletedRuleIds(deletedIds).updatedRuleIds(updatedIds).build();
}
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder deletedRuleIds(Set ids);
public Builder deletedRuleId(String id) {
return deletedRuleIds(Sets.newHashSet(id));
}
public abstract Builder updatedRuleIds(Set ids);
public Builder updatedRuleId(String id) {
return updatedRuleIds(Sets.newHashSet(id));
}
public abstract RulesChangedEvent build();
}
}