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

COVERAGE SUMMARY FOR SOURCE FILE [ReturnEndpointIfAlreadyExists.java]

nameclass, %method, %block, %line, %
ReturnEndpointIfAlreadyExists.java100% (1/1)75%  (3/4)52%  (16/31)71%  (5/7)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class ReturnEndpointIfAlreadyExists100% (1/1)75%  (3/4)52%  (16/31)71%  (5/7)
setContext (HttpRequest): ReturnEndpointIfAlreadyExists 0%   (0/1)0%   (0/9)0%   (0/1)
apply (Exception): URI 100% (1/1)57%  (8/14)67%  (2/3)
ReturnEndpointIfAlreadyExists (): void 100% (1/1)100% (3/3)100% (1/1)
setEndpoint (URI): ReturnEndpointIfAlreadyExists 100% (1/1)100% (5/5)100% (2/2)

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.functions;
20 
21import static com.google.common.base.Preconditions.checkNotNull;
22import static org.jclouds.util.Throwables2.propagateOrNull;
23 
24import java.net.URI;
25 
26import org.jclouds.javax.annotation.Nullable;
27 
28import org.jclouds.blobstore.KeyAlreadyExistsException;
29import org.jclouds.http.HttpRequest;
30import org.jclouds.rest.InvocationContext;
31 
32import com.google.common.annotations.VisibleForTesting;
33import com.google.common.base.Function;
34 
35/**
36 * 
37 * @author Adrian Cole
38 */
39public class ReturnEndpointIfAlreadyExists implements Function<Exception, URI>,
40      InvocationContext<ReturnEndpointIfAlreadyExists> {
41 
42   private URI endpoint;
43 
44   public URI apply(Exception from) {
45      if (checkNotNull(from, "exception") instanceof KeyAlreadyExistsException) {
46         return endpoint;
47      }
48      return URI.class.cast(propagateOrNull(from));
49   }
50 
51   @Override
52   public ReturnEndpointIfAlreadyExists setContext(HttpRequest request) {
53      return setEndpoint(request == null ? null : request.getEndpoint());
54   }
55 
56   @VisibleForTesting
57   ReturnEndpointIfAlreadyExists setEndpoint(@Nullable URI endpoint) {
58      this.endpoint = endpoint;
59      return this;
60   }
61 
62}

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