Merge "BUG-2218: Keep existing link augmentations during discovery process"
[controller.git] / opendaylight / adsal / hosttracker_new / implementation / src / main / java / org / opendaylight / controller / hosttracker / internal / DefaultEntityClassifier.java
1 /*
2  * Copyright (c) 2011,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.Collection;
37 import java.util.EnumSet;
38
39 import org.opendaylight.controller.hosttracker.Entity;
40 import org.opendaylight.controller.hosttracker.IDevice;
41 import org.opendaylight.controller.hosttracker.IDeviceService;
42 import org.opendaylight.controller.hosttracker.IDeviceService.DeviceField;
43 import org.opendaylight.controller.hosttracker.IEntityClass;
44 import org.opendaylight.controller.hosttracker.IEntityClassListener;
45 import org.opendaylight.controller.hosttracker.IEntityClassifierService;
46
47 /**
48  * This is a default entity classifier that simply classifies all entities into
49  * a fixed entity class, with key fields of MAC and VLAN.
50  *
51  * @author readams
52  */
53 public class DefaultEntityClassifier implements IEntityClassifierService {
54     /**
55      * A default fixed entity class
56      */
57     protected static class DefaultEntityClass implements IEntityClass {
58         String name;
59
60         public DefaultEntityClass(String name) {
61             this.name = name;
62         }
63
64         @Override
65         public EnumSet<IDeviceService.DeviceField> getKeyFields() {
66             return keyFields;
67         }
68
69         @Override
70         public String getName() {
71             return name;
72         }
73     }
74
75     protected static EnumSet<DeviceField> keyFields;
76     static {
77         keyFields = EnumSet.of(DeviceField.MAC, DeviceField.VLAN);
78     }
79     protected static DefaultEntityClass entityClass = new DefaultEntityClass(
80             "DefaultEntityClass");
81
82     @Override
83     public IEntityClass classifyEntity(Entity entity) {
84         return entityClass;
85     }
86
87     @Override
88     public IEntityClass reclassifyEntity(IDevice curDevice, Entity entity) {
89         return entityClass;
90     }
91
92     @Override
93     public void deviceUpdate(IDevice oldDevice,
94             Collection<? extends IDevice> newDevices) {
95         // no-op
96     }
97
98     @Override
99     public EnumSet<DeviceField> getKeyFields() {
100         return keyFields;
101     }
102
103     @Override
104     public void addListener(IEntityClassListener listener) {
105         // no-op
106
107     }
108 }