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