Clean code: format, typo, new lines (very minor)
[netvirt.git] / vpnservice / aclservice / impl / src / main / java / org / opendaylight / netvirt / aclservice / AclServiceManagerImpl.java
1 /*
2  * Copyright (c) 2016 Red Hat, 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.netvirt.aclservice;
9
10 import java.util.ArrayList;
11 import java.util.List;
12
13 import org.opendaylight.netvirt.aclservice.api.AclServiceListener;
14 import org.opendaylight.netvirt.aclservice.api.AclServiceManager;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
16
17 public class AclServiceManagerImpl implements AclServiceManager {
18
19     private List<AclServiceListener> aclServiceListenerList;
20
21     /**
22      * Initialize the ACL service listener list.
23      */
24     public AclServiceManagerImpl() {
25         aclServiceListenerList = new ArrayList<>();
26     }
27
28     @Override
29     public void addAclServiceListner(AclServiceListener aclServiceListner) {
30         aclServiceListenerList.add(aclServiceListner);
31     }
32
33     @Override
34     public void removeAclServiceListner(AclServiceListener aclServiceListner) {
35         aclServiceListenerList.remove(aclServiceListner);
36     }
37
38     @Override
39     public void notify(Interface port, Action action) {
40         for (AclServiceListener aclServiceListener : aclServiceListenerList) {
41             if (action == Action.ADD) {
42                 aclServiceListener.applyAcl(port);
43             } else if (action == Action.UPDATE) {
44                 aclServiceListener.updateAcl(port);
45             } else if (action == Action.REMOVE) {
46                 aclServiceListener.removeAcl(port);
47             }
48         }
49     }
50
51 }