001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.wicket.authorization;
018:
019: import org.apache.wicket.util.lang.EnumeratedType;
020: import org.apache.wicket.util.string.Strings;
021:
022: /**
023: * A class for constructing singleton constants that represent a given component
024: * action that needs to be authorized. The Wicket core framework defines
025: * Component.RENDER and Component.ENABLE actions, but future versions of the
026: * framework may add more actions and user defined components can define their
027: * own actions as well.
028: *
029: * @see org.apache.wicket.Component#RENDER
030: * @see org.apache.wicket.Component#ENABLE
031: *
032: * @author Eelco Hillenius
033: * @author Jonathan Locke
034: * @since 1.2
035: */
036: public class Action extends EnumeratedType {
037: /**
038: * RENDER action name (for consistent name and use in annotations).
039: * <p>
040: * DO NOT use for equals on Action, like
041: *
042: * <pre>
043: * action.equals(Action.RENDER)
044: * </pre>
045: *
046: * as you'll compare an action with a string. Rather, do:
047: *
048: * <pre>
049: * action.equals(Component.RENDER)
050: * </pre>
051: *
052: * </p>
053: */
054: public static final String RENDER = "RENDER";
055:
056: /**
057: * ENABLE action name (for consistent name and use in annotations).
058: * <p>
059: * DO NOT use for equals on Action, like
060: *
061: * <pre>
062: * action.equals(Action.ENABLE)
063: * </pre>
064: *
065: * as you'll compare an action with a string. Rather, do:
066: *
067: * <pre>
068: * action.equals(Component.ENABLE)
069: * </pre>
070: *
071: * </p>
072: */
073: public static final String ENABLE = "ENABLE";
074:
075: private static final long serialVersionUID = -1L;
076:
077: /** The name of this action. */
078: private final String name;
079:
080: /**
081: * Construct.
082: *
083: * @param name
084: * The name of this action for debug purposes
085: */
086: public Action(final String name) {
087: super (name);
088: if (Strings.isEmpty(name)) {
089: throw new IllegalArgumentException(
090: "Name argument may not be null, whitespace or the empty string");
091: }
092:
093: this .name = name;
094: }
095:
096: /**
097: * @return The name of this action
098: */
099: public String getName() {
100: return name;
101: }
102: }
|