001/* 002 * This library is part of OpenCms - 003 * The Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (https://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software GmbH & Co. KG, please see the 018 * company website: https://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: https://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.loader.imagecache; 029 030import java.util.Collections; 031import java.util.EnumSet; 032import java.util.Set; 033 034/** 035 * Describes the maintenance operations supported by an image cache backend.<p> 036 */ 037public final class CmsImageCacheCapabilities { 038 039 /** Individual backend capabilities. */ 040 public enum Capability { 041 042 /** All cache entries can be listed. */ 043 LIST_ENTRIES, 044 045 /** Listed entries contain a last-modified timestamp. */ 046 ENTRY_TIMESTAMPS, 047 048 /** Individual entries can be deleted. */ 049 DELETE_ENTRIES, 050 051 /** The complete cache can be cleared. */ 052 CLEAR, 053 054 /** Individual entries can be renewed without regenerating their content. */ 055 RENEW_ENTRIES 056 } 057 058 /** The supported capabilities. */ 059 private final Set<Capability> m_capabilities; 060 061 /** 062 * Creates a capability set.<p> 063 * 064 * @param capabilities the supported capabilities 065 */ 066 private CmsImageCacheCapabilities(EnumSet<Capability> capabilities) { 067 068 m_capabilities = Collections.unmodifiableSet(EnumSet.copyOf(capabilities)); 069 } 070 071 /** 072 * Creates a capability set.<p> 073 * 074 * @param capabilities the supported capabilities 075 * @return the capability set 076 */ 077 public static CmsImageCacheCapabilities of(Capability... capabilities) { 078 079 EnumSet<Capability> values = EnumSet.noneOf(Capability.class); 080 Collections.addAll(values, capabilities); 081 return new CmsImageCacheCapabilities(values); 082 } 083 084 /** 085 * Returns the supported capabilities.<p> 086 * 087 * @return the supported capabilities 088 */ 089 public Set<Capability> asSet() { 090 091 return m_capabilities; 092 } 093 094 /** 095 * Checks whether a capability is supported.<p> 096 * 097 * @param capability the capability 098 * @return whether the capability is supported 099 */ 100 public boolean supports(Capability capability) { 101 102 return m_capabilities.contains(capability); 103 } 104}