1   /*
2    * Copyright 2017 LINE Corporation
3    *
4    * LINE Corporation licenses this file to you under the Apache License,
5    * version 2.0 (the "License"); you may not use this file except in compliance
6    * with the License. You may obtain a copy of the License at:
7    *
8    *   https://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations
14   * under the License.
15   */
16  
17  package com.linecorp.centraldogma.server.command;
18  
19  import com.linecorp.centraldogma.common.Revision;
20  
21  /**
22   * Types of a {@link Command}.
23   */
24  public enum CommandType {
25      CREATE_PROJECT(Void.class),
26      REMOVE_PROJECT(Void.class),
27      UNREMOVE_PROJECT(Void.class),
28      CREATE_REPOSITORY(Void.class),
29      REMOVE_REPOSITORY(Void.class),
30      UNREMOVE_REPOSITORY(Void.class),
31      NORMALIZING_PUSH(CommitResult.class),
32      PUSH(Revision.class),
33      SAVE_NAMED_QUERY(Void.class),
34      REMOVE_NAMED_QUERY(Void.class),
35      SAVE_PLUGIN(Void.class),
36      REMOVE_PLUGIN(Void.class),
37      CREATE_SESSION(Void.class),
38      REMOVE_SESSION(Void.class),
39      PURGE_PROJECT(Void.class),
40      PURGE_REPOSITORY(Void.class),
41      UPDATE_SERVER_STATUS(Void.class),
42      // The result type of FORCE_PUSH is Object because it can be any type.
43      FORCE_PUSH(Object.class);
44  
45      /**
46       * The type of an object which is returned as a result after executing the command.
47       */
48      private final Class<?> resultType;
49  
50      CommandType(Class<?> resultType) {
51          this.resultType = resultType;
52      }
53  
54      /**
55       * Returns the result type of the command.
56       */
57      public Class<?> resultType() {
58          return resultType;
59      }
60  }