Fix build faliures due to OFPlugin checktyle fixes
[netvirt.git] / vpnservice / elanmanager / elanmanager-impl / src / main / java / org / opendaylight / netvirt / elan / internal / InterfaceAddWorkerOnElan.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. 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.netvirt.elan.internal;
9
10 import com.google.common.util.concurrent.ListenableFuture;
11 import java.util.ArrayList;
12 import java.util.List;
13 import java.util.concurrent.Callable;
14
15 import org.opendaylight.genius.interfacemanager.globals.InterfaceInfo;
16 import org.opendaylight.netvirt.elan.utils.ElanUtils;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
19 import org.slf4j.Logger;
20 import org.slf4j.LoggerFactory;
21
22 public class InterfaceAddWorkerOnElan implements Callable<List<ListenableFuture<Void>>> {
23
24     private static final Logger LOG = LoggerFactory.getLogger(InterfaceAddWorkerOnElan.class);
25
26     private final String key;
27     private final ElanInterface elanInterface;
28     private final ElanInstance elanInstance;
29     private final InterfaceInfo interfaceInfo;
30     private final ElanInterfaceManager dataChangeListener;
31
32     public InterfaceAddWorkerOnElan(String key, ElanInterface elanInterface, InterfaceInfo interfaceInfo,
33                                     ElanInstance elanInstance, ElanInterfaceManager dataChangeListener) {
34         this.key = key;
35         this.elanInterface = elanInterface;
36         this.interfaceInfo = interfaceInfo;
37         this.elanInstance = elanInstance;
38         this.dataChangeListener = dataChangeListener;
39     }
40
41     @Override
42     public String toString() {
43         return "InterfaceAddWorkerOnElan [key=" + key + ", elanInterface=" + elanInterface + ", elanInstance="
44             + elanInstance + ", interfaceInfo=" + interfaceInfo + "]";
45     }
46
47
48     @Override
49     @SuppressWarnings("checkstyle:IllegalCatch")
50     public List<ListenableFuture<Void>> call() throws Exception {
51         List<ListenableFuture<Void>> futures = new ArrayList<>();
52         try {
53             futures.addAll(dataChangeListener.addElanInterface(elanInterface, interfaceInfo, elanInstance));
54         } catch (RuntimeException e) {
55             LOG.error("Error while processing key {} for elan interface {} ", key, elanInterface, e);
56             ElanUtils.addToListenableFutureIfTxException(e, futures);
57         }
58         return futures;
59     }
60 }