Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package it.inaf.oats.ia2.tapschemamanager.datalayer;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
/**
*
* @author Sonia Zorba <zorba at oats.inaf.it>
*/
public class DLUtil {
public static <T extends TapSchemaEntity> T getEntityByName(List<T> entities, String name) {
for (T entity : entities) {
if (entity.getName().equals(name)) {
return entity;
}
}
return null;
}
public static <T extends TapSchemaEntity> List<String> getEntitiesNames(List<T> entities) {
List<String> entitiesNames = new ArrayList<String>();
for (T entity : entities) {
entitiesNames.add(entity.getName());
}
return entitiesNames;
}
protected static <T extends TapSchemaEntity> void insertEntityInOrder(List<T> entities, T newEntity) {
int i = 0;
for (T entity : entities) {
if (entity.getName().compareTo(newEntity.getName()) > 0) {
break;
}
i++;
}
entities.add(i, newEntity);
}
protected static <T extends TapSchemaEntity> void removeEntity(List<T> entities, String entityName) {
Iterator<T> iterator = entities.iterator();
while (iterator.hasNext()) {
T entity = iterator.next();
if (entity.getName().equals(entityName)) {
iterator.remove();
return;
}
}
}
}