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

io.symcpe.wraith.rules.SimpleRule Maven / Gradle / Ivy

There is a newer version: 0.0.34
Show newest version
/**
 * 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.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import io.symcpe.wraith.actions.Action;
import io.symcpe.wraith.conditions.Condition;

/**
 * A simple {@link Rule} concrete implementation
 * 
 * @author ambud_sharma
 *
 */
public class SimpleRule extends Rule {

	private static final long serialVersionUID = 1L;
	private Condition condition;
	private List actions;
	
	public SimpleRule(short ruleId, String name, boolean active, Condition condition, Action ...action) {
		super(ruleId, name, active);
		this.condition = condition;
		this.actions = new ArrayList<>(Arrays.asList(action));
	}
	
	@Override
	public Condition getCondition() {
		return condition;
	}

	/**
	 * @return the action
	 */
	@Override
	public List getActions() {
		return actions;
	}

	/**
	 * @param actions the action to set
	 */
	@Override
	public void setActions(List actions) {
		this.actions = actions;
	}

	/**
	 * @param condition the condition to set
	 */
	public void setCondition(Condition condition) {
		this.condition = condition;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof SimpleRule) {
			return ((SimpleRule)obj).getRuleId()==getRuleId();
		}
		return false;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "SimpleRule [id="+getRuleId()+", name="+getName()+", active="+isActive()+", condition=" + condition + ", action=" + actions + "]";
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy