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

COVERAGE SUMMARY FOR SOURCE FILE [AtmosObjectImpl.java]

nameclass, %method, %block, %line, %
AtmosObjectImpl.java100% (2/2)81%  (13/16)56%  (137/243)59%  (31.8/54)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AtmosObjectImpl100% (1/1)75%  (9/12)51%  (107/211)56%  (28/50)
compareTo (AtmosObject): int 0%   (0/1)0%   (0/19)0%   (0/3)
hashCode (): int 0%   (0/1)0%   (0/46)0%   (0/6)
toString (): String 0%   (0/1)0%   (0/12)0%   (0/1)
equals (Object): boolean 100% (1/1)62%  (44/71)48%  (11/23)
AtmosObjectImpl (MutableContentMetadata): void 100% (1/1)100% (8/8)100% (2/2)
AtmosObjectImpl (MutableContentMetadata, SystemMetadata, UserMetadata): void 100% (1/1)100% (15/15)100% (6/6)
getAllHeaders (): Multimap 100% (1/1)100% (3/3)100% (1/1)
getContentMetadata (): MutableContentMetadata 100% (1/1)100% (3/3)100% (1/1)
getSystemMetadata (): SystemMetadata 100% (1/1)100% (3/3)100% (1/1)
getUserMetadata (): UserMetadata 100% (1/1)100% (3/3)100% (1/1)
setAllHeaders (Multimap): void 100% (1/1)100% (7/7)100% (2/2)
setPayload (Payload): void 100% (1/1)100% (21/21)100% (3/3)
     
class AtmosObjectImpl$AtmosObjectFactory100% (1/1)100% (4/4)94%  (30/32)96%  (3.8/4)
create (MutableContentMetadata): AtmosObject 100% (1/1)83%  (10/12)83%  (0.8/1)
AtmosObjectImpl$AtmosObjectFactory (): void 100% (1/1)100% (3/3)100% (1/1)
create (MutableContentMetadata, SystemMetadata, UserMetadata): AtmosObject 100% (1/1)100% (7/7)100% (1/1)
create (SystemMetadata, UserMetadata): AtmosObject 100% (1/1)100% (10/10)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.atmos.domain.internal;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22 
23import javax.inject.Inject;
24import javax.inject.Provider;
25import javax.inject.Singleton;
26 
27import org.jclouds.atmos.domain.AtmosObject;
28import org.jclouds.atmos.domain.MutableContentMetadata;
29import org.jclouds.atmos.domain.SystemMetadata;
30import org.jclouds.atmos.domain.UserMetadata;
31import org.jclouds.http.internal.PayloadEnclosingImpl;
32import org.jclouds.io.Payload;
33 
34import com.google.common.collect.LinkedHashMultimap;
35import com.google.common.collect.Multimap;
36 
37/**
38 * Default Implementation of {@link AtmosObject}.
39 * 
40 * @author Adrian Cole
41 */
42public class AtmosObjectImpl extends PayloadEnclosingImpl implements AtmosObject, Comparable<AtmosObject> {
43   @Singleton
44   public static class AtmosObjectFactory implements AtmosObject.Factory {
45 
46      @Inject
47      Provider<MutableContentMetadata> metadataProvider;
48 
49      public AtmosObject create(MutableContentMetadata contentMetadata) {
50         return new AtmosObjectImpl(contentMetadata != null ? contentMetadata : metadataProvider.get());
51      }
52 
53      public AtmosObject create(SystemMetadata systemMetadata, UserMetadata userMetadata) {
54         return new AtmosObjectImpl(metadataProvider.get(), systemMetadata, userMetadata);
55      }
56 
57      public AtmosObject create(MutableContentMetadata contentMetadata, SystemMetadata systemMetadata,
58               UserMetadata userMetadata) {
59         return new AtmosObjectImpl(contentMetadata, systemMetadata, userMetadata);
60      }
61   }
62 
63   private final UserMetadata userMetadata;
64   private final SystemMetadata systemMetadata;
65 
66   public SystemMetadata getSystemMetadata() {
67      return systemMetadata;
68   }
69 
70   public UserMetadata getUserMetadata() {
71      return userMetadata;
72   }
73 
74   private MutableContentMetadata contentMetadata;
75   private Multimap<String, String> allHeaders = LinkedHashMultimap.create();
76 
77   public AtmosObjectImpl(MutableContentMetadata contentMetadata, SystemMetadata systemMetadata,
78            UserMetadata userMetadata) {
79      this.contentMetadata = contentMetadata;
80      this.systemMetadata = systemMetadata;
81      this.userMetadata = userMetadata;
82   }
83 
84   @Inject
85   public AtmosObjectImpl(MutableContentMetadata contentMetadata) {
86      this(contentMetadata, null, new UserMetadata());
87   }
88 
89   /**
90    * {@inheritDoc}
91    */
92   @Override
93   public MutableContentMetadata getContentMetadata() {
94      return contentMetadata;
95   }
96 
97   /**
98    * {@inheritDoc}
99    */
100   @Override
101   public Multimap<String, String> getAllHeaders() {
102      return allHeaders;
103   }
104 
105   /**
106    * {@inheritDoc}
107    */
108   @Override
109   public void setAllHeaders(Multimap<String, String> allHeaders) {
110      this.allHeaders = checkNotNull(allHeaders, "allHeaders");
111   }
112 
113   /**
114    * {@inheritDoc}
115    */
116   @Override
117   public int compareTo(AtmosObject o) {
118      if (getContentMetadata().getName() == null)
119         return -1;
120      return (this == o) ? 0 : getContentMetadata().getName().compareTo(o.getContentMetadata().getName());
121   }
122 
123   @Override
124   public int hashCode() {
125      final int prime = 31;
126      int result = super.hashCode();
127      result = prime * result + ((contentMetadata == null) ? 0 : contentMetadata.hashCode());
128      result = prime * result + ((systemMetadata == null) ? 0 : systemMetadata.hashCode());
129      result = prime * result + ((userMetadata == null) ? 0 : userMetadata.hashCode());
130      return result;
131   }
132 
133   @Override
134   public boolean equals(Object obj) {
135      if (this == obj)
136         return true;
137      if (!super.equals(obj))
138         return false;
139      if (getClass() != obj.getClass())
140         return false;
141      AtmosObjectImpl other = (AtmosObjectImpl) obj;
142      if (contentMetadata == null) {
143         if (other.contentMetadata != null)
144            return false;
145      } else if (!contentMetadata.equals(other.contentMetadata))
146         return false;
147      if (systemMetadata == null) {
148         if (other.systemMetadata != null)
149            return false;
150      } else if (!systemMetadata.equals(other.systemMetadata))
151         return false;
152      if (userMetadata == null) {
153         if (other.userMetadata != null)
154            return false;
155      } else if (!userMetadata.equals(other.userMetadata))
156         return false;
157      return true;
158   }
159 
160   @Override
161   public String toString() {
162      return "[contentMetadata=" + contentMetadata + "]";
163   }
164 
165   @Override
166   public void setPayload(Payload data) {
167      this.payload = data;
168      this.contentMetadata = new DelegatingMutableContentMetadata(contentMetadata.getUri(), contentMetadata.getName(),
169               contentMetadata.getPath(), payload.getContentMetadata());
170   }
171}

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