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      RESET_META_REPOSITORY(Void.class),
30      REMOVE_REPOSITORY(Void.class),
31      UNREMOVE_REPOSITORY(Void.class),
32      NORMALIZING_PUSH(CommitResult.class),
33      TRANSFORM(CommitResult.class),
34      PUSH(Revision.class),
35      SAVE_NAMED_QUERY(Void.class),
36      REMOVE_NAMED_QUERY(Void.class),
37      SAVE_PLUGIN(Void.class),
38      REMOVE_PLUGIN(Void.class),
39      CREATE_SESSION(Void.class),
40      REMOVE_SESSION(Void.class),
41      PURGE_PROJECT(Void.class),
42      PURGE_REPOSITORY(Void.class),
43      UPDATE_SERVER_STATUS(Void.class),
44      // The result type of FORCE_PUSH is Object because it can be any type.
45      FORCE_PUSH(Object.class);
46  
47      /**
48       * The type of an object which is returned as a result after executing the command.
49       */
50      private final Class<?> resultType;
51  
52      CommandType(Class<?> resultType) {
53          this.resultType = resultType;
54      }
55  
56      /**
57       * Returns the result type of the command.
58       */
59      public Class<?> resultType() {
60          return resultType;
61      }
62  }