Unit/SONAR/Checkstyle in ONAP-REST
[policy/engine.git] / ONAP-REST / src / main / java / org / onap / policy / rest / util / PolicyContainer.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP Policy Engine
4  * ================================================================================
5  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Modifications Copyright (C) 2019 Nordix Foundation.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.onap.policy.rest.util;
23
24 import java.io.Serializable;
25 import java.util.Collection;
26 import java.util.List;
27
28 public interface PolicyContainer extends Serializable {
29
30     public Collection<?> getContainerPropertyIds();
31
32     public Collection<?> getItemIds();
33
34     public Class<?> getType(Object propertyId);
35
36     public int size();
37
38     public boolean containsId(Object itemId);
39
40     public Object addItem();
41
42     public boolean removeItem(Object itemId);
43
44     public boolean addContainerProperty(Object propertyId, Class<?> type, Object defaultValue);
45
46     public boolean removeContainerProperty(Object propertyId);
47
48     public boolean removeAllItems();
49
50     public interface Ordered extends PolicyContainer {
51
52         public Object nextItemId(Object itemId);
53
54         public Object prevItemId(Object itemId);
55
56         public Object firstItemId();
57
58         public Object lastItemId();
59
60         public boolean isFirstId(Object itemId);
61
62         public boolean isLastId(Object itemId);
63
64         public Object addItemAfter(Object previousItemId);
65
66     }
67
68     public interface Indexed extends Ordered {
69
70         public int indexOfId(Object itemId);
71
72         public Object getIdByIndex(int index);
73
74         public List<?> getItemIds(int startIndex, int numberOfItems);
75
76         public Object addItemAt(int index);
77
78         public interface ItemAddEvent extends ItemSetChangeEvent {
79
80             public Object getFirstItemId();
81
82             public int getFirstIndex();
83
84             public int getAddedItemsCount();
85         }
86
87         public interface ItemRemoveEvent extends ItemSetChangeEvent {
88
89             public Object getFirstItemId();
90
91             public int getFirstIndex();
92
93             public int getRemovedItemsCount();
94         }
95     }
96
97     @FunctionalInterface
98     public interface ItemSetChangeEvent {
99         public PolicyContainer getContainer();
100     }
101
102     @FunctionalInterface
103     public interface ItemSetChangeListener {
104         public void containerItemSetChange(PolicyContainer.ItemSetChangeEvent event);
105     }
106
107     public interface ItemSetChangeNotifier extends Serializable {
108
109         public void addItemSetChangeListener(PolicyContainer.ItemSetChangeListener listener);
110
111         public void removeItemSetChangeListener(PolicyContainer.ItemSetChangeListener listener);
112     }
113 }