| 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.blobstore.options; |
| 20 | |
| 21 | /** |
| 22 | * Contains options supported in the list container operation. <h2> |
| 23 | * Usage</h2> The recommended way to instantiate a CreateOptions object is to statically import |
| 24 | * CreateContainerOptions.* and invoke a static creation method followed by an instance mutator (if |
| 25 | * needed): |
| 26 | * <p/> |
| 27 | * <code> |
| 28 | * import static org.jclouds.blobstore.options.CreateContainerOptions.Builder.* |
| 29 | * <p/> |
| 30 | * BlobStore connection = // get connection |
| 31 | * Future<CreateResponse<ResourceMetadata>> list = connection.list("container",inDirectory("home/users").maxResults(1000)); |
| 32 | * <code> |
| 33 | * |
| 34 | * @author Adrian Cole |
| 35 | */ |
| 36 | public class CreateContainerOptions implements Cloneable { |
| 37 | |
| 38 | public static final ImmutableCreateContainerOptions NONE = new ImmutableCreateContainerOptions( |
| 39 | new CreateContainerOptions()); |
| 40 | |
| 41 | private boolean publicRead; |
| 42 | |
| 43 | public CreateContainerOptions() { |
| 44 | } |
| 45 | |
| 46 | CreateContainerOptions(boolean publicRead) { |
| 47 | this.publicRead = publicRead; |
| 48 | } |
| 49 | |
| 50 | public static class ImmutableCreateContainerOptions extends CreateContainerOptions { |
| 51 | private final CreateContainerOptions delegate; |
| 52 | |
| 53 | public ImmutableCreateContainerOptions(CreateContainerOptions delegate) { |
| 54 | this.delegate = delegate; |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public boolean isPublicRead() { |
| 59 | return delegate.isPublicRead(); |
| 60 | } |
| 61 | |
| 62 | @Override |
| 63 | public CreateContainerOptions publicRead() { |
| 64 | throw new UnsupportedOperationException(); |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public CreateContainerOptions clone() { |
| 69 | return delegate.clone(); |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public String toString() { |
| 74 | return delegate.toString(); |
| 75 | } |
| 76 | |
| 77 | } |
| 78 | |
| 79 | public boolean isPublicRead() { |
| 80 | return publicRead; |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * return a listing of all objects inside the store, publicReadly. |
| 85 | */ |
| 86 | public CreateContainerOptions publicRead() { |
| 87 | // checkArgument(path == null, "path and publicRead combination currently not supported"); |
| 88 | this.publicRead = true; |
| 89 | return this; |
| 90 | } |
| 91 | |
| 92 | public static class Builder { |
| 93 | |
| 94 | /** |
| 95 | * @see CreateContainerOptions#publicRead() |
| 96 | */ |
| 97 | public static CreateContainerOptions publicRead() { |
| 98 | CreateContainerOptions options = new CreateContainerOptions(); |
| 99 | return options.publicRead(); |
| 100 | } |
| 101 | |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | public CreateContainerOptions clone() { |
| 106 | return new CreateContainerOptions(publicRead); |
| 107 | } |
| 108 | |
| 109 | @Override |
| 110 | public String toString() { |
| 111 | return "[publicRead=" + publicRead + "]"; |
| 112 | } |
| 113 | } |