Make sure invokeOperation is set once
[controller.git] / opendaylight / adsal / northbound / commons / src / main / java / org / opendaylight / controller / northbound / commons / query / Query.java
1 /**
2  * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.northbound.commons.query;
9
10 import java.util.Collection;
11 import java.util.List;
12
13
14 /**
15  * Represents a parsed query used in filtering of collections.
16  */
17 public interface Query<T> {
18
19     /**
20      * Find items in the given collection and return them as a new list. The
21      * original collection is not changed.
22      *
23      * @param collection to search in.
24      * @return list of items which match the query.
25      * @throws QueryException
26      */
27     public List<T> find(Collection<T> collection) throws QueryException;
28
29     /**
30      * Apply the query on the given collection. Note that this method will modify
31      * the given object by removing any items which don't match the query criteria.
32      * If the collection is 'singleton' or unmodifiable, invocation will result in
33      * an exception.
34      *
35      * @param collection
36      * @return the number matched items
37      * @throws QueryException
38      */
39     public int filter(Collection<T> collection) throws QueryException;
40
41     /**
42      * Search the given root for a child collection and them apply the query on.
43      * Note that this method will modify the given object by removing any items
44      * which don't match the query criteria.
45      *
46      * @param root - top level object to search in
47      * @param childType - the child type which represents the collection.
48      * @return the number of matched items
49      * @throws QueryException
50      */
51     public int filter(T root, Class<?> childType) throws QueryException;
52 }