package de.retest.recheck;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import de.retest.recheck.ignore.CompoundFilter;
import de.retest.recheck.ignore.Filter;
import de.retest.recheck.ignore.RecheckIgnoreUtil;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

@AllArgsConstructor( access = AccessLevel.PRIVATE )
@Getter
public class RecheckOptions {

	private final FileNamerStrategy fileNamerStrategy;
	private final String suiteName;
	private final boolean reportUploadEnabled;
	private final Filter filter;

	public static RecheckOptionsBuilder builder() {
		return new RecheckOptionsBuilder();
	}

	public static class RecheckOptionsBuilder {
		private FileNamerStrategy fileNamerStrategy = new MavenConformFileNamerStrategy();
		private String suiteName = fileNamerStrategy.getTestClassName();
		private boolean reportUploadEnabled = false;
		private Filter filter = null;
		private final List<Filter> filterToAdd = new ArrayList<>();

		private RecheckOptionsBuilder() {}

		public RecheckOptionsBuilder fileNamerStrategy( final FileNamerStrategy fileNamerStrategy ) {
			this.fileNamerStrategy = fileNamerStrategy;
			suiteName = fileNamerStrategy.getTestClassName();
			return this;
		}

		public RecheckOptionsBuilder suiteName( final String suiteName ) {
			this.suiteName = suiteName;
			return this;
		}

		public RecheckOptionsBuilder enableReportUpload() {
			reportUploadEnabled = true;
			return this;
		}

		public RecheckOptionsBuilder setFilter( final Filter filter ) {
			this.filter = filter;
			return this;
		}

		public RecheckOptionsBuilder addFilter( final Filter added ) {
			if ( filter == null ) {
				filterToAdd.add( added );
			} else {
				throw new IllegalStateException(
						"Cannot combine `setFilter()` and `add(Filter)`. Use a `CompoundFilter` to do that." );
			}
			return this;
		}

		public RecheckOptions build() {
			if ( filter == null ) {
				filterToAdd.add( RecheckIgnoreUtil.loadRecheckIgnore() );
				filterToAdd.add( RecheckIgnoreUtil.loadRecheckSuiteIgnore( getSuitePath() ) );
				filter = new CompoundFilter( filterToAdd );
			}
			return new RecheckOptions( fileNamerStrategy, suiteName, reportUploadEnabled, filter );
		}

		private File getSuitePath() {
			return fileNamerStrategy.createFileNamer( suiteName ).getFile( "" );
		}
	}
}

@@ -233,16 +233,64 @@
 reUtil;%0A
+import de.retest.recheck.persistence.FileNamer;%0A
 import l
@@ -421,16 +421,8 @@
 E )%0A
-@Getter%0A
 publ
@@ -448,16 +448,25 @@
 ions %7B%0A%0A
+%09@Getter%0A
 %09private
@@ -542,16 +542,25 @@
 teName;%0A
+%09@Getter%0A
 %09private
@@ -624,16 +624,57 @@
  filter;
+%0A%09private final List%3CFilter%3E filterToAdd;
 %0A%0A%09publi
@@ -758,16 +758,664 @@
 ();%0A%09%7D%0A%0A
+%09public String getSuiteName() %7B%0A%09%09if ( suiteName != null ) %7B%0A%09%09%09return suiteName;%0A%09%09%7D%0A%09%09return fileNamerStrategy.getTestClassName();%0A%09%7D%0A%0A%09public Filter getFilter() %7B%0A%09%09if ( filter != null ) %7B%0A%09%09%09return filter;%0A%09%09%7D%0A%09%09final ArrayList%3CFilter%3E filters = new ArrayList%3C%3E( filterToAdd );%0A%09%09filters.add( RecheckIgnoreUtil.loadRecheckIgnore() );%0A%09%09filters.add( RecheckIgnoreUtil.loadRecheckSuiteIgnore( getSuitePath() ) );%0A%09%09return new CompoundFilter( filters );%0A%09%7D%0A%0A%09private File getSuitePath() %7B%0A%09%09final FileNamer fileNamer = fileNamerStrategy.createFileNamer( getSuiteName() );%0A%09%09return fileNamer.getFile( Properties.GOLDEN_MASTER_FILE_EXTENSION );%0A%09%7D%0A%0A
 %09public 
@@ -1451,16 +1451,17 @@
 ilder %7B%0A
+%0A
 %09%09privat
@@ -1570,44 +1570,12 @@
 e = 
-fileNamerStrategy.getTestClassName()
+null
 ;%0A%09%09
@@ -1899,61 +1899,8 @@
 gy;%0A
-%09%09%09suiteName = fileNamerStrategy.getTestClassName();%0A
 %09%09%09r
@@ -2429,15 +2429,9 @@
 ion(
-%0A%09%09%09%09%09%09
+ 
 %22Can
@@ -2453,16 +2453,22 @@
 tFilter(
+Filter
 )%60 and %60
@@ -2474,52 +2474,23 @@
 %60add
-(
 Filter
-)%60. Use a %60CompoundFilter%60 to do that
+(Filter)%60
 .%22 )
@@ -2558,426 +2558,105 @@
 %0A%09%09%09
-if ( filter == null ) %7B%0A%09%09%09%09filterToAdd.add( RecheckIgnoreUtil.loadRecheckIgnore() );%0A%09%09%09%09filterToAdd.add( RecheckIgnoreUtil.loadRecheckSuiteIgnore( getSuitePath() ) );%0A%09%09%09%09filter = new CompoundFilter( filterToAdd );%0A%09%09%09%7D%0A%09%09%09return new RecheckOptions( fileNamerStrategy, suiteName, reportUploadEnabled, filter );%0A%09%09%7D%0A%0A%09%09private File getSuitePath() %7B%0A%09%09%09return fileNamerStrategy.createFileNamer( suiteName ).getFile( %22%22
+return new RecheckOptions( fileNamerStrategy, suiteName, reportUploadEnabled, filter, filterToAdd
  );%0A

Move logic inside actual options