public static void addField(IMutableSearch search, Field field) { List<Field> fields = search.getFields(); if (fields == null) { fields = new ArrayList<Field>(); search.setFields(fields); } fields.add(field); }
/** * Modify the search by adding the given fields after the current fields in * the search. */ public static void mergeFieldsAfter(IMutableSearch search, List<Field> fields) { List<Field> list = search.getFields(); if (list == null) { list = new ArrayList<Field>(); search.setFields(list); } list.addAll(fields); }
/** * Modify the search by adding the given fields before the current fields in * the search. */ public static void mergeFieldsBefore(IMutableSearch search, List<Field> fields) { List<Field> list = search.getFields(); if (list == null) { list = new ArrayList<Field>(); search.setFields(list); } list.addAll(0, fields); }
/** * Copy the contents of the source search object to the destination search * object, overriding any contents previously found in the destination. All * collections are copied into new collections, but the items in those * collections are not duplicated; they still point to the same objects. */ public static <T extends IMutableSearch> T copy(ISearch source, T destination) { shallowCopy(source, destination); ArrayList<String> fetches = new ArrayList<String>(); fetches.addAll(source.getFetches()); destination.setFetches(fetches); ArrayList<Field> fields = new ArrayList<Field>(); fields.addAll(source.getFields()); destination.setFields(fields); ArrayList<Filter> filters = new ArrayList<Filter>(); filters.addAll(source.getFilters()); destination.setFilters(filters); ArrayList<Sort> sorts = new ArrayList<Sort>(); sorts.addAll(source.getSorts()); destination.setSorts(sorts); return destination; }
/** * Copy the contents of the source search object to the destination search * object, overriding any contents previously found in the destination. All * destination properties reference the same objects from the source * properties. */ public static IMutableSearch shallowCopy(ISearch source, IMutableSearch destination) { destination.setSearchClass(source.getSearchClass()); destination.setDistinct(source.isDistinct()); destination.setDisjunction(source.isDisjunction()); destination.setResultMode(source.getResultMode()); destination.setFirstResult(source.getFirstResult()); destination.setPage(source.getPage()); destination.setMaxResults(source.getMaxResults()); destination.setFetches(source.getFetches()); destination.setFields(source.getFields()); destination.setFilters(source.getFilters()); destination.setSorts(source.getSorts()); return destination; }