BUG-2218: Keep existing link augmentations during discovery process
[controller.git] / opendaylight / adsal / hosttracker_new / implementation / src / main / java / org / opendaylight / controller / hosttracker / internal / DeviceIndexInterator.java
1 /*
2  * Copyright (c) 2012 Big Switch Networks, Inc.
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the
5  * "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/legal/epl-v10.html
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13  * implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  *
16  * This file incorporates work covered by the following copyright and
17  * permission notice:
18  *
19  *    Originally created by David Erickson, Stanford University
20  *
21  *    Licensed under the Apache License, Version 2.0 (the "License");
22  *    you may not use this file except in compliance with the
23  *    License. You may obtain a copy of the License at
24  *
25  *         http://www.apache.org/licenses/LICENSE-2.0
26  *
27  *    Unless required by applicable law or agreed to in writing,
28  *    software distributed under the License is distributed on an "AS
29  *    IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
30  *    express or implied. See the License for the specific language
31  *    governing permissions and limitations under the License.
32  */
33
34 package org.opendaylight.controller.hosttracker.internal;
35
36 import java.util.Iterator;
37
38 /**
39  * An iterator for handling device index queries
40  */
41 public class DeviceIndexInterator implements Iterator<Device> {
42     private DeviceManagerImpl deviceManager;
43     private Iterator<Long> subIterator;
44
45     /**
46      * Construct a new device index iterator referring to a device manager
47      * instance and an iterator over device keys
48      *
49      * @param deviceManager
50      *            the device manager
51      * @param subIterator
52      *            an iterator over device keys
53      */
54     public DeviceIndexInterator(DeviceManagerImpl deviceManager,
55             Iterator<Long> subIterator) {
56         super();
57         this.deviceManager = deviceManager;
58         this.subIterator = subIterator;
59     }
60
61     @Override
62     public boolean hasNext() {
63         return subIterator.hasNext();
64     }
65
66     @Override
67     public Device next() {
68         Long next = subIterator.next();
69         return deviceManager.deviceMap.get(next);
70     }
71
72     @Override
73     public void remove() {
74         subIterator.remove();
75     }
76
77 }