001/* 002 * The contents of this file are subject to the license and copyright 003 * detailed in the LICENSE and NOTICE files at the root of the source 004 * tree. 005 */ 006package org.fcrepo.kernel.api.lock; 007 008/** 009 * Enum for the different types of locks you can acquire on a resource. 010 * @author whikloj 011 * @since 6.3.1 012 */ 013public enum ResourceLockType { 014 015 EXCLUSIVE("exclusive"), 016 NONEXCLUSIVE("non-exclusive"); 017 018 private final String value; 019 020 ResourceLockType(final String value) { 021 this.value = value; 022 } 023 024 public String getValue() { 025 return value; 026 } 027 028 /** 029 * To generate a new enum instance by matching on the enum's value 030 * @param value the value of the enum to create 031 * @return the ResourceLockType enum 032 */ 033 public static ResourceLockType fromString(final String value) { 034 for (final var mode : values()) { 035 if (mode.value.equalsIgnoreCase(value)) { 036 return mode; 037 } 038 } 039 throw new IllegalArgumentException("Unknown resource lock type: " + value); 040 } 041 042 @Override 043 public String toString() { 044 return value; 045 } 046}