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.internal.admin.dto;
18  
19  import java.util.ArrayList;
20  import java.util.List;
21  import java.util.stream.Collectors;
22  
23  import com.linecorp.centraldogma.internal.thrift.PluginOperation;
24  
25  public class PluginOperationDto {
26      private String pluginName;
27      private String operationName;
28      private List<PluginOperationParamDefDto> paramDefs = new ArrayList<>();
29      private PluginOperationReturnDefDto returnDef;
30      private CommentDto comment;
31  
32      public PluginOperationDto() {}
33  
34      public PluginOperationDto(PluginOperation pluginOperation) {
35          pluginName = pluginOperation.getPluginName();
36          operationName = pluginOperation.getOperationName();
37          paramDefs = pluginOperation.getParamDefs().stream()
38                  .map(PluginOperationParamDefDto::new).collect(Collectors.toList());
39          returnDef = new PluginOperationReturnDefDto(pluginOperation.getReturnDef());
40          if (pluginOperation.getComment() != null) {
41              comment = new CommentDto(pluginOperation.getComment());
42          }
43      }
44  
45      public String getPluginName() {
46          return pluginName;
47      }
48  
49      public void setPluginName(String pluginName) {
50          this.pluginName = pluginName;
51      }
52  
53      public String getOperationName() {
54          return operationName;
55      }
56  
57      public void setOperationName(String operationName) {
58          this.operationName = operationName;
59      }
60  
61      public List<PluginOperationParamDefDto> getParamDefs() {
62          return paramDefs;
63      }
64  
65      public void setParamDefs(List<PluginOperationParamDefDto> paramDefs) {
66          this.paramDefs = paramDefs;
67      }
68  
69      public PluginOperationReturnDefDto getReturnDef() {
70          return returnDef;
71      }
72  
73      public void setReturnDef(PluginOperationReturnDefDto returnDef) {
74          this.returnDef = returnDef;
75      }
76  
77      public CommentDto getComment() {
78          return comment;
79      }
80  
81      public void setComment(CommentDto comment) {
82          this.comment = comment;
83      }
84  }