io.symcpe.wraith.rules.Rule Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wraith-engine Show documentation
Show all versions of wraith-engine Show documentation
An efficient event correlation library
/**
* Copyright 2016 Symantec Corporation.
*
* Licensed under the Apache License, Version 2.0 (the “License”);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.symcpe.wraith.rules;
import java.io.Serializable;
import java.util.List;
import io.symcpe.wraith.actions.Action;
import io.symcpe.wraith.conditions.Condition;
/**
* Abstract definition of a rule.
*
* 1 rule is composed for:
*
* - rule id that uniquely identifies a rule
* - rule name
* - 1 {@link Condition}
* - List of {@link Action}s
*
*
* @author ambud_sharma
*
*/
public abstract class Rule implements Serializable {
private static final long serialVersionUID = 1L;
private short ruleId;
private String name;
private boolean active;
private String description;
public Rule(short ruleId, String name, boolean active) {
this.ruleId = ruleId;
this.name = name;
this.active = active;
}
/**
* Getter for condition
* @return condition
*/
public abstract Condition getCondition();
/**
* Setter for condition
* @param condition
*/
public abstract void setCondition(Condition condition);
/**
* Getter for actions
* @return actions
*/
public abstract List getActions();
/**
* Setter for actions
* @param actions
*/
public abstract void setActions(List actions);
/**
* Getter for ruleId
* @return ruleId
*/
public short getRuleId() {
return ruleId;
}
/**
* Getter for rule name
* @return name
*/
public String getName() {
return name;
}
@Override
public boolean equals(Object obj) {
if(obj instanceof Rule) {
return this.getRuleId() == ((Rule) obj).getRuleId();
}else{
return false;
}
}
@Override
public int hashCode() {
return ruleId;
}
/**
* @return true if rule is active
*/
public boolean isActive() {
return active;
}
/**
* @param ruleId the ruleId to set
*/
public void setRuleId(short ruleId) {
this.ruleId = ruleId;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* @param active the active to set
*/
public void setActive(boolean active) {
this.active = active;
}
/**
* @return the description
*/
public String getDescription() {
return description;
}
/**
* @param description the description to set
*/
public void setDescription(String description) {
this.description = description;
}
}