@Override
  public BufferedImage convert(BufferedImage source) throws FilterException {

    if (!init) {
      throw new IllegalStateException("Internal error. Called convert without init.");
    }

    if (done) {
      throw new IllegalStateException("Internal error. Called convert after done.");
    }

    logger.debug(this + " CONVERT");

    ParamTest.compareInCollections(model, parameters, true);

    return source;
  }
 public TestMyFilter() {
   parameters = new ArrayList<Param>();
   ParamTest.fillParameters(parameters);
   Collections.unmodifiableCollection(parameters);
 }
public class TestMyFilter implements IFilter, IInitiable {

  private static final Logger logger = LoggerFactory.getLogger(TestMyFilter.class);

  @Override
  protected void finalize() throws Throwable {
    if (!done) {
      System.err.println("Method 'close' does not called for " + this);
    }
  }

  private Collection<Param> model = ParamTest.fillParameters(new ArrayList<Param>());

  private Collection<Param> parameters = null;

  public TestMyFilter() {
    parameters = new ArrayList<Param>();
    ParamTest.fillParameters(parameters);
    Collections.unmodifiableCollection(parameters);
  }

  @Override
  public BufferedImage convert(BufferedImage source) throws FilterException {

    if (!init) {
      throw new IllegalStateException("Internal error. Called convert without init.");
    }

    if (done) {
      throw new IllegalStateException("Internal error. Called convert after done.");
    }

    logger.debug(this + " CONVERT");

    ParamTest.compareInCollections(model, parameters, true);

    return source;
  }

  @Override
  public String getName() {
    return "Тестовый фильтр";
  }

  @Override
  public Collection<Param> getParams() {
    return this.parameters;
  }

  private boolean init;
  private boolean done;

  public boolean isDone() {
    return done;
  }

  public boolean isInit() {
    return init;
  }

  public void close() {
    if (!init) {
      throw new IllegalStateException("Internal error. Called done without init.");
    }
    if (done) {
      throw new IllegalStateException("Internal error. Called done twice.");
    }
    this.done = true;
    logger.debug(this + " CLOSE");
  }

  public void init() {
    if (done) {
      throw new IllegalStateException("Internal error. Reusing existable object.");
    }
    if (init) {
      throw new IllegalStateException("Internal error. Called done twice.");
    }
    init = true;
    logger.debug(this + " INIT");
  }
}