All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jclouds.azureblob.options.CopyBlobOptions Maven / Gradle / Ivy

The newest version!
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.jclouds.azureblob.options;

import static shaded.com.google.common.base.Preconditions.checkNotNull;

import java.util.Date;
import java.util.Map;

import shaded.com.google.common.base.Optional;
import shaded.com.google.common.collect.ImmutableMap;

public final class CopyBlobOptions {
   public static final CopyBlobOptions NONE = CopyBlobOptions.builder().build();

   private final Optional> userMetadata;
   private final Optional ifModifiedSince;
   private final Optional ifUnmodifiedSince;
   private final Optional ifMatch;
   private final Optional ifNoneMatch;

   private CopyBlobOptions(Map userMetadata, Date ifModifiedSince, Date ifUnmodifiedSince,
         String ifMatch, String ifNoneMatch) {
      this.userMetadata = Optional.fromNullable(userMetadata);
      this.ifModifiedSince = Optional.fromNullable(ifModifiedSince);
      this.ifUnmodifiedSince = Optional.fromNullable(ifUnmodifiedSince);
      this.ifMatch = Optional.fromNullable(ifMatch);
      this.ifNoneMatch = Optional.fromNullable(ifNoneMatch);
   }

   public static Builder builder() {
      return new Builder();
   }

   public Optional> getUserMetadata() {
      return userMetadata;
   }

   public Optional getIfModifiedSince() {
      return Optional.fromNullable(ifModifiedSince.isPresent() ? (Date) ifModifiedSince.get().clone() : null);
   }

   public Optional getIfUnmodifiedSince() {
      return Optional.fromNullable(ifUnmodifiedSince.isPresent() ? (Date) ifUnmodifiedSince.get().clone() : null);
   }

   public Optional getIfMatch() {
      return ifMatch;
   }

   public Optional getIfNoneMatch() {
      return ifNoneMatch;
   }

   public static class Builder {
      private Map userMetadata;
      private Date ifModifiedSince;
      private Date ifUnmodifiedSince;
      private String ifMatch;
      private String ifNoneMatch;

      Builder() {
      }

      public Builder overrideUserMetadata(Map userMetadata) {
         this.userMetadata = ImmutableMap.copyOf(checkNotNull(userMetadata, "userMetadata"));
         return this;
      }

      public Builder ifModifiedSince(Date ifModifiedSince) {
         this.ifModifiedSince = (Date) checkNotNull(ifModifiedSince, "ifModifiedSince").clone();
         return this;
      }

      public Builder ifUnmodifiedSince(Date ifUnmodifiedSince) {
         this.ifUnmodifiedSince = (Date) checkNotNull(ifUnmodifiedSince, "ifUnmodifiedSince").clone();
         return this;
      }

      public Builder ifMatch(String ifMatch) {
         this.ifMatch = checkNotNull(ifMatch, "ifMatch");
         return this;
      }

      public Builder ifNoneMatch(String ifNoneMatch) {
         this.ifNoneMatch = checkNotNull(ifNoneMatch, "ifNoneMatch");
         return this;
      }

      public CopyBlobOptions build() {
         return new CopyBlobOptions(userMetadata, ifModifiedSince, ifUnmodifiedSince, ifMatch, ifNoneMatch);
      }
   }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy