| 1 | /** |
| 2 | * Licensed to jclouds, Inc. (jclouds) under one or more |
| 3 | * contributor license agreements. See the NOTICE file |
| 4 | * distributed with this work for additional information |
| 5 | * regarding copyright ownership. jclouds 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, |
| 13 | * software distributed under the License is distributed on an |
| 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | * KIND, either express or implied. See the License for the |
| 16 | * specific language governing permissions and limitations |
| 17 | * under the License. |
| 18 | */ |
| 19 | package org.jclouds.compute.domain; |
| 20 | |
| 21 | import org.jclouds.compute.config.CustomizationResponse; |
| 22 | |
| 23 | /** |
| 24 | * @author Adrian Cole |
| 25 | */ |
| 26 | public class ExecResponse implements CustomizationResponse { |
| 27 | |
| 28 | private final String error; |
| 29 | private final String output; |
| 30 | private final int exitCode; |
| 31 | |
| 32 | public ExecResponse(String output, String error, int exitCode) { |
| 33 | this.output = output; |
| 34 | this.error = error; |
| 35 | this.exitCode = exitCode; |
| 36 | } |
| 37 | |
| 38 | public String getError() { |
| 39 | return error; |
| 40 | } |
| 41 | |
| 42 | public String getOutput() { |
| 43 | return output; |
| 44 | } |
| 45 | |
| 46 | @Override |
| 47 | public String toString() { |
| 48 | return "[output=" + output + ", error=" + error + ", exitCode=" + exitCode + "]"; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public int hashCode() { |
| 53 | final int prime = 31; |
| 54 | int result = 1; |
| 55 | result = prime * result + ((error == null) ? 0 : error.hashCode()); |
| 56 | result = prime * result + exitCode; |
| 57 | result = prime * result + ((output == null) ? 0 : output.hashCode()); |
| 58 | return result; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public boolean equals(Object obj) { |
| 63 | if (this == obj) |
| 64 | return true; |
| 65 | if (obj == null) |
| 66 | return false; |
| 67 | if (getClass() != obj.getClass()) |
| 68 | return false; |
| 69 | ExecResponse other = (ExecResponse) obj; |
| 70 | if (error == null) { |
| 71 | if (other.error != null) |
| 72 | return false; |
| 73 | } else if (!error.equals(other.error)) |
| 74 | return false; |
| 75 | if (exitCode != other.exitCode) |
| 76 | return false; |
| 77 | if (output == null) { |
| 78 | if (other.output != null) |
| 79 | return false; |
| 80 | } else if (!output.equals(other.output)) |
| 81 | return false; |
| 82 | return true; |
| 83 | } |
| 84 | |
| 85 | public int getExitCode() { |
| 86 | return exitCode; |
| 87 | } |
| 88 | |
| 89 | } |