class CommonUtils {

	public static Object filterMatchingCollectionElements(Object obj, String pattern, boolean retainInsteadOfFilter) {
		JsonElement jsonElement = new GsonBuilder().create().toJsonTree(obj);

		boolean exact=false;

		if (!Strings.isNullOrEmpty(pattern) && pattern.startsWith("\"")&&pattern.endsWith("\"")) {
			//If the user enters search term enclosed in double quotes,
			//we take that as an 'exact' search rather than a 'like' search
				exact=true;
				//Strip off the quotes now. We will use the search term within.
				pattern = pattern.substring(1,Math.max(1,pattern.length()-1));
		}

		doRecursiveJsonMatch(jsonElement, pattern, retainInsteadOfFilter,exact);

		obj = new GsonBuilder().create().fromJson(jsonElement, Object.class);

		return obj;

	}

	private  CommonUtils();

}