001package org.biopax.paxtools.pattern.constraint; 002 003import org.biopax.paxtools.model.level3.PhysicalEntity; 004import org.biopax.paxtools.pattern.Match; 005 006/** 007 * Checks if the PhysicalEntity controls anything. 008 * 009 * @author Ozgun Babur 010 */ 011public class ActivityConstraint extends ConstraintAdapter 012{ 013 /** 014 * Desired activity. 015 */ 016 boolean active; 017 018 /** 019 * Constructor with the desired activity. 020 * @param active desires activity 021 */ 022 public ActivityConstraint(boolean active) 023 { 024 super(1); 025 this.active = active; 026 } 027 028 /** 029 * Checks if the PhysicalEntity controls anything. 030 * @param match current match to validate 031 * @param ind mapped index 032 * @return true if it controls anything 033 */ 034 @Override 035 public boolean satisfies(Match match, int... ind) 036 { 037 PhysicalEntity pe = (PhysicalEntity) match.get(ind[0]); 038 039 return pe.getControllerOf().isEmpty() == active; 040 } 041}