This project has retired. For details please refer to its Attic page.
DeployedScript xref
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 com.google.common.base.MoreObjects;
21  import org.apache.giraph.graph.Language;
22  import org.codehaus.jackson.annotate.JsonCreator;
23  import org.codehaus.jackson.annotate.JsonProperty;
24  
25  import com.google.common.base.Objects;
26  
27  /**
28   * A script that was deployed to the cluster.
29   */
30  public class DeployedScript {
31    /** How the script was deployed */
32    @JsonProperty
33    private final DeployType deployType;
34    /** Path to the script */
35    @JsonProperty
36    private final String path;
37    /** Programming language the script is written in */
38    @JsonProperty
39    private final Language language;
40  
41    /**
42     * Constructor
43     *
44     * @param path String path to resource
45     * @param deployType deployment type
46     * @param language programming language
47     */
48    @JsonCreator
49    public DeployedScript(
50        @JsonProperty("path") String path,
51        @JsonProperty("deployType") DeployType deployType,
52        @JsonProperty("language") Language language) {
53      this.path = path;
54      this.deployType = deployType;
55      this.language = language;
56    }
57  
58    public DeployType getDeployType() {
59      return deployType;
60    }
61  
62    public String getPath() {
63      return path;
64    }
65  
66    public Language getLanguage() {
67      return language;
68    }
69  
70    @Override
71    public int hashCode() {
72      return Objects.hashCode(path, deployType, language);
73    }
74  
75    @Override
76    public boolean equals(Object obj) {
77      if (this == obj) {
78        return true;
79      }
80      if (obj instanceof DeployedScript) {
81        DeployedScript other = (DeployedScript) obj;
82        return Objects.equal(path, other.path) &&
83            Objects.equal(deployType, other.deployType) &&
84            Objects.equal(language, other.language);
85      }
86      return false;
87    }
88  
89    @Override
90    public String toString() {
91      return MoreObjects.toStringHelper(this)
92          .add("path", path)
93          .add("deployType", deployType)
94          .add("language", language)
95          .toString();
96    }
97  }