Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * 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.openstack.swift.v1.domain;
 
 import static com.google.common.base.Objects.equal;
 import static com.google.common.base.Objects.toStringHelper;
 import static com.google.common.base.Preconditions.checkNotNull;
 
 import java.util.Map;
 
Represents a Container in OpenStack Object Storage.

 
 public class Container implements Comparable<Container> {
 
    private final String name;
    private final long objectCount;
    private final long bytesUsed;
    private final Optional<BooleananybodyRead;
    private final Map<StringStringmetadata;
    private final Multimap<StringStringheaders;
 
    @ConstructorProperties({ "name""count""bytes""anybodyRead""metadata""headers"})
    protected Container(String namelong objectCountlong bytesUsedOptional<BooleananybodyRead,
          Map<StringStringmetadataMultimap<StringStringheaders) {
       this. = checkNotNull(name"name");
       this. = objectCount;
       this. = bytesUsed;
       this. = anybodyRead == null ? Optional.<Booleanabsent() : anybodyRead;
       this. = metadata == null ? ImmutableMap.<StringStringof() : metadata;
       this. = headers == null ? ImmutableMultimap.<StringStringof() : headers;
    }

   

Returns:
The name of this container.
 
    public String getName() {
       return ;
    }

   

Returns:
The count of objects for this container.
 
    public long getObjectCount() {
       return ;
    }

   

Returns:
The number of bytes used by this container.
 
    public long getBytesUsed() {
       return ;
    }

   
Absent except in Get Container commands.

Returns:
true if this container is publicly readable, false otherwise.
See also:
org.jclouds.openstack.swift.v1.options.CreateContainerOptions.anybodyRead()
 
    public Optional<BooleangetAnybodyRead() {
       return ;
    }

   

NOTE

In current swift implementations, headers keys are lower-cased. This means characters such as turkish will probably not work out well.

Returns:
a Map<String, String> containing this container's metadata.
 
    public Map<StringStringgetMetadata() {
       return ;
   }

   

Returns:
The HTTP headers for this account.
   public Multimap<StringStringgetHeaders() {
      return ;
   }
   public boolean equals(Object object) {
      if (this == object) {
         return true;
      }
      if (object instanceof Container) {
         final Container that = Container.class.cast(object);
         return equal(getName(), that.getName())
               && equal(getObjectCount(), that.getObjectCount())
               && equal(getBytesUsed(), that.getBytesUsed())
               && equal(getMetadata(), that.getMetadata());
      } else {
         return false;
      }
   }
   public int hashCode() {
      return Objects.hashCode(getName(), getObjectCount(), getBytesUsed(), getAnybodyRead(), getMetadata());
   }
   public String toString() {
      return string().toString();
   }
   protected ToStringHelper string() {
      return toStringHelper(this).omitNullValues()
            .add("name"getName())
            .add("objectCount"getObjectCount())
            .add("bytesUsed"getBytesUsed())
            .add("anybodyRead"getAnybodyRead().orNull())
            .add("metadata"getMetadata());
   }
   public int compareTo(Container that) {
      if (that == null)
         return 1;
      if (this == that)
         return 0;
      return this.getName().compareTo(that.getName());
   }
   public static Builder builder() {
      return new Builder();
   }
   public Builder toBuilder() {
      return builder().fromContainer(this);
   }
   public static class Builder {
      protected String name;
      protected long objectCount;
      protected long bytesUsed;
      protected Optional<BooleananybodyRead = Optional.absent();
      protected Map<StringStringmetadata = ImmutableMap.of();
      protected Multimap<StringStringheaders = ImmutableMultimap.of();

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

      
      public Builder objectCount(long objectCount) {
         this. = objectCount;
         return this;
      }

      
      public Builder bytesUsed(long bytesUsed) {
         this. = bytesUsed;
         return this;
      }

      
      public Builder anybodyRead(Boolean anybodyRead) {
         this. = Optional.fromNullable(anybodyRead);
         return this;
      }

      

NOTE

This method will lower-case all metadata keys.

      public Builder metadata(Map<StringStringmetadata) {
         ImmutableMap.Builder<StringStringbuilder = ImmutableMap.<StringStringbuilder();
         for (Entry<StringStringentry : checkNotNull(metadata"metadata").entrySet()) {
            builder.put(entry.getKey().toLowerCase(), entry.getValue());
         }
         this. = builder.build();
         return this;
      }

      
      public Builder headers(Multimap<StringStringheaders) {
         this. = headers;
         return this;
      }
      public Container build() {
         return new Container();
      }
      public Builder fromContainer(Container from) {
         return name(from.getName())
               .objectCount(from.getObjectCount())
               .bytesUsed(from.getBytesUsed())
               .anybodyRead(from.getAnybodyRead().orNull())
               .metadata(from.getMetadata())
               .headers(from.getHeaders());
      }
   }
New to GrepCode? Check out our FAQ X