View Javadoc
1   package org.apache.maven.surefire.booter;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  /**
23   * Specifies the way how the forked jvm should be terminated after
24   * class AbstractCommandStream is closed and CTRL+C.
25   *
26   * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
27   * @since 2.19
28   */
29  public enum Shutdown
30  {
31      DEFAULT( "testset" ),
32      EXIT( "exit" ),
33      KILL( "kill" );
34  
35      private final String param;
36  
37      Shutdown( String param )
38      {
39          this.param = param;
40      }
41  
42      public String getParam()
43      {
44          return param;
45      }
46  
47      public static boolean isKnown( String param )
48      {
49          for ( Shutdown shutdown : values() )
50          {
51              if ( shutdown.param.equals( param ) )
52              {
53                  return true;
54              }
55          }
56          return false;
57      }
58  
59      public static String listParameters()
60      {
61          StringBuilder values = new StringBuilder();
62          for ( Shutdown shutdown : values() )
63          {
64              if ( values.length() != 0 )
65              {
66                  values.append( ", " );
67              }
68              values.append( shutdown.getParam() );
69          }
70          return values.toString();
71      }
72  
73      public static Shutdown parameterOf( String parameter )
74      {
75          for ( Shutdown shutdown : values() )
76          {
77              if ( shutdown.param.equals( parameter ) )
78              {
79                  return shutdown;
80              }
81          }
82          return DEFAULT;
83      }
84  }