| 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.azureblob.domain.internal; |
| 20 | |
| 21 | import java.net.URI; |
| 22 | import java.util.Set; |
| 23 | |
| 24 | import org.jclouds.azureblob.domain.BlobProperties; |
| 25 | import org.jclouds.azureblob.domain.ListBlobsResponse; |
| 26 | import org.jclouds.azure.storage.domain.internal.BoundedHashSet; |
| 27 | |
| 28 | import com.google.common.collect.Iterables; |
| 29 | import com.google.common.collect.Sets; |
| 30 | |
| 31 | /** |
| 32 | * |
| 33 | * @author Adrian Cole |
| 34 | * |
| 35 | */ |
| 36 | public class HashSetListBlobsResponse extends BoundedHashSet<BlobProperties> implements |
| 37 | ListBlobsResponse { |
| 38 | /** The serialVersionUID */ |
| 39 | private static final long serialVersionUID = -4475709781001190244L; |
| 40 | |
| 41 | protected final String delimiter; |
| 42 | protected final Set<String> blobPrefixes = Sets.newHashSet(); |
| 43 | |
| 44 | public HashSetListBlobsResponse(Iterable<BlobProperties> contents, URI url, String prefix, |
| 45 | String marker, Integer maxResults, String nextMarker, String delimiter, |
| 46 | Iterable<String> blobPrefixes) { |
| 47 | super(contents, url, prefix, marker, maxResults, nextMarker); |
| 48 | this.delimiter = delimiter; |
| 49 | Iterables.addAll(this.blobPrefixes, blobPrefixes); |
| 50 | } |
| 51 | |
| 52 | public String getDelimiter() { |
| 53 | return delimiter; |
| 54 | } |
| 55 | |
| 56 | public Set<String> getBlobPrefixes() { |
| 57 | return blobPrefixes; |
| 58 | } |
| 59 | |
| 60 | @Override |
| 61 | public int hashCode() { |
| 62 | final int prime = 31; |
| 63 | int result = super.hashCode(); |
| 64 | result = prime * result + ((blobPrefixes == null) ? 0 : blobPrefixes.hashCode()); |
| 65 | result = prime * result + ((delimiter == null) ? 0 : delimiter.hashCode()); |
| 66 | return result; |
| 67 | } |
| 68 | |
| 69 | @Override |
| 70 | public boolean equals(Object obj) { |
| 71 | if (this == obj) |
| 72 | return true; |
| 73 | if (!super.equals(obj)) |
| 74 | return false; |
| 75 | if (getClass() != obj.getClass()) |
| 76 | return false; |
| 77 | HashSetListBlobsResponse other = (HashSetListBlobsResponse) obj; |
| 78 | if (blobPrefixes == null) { |
| 79 | if (other.blobPrefixes != null) |
| 80 | return false; |
| 81 | } else if (!blobPrefixes.equals(other.blobPrefixes)) |
| 82 | return false; |
| 83 | if (delimiter == null) { |
| 84 | if (other.delimiter != null) |
| 85 | return false; |
| 86 | } else if (!delimiter.equals(other.delimiter)) |
| 87 | return false; |
| 88 | return true; |
| 89 | } |
| 90 | |
| 91 | @Override |
| 92 | public String toString() { |
| 93 | return "[blobPrefixes=" + blobPrefixes + ", delimiter=" + delimiter |
| 94 | + "]"; |
| 95 | } |
| 96 | } |