aboutsummaryrefslogtreecommitdiffstats
path: root/catalog-dao/src/main/java/org/openecomp/sdc/be/dao/titan/TitanUtils.java
blob: 163ef807fbed4448ebade214951c9e3a3e41c8fb (plain)
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
package org.openecomp.sdc.be.dao.titan;

import com.thinkaurelius.titan.graphdb.query.TitanPredicate;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;

import static com.thinkaurelius.titan.core.attribute.Contain.NOT_IN;
import static java.util.Collections.emptyMap;
import static org.apache.commons.collections.CollectionUtils.isEmpty;

public class TitanUtils {

    private TitanUtils() {
    }

    public static <T> Map<String, Entry<TitanPredicate, Object>> buildNotInPredicate(String propKey, Collection<T> notInCollection) {
        if (isEmpty(notInCollection)) {
            return emptyMap();
        }
        Map<String, Entry<TitanPredicate,  Object>> predicateCriteria = new HashMap<>();
        predicateCriteria.put(propKey, new HashMap.SimpleEntry<>(NOT_IN, notInCollection));
        return predicateCriteria;
    }
}