View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.apt.annotation;
21  
22  public enum DynamicExpression {
23  
24    VALUE_EXPRESSION(false, true, false),
25    VALUE_EXPRESSION_REQUIRED(true, true, false),
26    METHOD_EXPRESSION(false, false, true),
27    METHOD_EXPRESSION_REQUIRED(true, false, true),
28    PROHIBITED(false, false, false);
29  
30    private final boolean required;
31    private final boolean valueExpression;
32    private final boolean methodExpression;
33  
34    DynamicExpression(final boolean required, final boolean valueExpression, final boolean methodExpression) {
35      this.required = required;
36      this.valueExpression = valueExpression;
37      this.methodExpression = methodExpression;
38    }
39  
40    public boolean isRequired() {
41      return required;
42    }
43  
44    public boolean isValueExpression() {
45      return valueExpression;
46    }
47  
48    public boolean isMethodExpression() {
49      return methodExpression;
50    }
51  
52    public String toMetaDataString() {
53      switch (this) {
54        case VALUE_EXPRESSION:
55          return "ALLOWED";
56        case METHOD_EXPRESSION:
57          return "ALLOWED";
58        case VALUE_EXPRESSION_REQUIRED:
59          return "REQUIRED";
60        case METHOD_EXPRESSION_REQUIRED:
61          return "REQUIRED";
62        case PROHIBITED:
63          return "PROHIBITED";
64        default:
65          throw new IllegalStateException("Unexpected DynamicExpression " + name());
66      }
67    }
68  
69    public String toString() {
70      switch (this) {
71        case VALUE_EXPRESSION:
72          return "VB";
73        case VALUE_EXPRESSION_REQUIRED:
74          return "VB";
75        case METHOD_EXPRESSION:
76          return "MB";
77        case METHOD_EXPRESSION_REQUIRED:
78          return "MB";
79        case PROHIBITED:
80          return "NONE";
81        default:
82          throw new IllegalStateException("Unexpected DynamicExpression " + name());
83      }
84    }
85  }