| 1 | /** | 
| 2 |  * | 
| 3 |  * Copyright (C) 2011 Cloud Conscious, LLC. <info@cloudconscious.com> | 
| 4 |  * | 
| 5 |  * ==================================================================== | 
| 6 |  * Licensed under the Apache License, Version 2.0 (the "License"); | 
| 7 |  * you may not use this file except in compliance with the License. | 
| 8 |  * 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 |  */ | 
| 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 | } |