package loc.filter.filters.Aggregate;

import loc.FilterFactory;
import loc.filter.FilterSerializer;

import java.io.IOException;
import java.nio.file.Path;

public class Not implements Filter {
    public static final char prefix = '!';
	public final Filter filter;


	public static class Serializer implements FilterSerializer {
		@Override
		public FilterNot parse(String string) throws Exception {
			String filterString = new loc.Parser(string).skipSpaces().skipChar(prefix).readToTheEnd();
			return new FilterNot(FilterFactory.create(filterString));
		}

		@Override
		public String serialize() throws Exception {
			return null;
		}
	}

	@Override
	public FilterSerializer getSerializer() {
		return new Serializer();
	}

	public Not(Filter filter) {
		this.filter = filter;
	}

	@Override
	public boolean check(Path file) throws IOException {
		return !filter.check(file);
	}

    @Override
    public int hashCode() {
        return filter != null ? ~filter.hashCode() : 0;
    }

	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
		if (o == null || getClass() != o.getClass()) return false;

		FilterNot filterNot = (FilterNot) o;

		return filter != null ? filter.equals(filterNot.filter) : filterNot.filter == null;
	}

	@Override
	public String toString() {
		return prefix + filter.toString();
	}

	@Override
	public char getPrefix() {
		return prefix;
	}
}

@@ -43,16 +43,23 @@
 ort loc.
+filter.
 FilterFa
@@ -100,16 +100,42 @@
 ializer;
+%0Aimport loc.filter.Filter;
 %0A%0Aimport
@@ -378,22 +378,16 @@
 %09public 
-Filter
 Not pars
@@ -530,22 +530,16 @@
 urn new 
-Filter
 Not(Filt
@@ -614,16 +614,29 @@
 rialize(
+Filter filter
 ) throws
@@ -655,19 +655,123 @@
 %0A%09%09%09
-return null
+Filter subFilter = Not.class.cast(filter).filter;%0A%09%09%09return prefix + subFilter.getSerializer().serialize(subFilter)
 ;%0A%09%09
@@ -1266,37 +1266,19 @@
 %0A%0A%09%09
-FilterNot filterNot = (Filter
+Not not = (
 Not)
@@ -1322,23 +1322,17 @@
 .equals(
-filterN
+n
 ot.filte
@@ -1340,15 +1340,9 @@
 ) : 
-filterN
+n
 ot.f

Rename FilterNot to Not Implement serialize() in Not.Serializer