| 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.atmos.domain.internal; |
| 20 | |
| 21 | import java.net.URI; |
| 22 | |
| 23 | import org.jclouds.atmos.domain.MutableContentMetadata; |
| 24 | import org.jclouds.io.ContentMetadataBuilder; |
| 25 | import org.jclouds.io.payloads.BaseMutableContentMetadata; |
| 26 | |
| 27 | import com.google.common.collect.Multimap; |
| 28 | |
| 29 | /** |
| 30 | * |
| 31 | * @author Adrian Cole |
| 32 | */ |
| 33 | public class DelegatingMutableContentMetadata implements MutableContentMetadata { |
| 34 | private URI uri; |
| 35 | private String name; |
| 36 | private String path; |
| 37 | private final org.jclouds.io.MutableContentMetadata delegate; |
| 38 | |
| 39 | public DelegatingMutableContentMetadata() { |
| 40 | this(null, null, null, new BaseMutableContentMetadata()); |
| 41 | } |
| 42 | |
| 43 | public DelegatingMutableContentMetadata(URI uri, String name, String path, |
| 44 | org.jclouds.io.MutableContentMetadata delegate) { |
| 45 | this.uri = uri; |
| 46 | this.name = name; |
| 47 | this.delegate = delegate; |
| 48 | this.path = path; |
| 49 | } |
| 50 | |
| 51 | @Override |
| 52 | public Long getContentLength() { |
| 53 | return delegate.getContentLength(); |
| 54 | } |
| 55 | |
| 56 | @Override |
| 57 | public byte[] getContentMD5() { |
| 58 | return delegate.getContentMD5(); |
| 59 | } |
| 60 | |
| 61 | @Override |
| 62 | public String getContentType() { |
| 63 | return delegate.getContentType(); |
| 64 | } |
| 65 | |
| 66 | @Override |
| 67 | public String getName() { |
| 68 | return name; |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public void setContentLength(Long contentLength) { |
| 73 | delegate.setContentLength(contentLength); |
| 74 | } |
| 75 | |
| 76 | @Override |
| 77 | public void setContentMD5(byte[] contentMD5) { |
| 78 | delegate.setContentMD5(contentMD5); |
| 79 | } |
| 80 | |
| 81 | @Override |
| 82 | public void setContentType(String contentType) { |
| 83 | delegate.setContentType(contentType); |
| 84 | } |
| 85 | |
| 86 | @Override |
| 87 | public void setName(String name) { |
| 88 | this.name = name; |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public boolean equals(Object obj) { |
| 93 | if (this == obj) |
| 94 | return true; |
| 95 | if (obj == null) |
| 96 | return false; |
| 97 | if (getClass() != obj.getClass()) |
| 98 | return false; |
| 99 | DelegatingMutableContentMetadata other = (DelegatingMutableContentMetadata) obj; |
| 100 | if (uri == null) { |
| 101 | if (other.uri != null) |
| 102 | return false; |
| 103 | } else if (!uri.equals(other.uri)) |
| 104 | return false; |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | @Override |
| 109 | public int hashCode() { |
| 110 | final int prime = 31; |
| 111 | int result = 1; |
| 112 | result = prime * result + ((uri == null) ? 0 : uri.hashCode()); |
| 113 | return result; |
| 114 | } |
| 115 | |
| 116 | @Override |
| 117 | public String toString() { |
| 118 | return "[uri=" + uri + ", name=" + name + ", path=" + path + ", delegate=" + delegate + "]"; |
| 119 | } |
| 120 | |
| 121 | public org.jclouds.io.MutableContentMetadata getDelegate() { |
| 122 | return delegate; |
| 123 | } |
| 124 | |
| 125 | @Override |
| 126 | public void setContentDisposition(String contentDisposition) { |
| 127 | delegate.setContentDisposition(contentDisposition); |
| 128 | |
| 129 | } |
| 130 | |
| 131 | @Override |
| 132 | public void setContentEncoding(String contentEncoding) { |
| 133 | delegate.setContentEncoding(contentEncoding); |
| 134 | } |
| 135 | |
| 136 | @Override |
| 137 | public void setContentLanguage(String contentLanguage) { |
| 138 | delegate.setContentLanguage(contentLanguage); |
| 139 | } |
| 140 | |
| 141 | @Override |
| 142 | public String getContentDisposition() { |
| 143 | return delegate.getContentDisposition(); |
| 144 | } |
| 145 | |
| 146 | @Override |
| 147 | public String getContentEncoding() { |
| 148 | return delegate.getContentEncoding(); |
| 149 | } |
| 150 | |
| 151 | @Override |
| 152 | public String getContentLanguage() { |
| 153 | return delegate.getContentLanguage(); |
| 154 | } |
| 155 | |
| 156 | @Override |
| 157 | public void setPropertiesFromHttpHeaders(Multimap<String, String> headers) { |
| 158 | delegate.setPropertiesFromHttpHeaders(headers); |
| 159 | } |
| 160 | |
| 161 | @Override |
| 162 | public ContentMetadataBuilder toBuilder() { |
| 163 | return delegate.toBuilder(); |
| 164 | } |
| 165 | |
| 166 | @Override |
| 167 | public URI getUri() { |
| 168 | return uri; |
| 169 | } |
| 170 | |
| 171 | @Override |
| 172 | public void setUri(URI uri) { |
| 173 | this.uri = uri; |
| 174 | } |
| 175 | |
| 176 | @Override |
| 177 | public String getPath() { |
| 178 | return path; |
| 179 | } |
| 180 | |
| 181 | @Override |
| 182 | public void setPath(String path) { |
| 183 | this.path = path; |
| 184 | } |
| 185 | |
| 186 | } |