2 * ============LICENSE_START=======================================================
3 * Copyright (C) 2018 Ericsson. All rights reserved.
4 * Modifications Copyright (C) 2019 Nordix Foundation.
5 * ================================================================================
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
18 * SPDX-License-Identifier: Apache-2.0
19 * ============LICENSE_END=========================================================
22 package org.onap.policy.apex.testsuites.integration.context.lock.modifier;
24 import org.onap.policy.apex.context.ContextRuntimeException;
27 * The Enum LockType defines the type of lock on a test context album.
29 public enum LockType {
33 public AlbumModifier getAlbumModifier() {
34 return NO_LOCK_MODIFER;
39 public AlbumModifier getAlbumModifier() {
40 return READ_LOCK_MODIFER;
45 public AlbumModifier getAlbumModifier() {
46 return WRITE_LOCK_MODIFER;
49 WRITE_LOCK_SINGLE_VALUE_UPDATE(3) {
51 public AlbumModifier getAlbumModifier() {
52 return WRITE_LOCK_SINGLE_VALUE_MODIFER;
56 private static final AlbumModifier NO_LOCK_MODIFER = new NoLockAlbumModifier();
57 private static final AlbumModifier READ_LOCK_MODIFER = new ReadLockAlbumModifier();
58 private static final AlbumModifier WRITE_LOCK_MODIFER = new WriteLockAlbumModifier();
59 private static final AlbumModifier WRITE_LOCK_SINGLE_VALUE_MODIFER = new SingleValueWriteLockAlbumModifier();
61 private final int value;
64 * Instantiates a new lock type.
66 * @param value the value
68 LockType(final int value) {
77 public int getValue() {
82 * Get the lock type given an int value.
83 * @param value the value of lock type
84 * @return the lock type
86 public static LockType getLockType(final int value) {
87 for (final LockType lockType : LockType.values()) {
88 if (lockType.getValue() == value) {
92 throw new ContextRuntimeException("Invalid Lock type value: " + value);
96 * Gets the album modifier.
98 * @return the album modifier
100 public abstract AlbumModifier getAlbumModifier();