001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://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: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://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.workplace.tools.accounts; 029 030import org.opencms.main.CmsIllegalArgumentException; 031 032import java.util.Arrays; 033import java.util.Collections; 034import java.util.Iterator; 035import java.util.List; 036 037/** 038 * Wrapper class for 039 * the different types of icon actions the dependency lists.<p> 040 * 041 * The possibles values are:<br> 042 * <ul> 043 * <li>{@link #RESOURCE}</li> 044 * <li>{@link #GROUP}</li> 045 * <li>{@link #USER}</li> 046 * </ul> 047 * <p> 048 * 049 * @since 6.0.0 050 */ 051public final class CmsDependencyIconActionType { 052 053 /** Constant for the resource icon action. */ 054 public static final CmsDependencyIconActionType RESOURCE = new CmsDependencyIconActionType("r"); 055 056 /** Constant for the group icon action. */ 057 public static final CmsDependencyIconActionType GROUP = new CmsDependencyIconActionType("g"); 058 059 /** Constant for the user icon action. */ 060 public static final CmsDependencyIconActionType USER = new CmsDependencyIconActionType("u"); 061 062 /** Array constant for all available align types. */ 063 private static final CmsDependencyIconActionType[] VALUE_ARRAY = {RESOURCE, GROUP, USER}; 064 065 /** List of mode constants. */ 066 public static final List<CmsDependencyIconActionType> VALUES = Collections.unmodifiableList( 067 Arrays.asList(VALUE_ARRAY)); 068 069 /** Internal representation. */ 070 private final String m_mode; 071 072 /** 073 * Private constructor.<p> 074 * 075 * @param mode the view mode 076 */ 077 private CmsDependencyIconActionType(String mode) { 078 079 m_mode = mode; 080 } 081 082 /** 083 * Parses an string into an element of this enumeration.<p> 084 * 085 * @param value the id to parse 086 * 087 * @return the enumeration element 088 * 089 * @throws CmsIllegalArgumentException if the given value could not be matched against a 090 * <code>{@link CmsDependencyIconActionType}</code> type. 091 */ 092 public static CmsDependencyIconActionType valueOf(String value) throws CmsIllegalArgumentException { 093 094 Iterator<CmsDependencyIconActionType> iter = VALUES.iterator(); 095 while (iter.hasNext()) { 096 CmsDependencyIconActionType target = iter.next(); 097 if (value.equals(target.getId())) { 098 return target; 099 } 100 } 101 throw new CmsIllegalArgumentException( 102 org.opencms.db.Messages.get().container( 103 org.opencms.db.Messages.ERR_MODE_ENUM_PARSE_2, 104 value, 105 CmsDependencyIconActionType.class.getName())); 106 } 107 108 /** 109 * Returns the id string.<p> 110 * 111 * @return the id string 112 */ 113 public String getId() { 114 115 return m_mode; 116 } 117 118 /** 119 * @see java.lang.Object#toString() 120 */ 121 @Override 122 public String toString() { 123 124 return m_mode; 125 } 126}