View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *     http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software
13   * distributed under the License is distributed on an "AS IS" BASIS,
14   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15   * See the License for the specific language governing permissions and
16   * limitations under the License.
17   */
18  package org.apache.giraph.scripting;
19  
20  import org.apache.giraph.graph.Language;
21  import org.codehaus.jackson.annotate.JsonCreator;
22  import org.codehaus.jackson.annotate.JsonProperty;
23  
24  import com.google.common.base.Objects;
25  
26  /**
27   * A script that was deployed to the cluster.
28   */
29  public class DeployedScript {
30    /** How the script was deployed */
31    @JsonProperty
32    private final DeployType deployType;
33    /** Path to the script */
34    @JsonProperty
35    private final String path;
36    /** Programming language the script is written in */
37    @JsonProperty
38    private final Language language;
39  
40    /**
41     * Constructor
42     *
43     * @param path String path to resource
44     * @param deployType deployment type
45     * @param language programming language
46     */
47    @JsonCreator
48    public DeployedScript(
49        @JsonProperty("path") String path,
50        @JsonProperty("deployType") DeployType deployType,
51        @JsonProperty("language") Language language) {
52      this.path = path;
53      this.deployType = deployType;
54      this.language = language;
55    }
56  
57    public DeployType getDeployType() {
58      return deployType;
59    }
60  
61    public String getPath() {
62      return path;
63    }
64  
65    public Language getLanguage() {
66      return language;
67    }
68  
69    @Override
70    public int hashCode() {
71      return Objects.hashCode(path, deployType, language);
72    }
73  
74    @Override
75    public boolean equals(Object obj) {
76      if (this == obj) {
77        return true;
78      }
79      if (obj instanceof DeployedScript) {
80        DeployedScript other = (DeployedScript) obj;
81        return Objects.equal(path, other.path) &&
82            Objects.equal(deployType, other.deployType) &&
83            Objects.equal(language, other.language);
84      }
85      return false;
86    }
87  
88    @Override
89    public String toString() {
90      return Objects.toStringHelper(this)
91          .add("path", path)
92          .add("deployType", deployType)
93          .add("language", language)
94          .toString();
95    }
96  }