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 */ 017package org.apache.juneau.commons.lang; 018 019/** 020 * Enumeration of state machine states for use in parsing operations. 021 * 022 * <p> 023 * This enum provides a standardized set of state constants (S1 through S50) that can be used 024 * in state machine implementations throughout the Juneau codebase. This eliminates the need 025 * to declare local int constants and provides better code readability. 026 * 027 * <h5 class='section'>Examples:</h5> 028 * <p class='bcode w800'> 029 * <jk>import static</jk> org.apache.juneau.commons.utils.StateEnum.*; 030 * 031 * <jc>// Use in state machine</jc> 032 * <jk>var</jk> state = S1; 033 * <jk>if</jk> (state == S1) { 034 * <jc>// Handle state S1</jc> 035 * } 036 * </p> 037 * 038 * <h5 class='section'>See Also:</h5><ul> 039 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauCommonsBasics">juneau-commons Basics</a> 040 * </ul> 041 */ 042public enum StateEnum { 043 /** State 1 */ 044 S1, 045 /** State 2 */ 046 S2, 047 /** State 3 */ 048 S3, 049 /** State 4 */ 050 S4, 051 /** State 5 */ 052 S5, 053 /** State 6 */ 054 S6, 055 /** State 7 */ 056 S7, 057 /** State 8 */ 058 S8, 059 /** State 9 */ 060 S9, 061 /** State 10 */ 062 S10, 063 /** State 11 */ 064 S11, 065 /** State 12 */ 066 S12, 067 /** State 13 */ 068 S13, 069 /** State 14 */ 070 S14, 071 /** State 15 */ 072 S15, 073 /** State 16 */ 074 S16, 075 /** State 17 */ 076 S17, 077 /** State 18 */ 078 S18, 079 /** State 19 */ 080 S19, 081 /** State 20 */ 082 S20, 083 /** State 21 */ 084 S21, 085 /** State 22 */ 086 S22, 087 /** State 23 */ 088 S23, 089 /** State 24 */ 090 S24, 091 /** State 25 */ 092 S25, 093 /** State 26 */ 094 S26, 095 /** State 27 */ 096 S27, 097 /** State 28 */ 098 S28, 099 /** State 29 */ 100 S29, 101 /** State 30 */ 102 S30, 103 /** State 31 */ 104 S31, 105 /** State 32 */ 106 S32, 107 /** State 33 */ 108 S33, 109 /** State 34 */ 110 S34, 111 /** State 35 */ 112 S35, 113 /** State 36 */ 114 S36, 115 /** State 37 */ 116 S37, 117 /** State 38 */ 118 S38, 119 /** State 39 */ 120 S39, 121 /** State 40 */ 122 S40, 123 /** State 41 */ 124 S41, 125 /** State 42 */ 126 S42, 127 /** State 43 */ 128 S43, 129 /** State 44 */ 130 S44, 131 /** State 45 */ 132 S45, 133 /** State 46 */ 134 S46, 135 /** State 47 */ 136 S47, 137 /** State 48 */ 138 S48, 139 /** State 49 */ 140 S49, 141 /** State 50 */ 142 S50; 143 144 /** 145 * Returns <jk>true</jk> if the state is any one of the specified states. 146 * 147 * @param states The states to check. 148 * @return <jk>true</jk> if the state is any one of the specified states. 149 */ 150 public boolean isAny(StateEnum...states) { 151 for (var s : states) 152 if (this == s) 153 return true; 154 return false; 155 } 156}