001package daikon.inv.filter; 002 003// The template for an invariant filter. 004// Groups of invariant filters are managed by InvariantFilters. 005import daikon.inv.Invariant; 006 007public abstract class InvariantFilter { 008 boolean isOn; 009 010 protected InvariantFilter(boolean isOn) { 011 this.isOn = isOn; 012 } 013 014 // TODO: This is a hack. Should add constructors that take a boolean 015 // for every subclass. 016 protected InvariantFilter() { 017 this(true); 018 } 019 020 public abstract String getDescription(); 021 022 public void turnOn() { 023 isOn = true; 024 } 025 026 public void turnOff() { 027 isOn = false; 028 } 029 030 public boolean getSetting() { 031 return isOn; 032 } 033 034 public boolean shouldDiscard(Invariant invariant) { 035 if (!isOn) { 036 return false; 037 } else { 038 return shouldDiscardInvariant(invariant); 039 } 040 } 041 042 abstract boolean shouldDiscardInvariant(Invariant invariant); 043}