package sizebay.catalog.client.model;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;

import java.lang.reflect.Field;
import java.util.StringJoiner;

@Getter
@Setter
@AllArgsConstructor
public class ProductFilter {

	private String page;
	private String name;
	private String permalink;
	private String ageGroup;
	private String gender;
	private String productId;
	private String feedProductId;
	private String brandId;
	private String brandName;
	private String categoryId;
	private String categoryName;
	private String modelingId;
	private String modelingName;
	private String strongBrandId;
	private String strongBrandName;
	private String strongTypeId;
	private String strongTypeName;
	private String strongCategoryId;
	private String strongCategoryName;
	private String strongSubcategoryId;
	private String strongSubcategoryName;
	private String strongModelId;
	private String strongModelName;
	private String onlyShoe;
	private String productsThatShouldBeFixed;
	private String productsAvailable;
	private String productsUnavailable;

	public String createQuery() {
		StringJoiner query = new StringJoiner("&");

		Field[] fields = this.getClass().getDeclaredFields();

		for(Field field : fields) {
			try {
				if(field.get(this) != null) {
					String parameter = field.getName() + "=" + field.get(this);
					query.add(parameter);
				}
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}

		return query.toString();
	}

}

@@ -29,16 +29,24 @@
 nt.model
+.filters
 ;%0A%0Aimpor
@@ -123,72 +123,8 @@
 r;%0A%0A
-import java.lang.reflect.Field;%0Aimport java.util.StringJoiner;%0A%0A
 @Get
@@ -182,16 +182,31 @@
 tFilter 
+extends Filter 
 %7B%0A%0A%09priv
@@ -222,16 +222,36 @@
 g page;%0A
+%09private String id;%0A
 %09private
@@ -345,35 +345,8 @@
 er;%0A
-%09private String productId;%0A
 %09pri
@@ -900,16 +900,17 @@
 onlyShoe
+s
 ;%0A%09priva
@@ -1023,418 +1023,6 @@
 e;%0A%0A
-%09public String createQuery() %7B%0A%09%09StringJoiner query = new StringJoiner(%22&%22);%0A%0A%09%09Field%5B%5D fields = this.getClass().getDeclaredFields();%0A%0A%09%09for(Field field : fields) %7B%0A%09%09%09try %7B%0A%09%09%09%09if(field.get(this) != null) %7B%0A%09%09%09%09%09String parameter = field.getName() + %22=%22 + field.get(this);%0A%09%09%09%09%09query.add(parameter);%0A%09%09%09%09%7D%0A%09%09%09%7D catch (IllegalAccessException e) %7B%0A%09%09%09%09e.printStackTrace();%0A%09%09%09%7D%0A%09%09%7D%0A%0A%09%09return query.toString();%0A%09%7D%0A%0A
 %7D%0A

rename productId to id and onlyShoe to onlyShoes