| 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.vcloud.domain; |
| 20 | |
| 21 | import java.util.Set; |
| 22 | |
| 23 | import org.jclouds.cim.ResourceAllocationSettingData; |
| 24 | import org.jclouds.cim.VirtualSystemSettingData; |
| 25 | |
| 26 | import com.google.common.collect.Iterables; |
| 27 | import com.google.common.collect.Sets; |
| 28 | |
| 29 | /** |
| 30 | * The InstantiateVAppTemplateParams element forms the body of an instantiateVappTemplate request. |
| 31 | */ |
| 32 | public class InstantiateVAppTemplateParams { |
| 33 | |
| 34 | protected final String info; |
| 35 | protected final VirtualSystemSettingData virtualSystem; |
| 36 | protected final Set<ResourceAllocationSettingData> resourceAllocations = Sets.newLinkedHashSet(); |
| 37 | |
| 38 | public InstantiateVAppTemplateParams(String info, VirtualSystemSettingData virtualSystem, Iterable<? extends ResourceAllocationSettingData> resourceAllocations) { |
| 39 | this.info = info; |
| 40 | this.virtualSystem = virtualSystem; |
| 41 | Iterables.addAll(this.resourceAllocations, resourceAllocations); |
| 42 | } |
| 43 | |
| 44 | public String getInfo() { |
| 45 | return info; |
| 46 | } |
| 47 | |
| 48 | public VirtualSystemSettingData getSystem() { |
| 49 | return virtualSystem; |
| 50 | } |
| 51 | |
| 52 | public Set<? extends ResourceAllocationSettingData> getResourceAllocationSettingDatas() { |
| 53 | return resourceAllocations; |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public String toString() { |
| 58 | return "[info=" + getInfo() + ", virtualSystem=" + getSystem() + "]"; |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public int hashCode() { |
| 63 | final int prime = 31; |
| 64 | int result = 1; |
| 65 | result = prime * result + ((info == null) ? 0 : info.hashCode()); |
| 66 | result = prime * result + ((resourceAllocations == null) ? 0 : resourceAllocations.hashCode()); |
| 67 | result = prime * result + ((virtualSystem == null) ? 0 : virtualSystem.hashCode()); |
| 68 | return result; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public boolean equals(Object obj) { |
| 73 | if (this == obj) |
| 74 | return true; |
| 75 | if (obj == null) |
| 76 | return false; |
| 77 | if (getClass() != obj.getClass()) |
| 78 | return false; |
| 79 | InstantiateVAppTemplateParams other = (InstantiateVAppTemplateParams) obj; |
| 80 | if (info == null) { |
| 81 | if (other.info != null) |
| 82 | return false; |
| 83 | } else if (!info.equals(other.info)) |
| 84 | return false; |
| 85 | if (resourceAllocations == null) { |
| 86 | if (other.resourceAllocations != null) |
| 87 | return false; |
| 88 | } else if (!resourceAllocations.equals(other.resourceAllocations)) |
| 89 | return false; |
| 90 | if (virtualSystem == null) { |
| 91 | if (other.virtualSystem != null) |
| 92 | return false; |
| 93 | } else if (!virtualSystem.equals(other.virtualSystem)) |
| 94 | return false; |
| 95 | return true; |
| 96 | } |
| 97 | |
| 98 | } |