summaryrefslogtreecommitdiffstats
path: root/catalog-model/src/main/java/org/openecomp/sdc/be/model/operations/api/TypeOperations.java
blob: d858153348676824cdbc502aaf7b1ce0ea0e5e6d (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
package org.openecomp.sdc.be.model.operations.api;

import fj.data.Either;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;

import javax.validation.constraints.NotNull;

public interface TypeOperations<T extends ToscaDataDefinition> {

    T addType(T newTypeDefinition);

    T getType(String uniqueId);

    T getLatestType(String uniqueId);

    boolean isSameType(@NotNull T type1,@NotNull T type2);

    T updateType(T currentTypeDefinition, T newTypeDefinition);
    
    static <T> Either<T, StorageOperationStatus> mapOkStatus(StorageOperationStatus status, T obj) {
        return status != StorageOperationStatus.OK? Either.right(status) : Either.left(obj);
    }

}