Commit 843d1e75 authored by Viacheslav Pavlov's avatar Viacheslav Pavlov Committed by Matija Obreza

Added method for clearing one of Filter fields

parent b5f664b8
......@@ -92,6 +92,28 @@ public abstract class BasicModelFilter<T extends BasicModelFilter<T, R>, R exten
}
}
public void clearFilter(String jsonPath) throws NoSuchFieldException, IllegalAccessException {
String[] paths = jsonPath.split("\\.");
Object toClear = this;
Class<?> clazz = this.getClass();
Field field = clazz.getField(paths[0]);
for (int i = 1; i < paths.length; i++) {
clazz = field.getType();
if (!BasicModelFilter.class.isAssignableFrom(clazz))
break;
toClear = field.get(toClear);
if (toClear == null)
return;
field = clazz.getField(paths[i]);
}
field.set(toClear, null);
}
// @Override
// public int hashCode() {
// String str = toString();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment