EMMA Coverage Report (generated Mon Oct 17 05:41:20 EDT 2011)
[all classes][org.jclouds.s3.domain]

COVERAGE SUMMARY FOR SOURCE FILE [BucketMetadata.java]

nameclass, %method, %block, %line, %
BucketMetadata.java100% (1/1)71%  (5/7)42%  (49/117)40%  (12.8/32)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class BucketMetadata100% (1/1)71%  (5/7)42%  (49/117)40%  (12.8/32)
compareTo (BucketMetadata): int 0%   (0/1)0%   (0/11)0%   (0/1)
equals (Object): boolean 0%   (0/1)0%   (0/53)0%   (0/18)
hashCode (): int 100% (1/1)88%  (28/32)96%  (4.8/5)
BucketMetadata (String, Date, CanonicalUser): void 100% (1/1)100% (12/12)100% (5/5)
getCreationDate (): Date 100% (1/1)100% (3/3)100% (1/1)
getName (): String 100% (1/1)100% (3/3)100% (1/1)
getOwner (): CanonicalUser 100% (1/1)100% (3/3)100% (1/1)

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 */
19package org.jclouds.s3.domain;
20 
21import java.util.Date;
22 
23/**
24 * System metadata of the S3Bucket
25 * 
26 * @author Adrian Cole
27 */
28public class BucketMetadata implements Comparable<BucketMetadata> {
29   private final Date creationDate;
30   private final CanonicalUser owner;
31   private final String name;
32 
33   public BucketMetadata(String name, Date creationDate, CanonicalUser owner) {
34      this.name = name;
35      this.creationDate = creationDate;
36      this.owner = owner;
37   }
38 
39   /**
40    * Every bucket and object in Amazon S3 has an owner, the user that created the bucket or object.
41    * The owner of a bucket or object cannot be changed. However, if the object is overwritten by
42    * another user (deleted and rewritten), the new object will have a new owner.
43    */
44   public CanonicalUser getOwner() {
45      return owner;
46   }
47 
48   public Date getCreationDate() {
49      return creationDate;
50   }
51 
52   /**
53    * To comply with Amazon S3 requirements, bucket names must:
54    * <p/>
55    * Contain lowercase letters, numbers, periods (.), underscores (_), and dashes (-)
56    * <p/>
57    * Start with a number or letter
58    * <p/>
59    * Be between 3 and 255 characters long
60    * <p/>
61    * Not be in an IP address style (e.g., "192.168.5.4")
62    */
63   public String getName() {
64      return name;
65   }
66 
67   public int compareTo(BucketMetadata o) {
68      return (this == o) ? 0 : getName().compareTo(o.getName());
69   }
70 
71   @Override
72   public int hashCode() {
73      final int prime = 31;
74      int result = 1;
75      result = prime * result + ((name == null) ? 0 : name.hashCode());
76      result = prime * result + ((owner == null) ? 0 : owner.hashCode());
77      return result;
78   }
79 
80   @Override
81   public boolean equals(Object obj) {
82      if (this == obj)
83         return true;
84      if (obj == null)
85         return false;
86      if (getClass() != obj.getClass())
87         return false;
88      BucketMetadata other = (BucketMetadata) obj;
89      if (name == null) {
90         if (other.name != null)
91            return false;
92      } else if (!name.equals(other.name))
93         return false;
94      if (owner == null) {
95         if (other.owner != null)
96            return false;
97      } else if (!owner.equals(other.owner))
98         return false;
99      return true;
100   }
101}

[all classes][org.jclouds.s3.domain]
EMMA 2.0.5312 (C) Vladimir Roubtsov