Coverage Report - org.apache.shindig.social.core.util.atom.AtomContent
 
Classes in this File Line Coverage Branch Coverage Complexity
AtomContent
100%
18/18
100%
4/4
0
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements. See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership. The ASF 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 under the License.
 17  
  */
 18  
 package org.apache.shindig.social.core.util.atom;
 19  
 
 20  
 import com.google.common.collect.Lists;
 21  
 
 22  
 import org.apache.shindig.social.opensocial.model.Activity;
 23  
 import org.apache.shindig.social.opensocial.model.Person;
 24  
 
 25  
 import java.util.ArrayList;
 26  
 import java.util.List;
 27  
 import java.util.Map;
 28  
 import java.util.Map.Entry;
 29  
 
 30  
 /**
 31  
  * Represents and atom:content element.
 32  
  */
 33  
 public class AtomContent {
 34  
 
 35  
   @SuppressWarnings("unused")
 36  
   private Person person;
 37  
   @SuppressWarnings("unused")
 38  
   private Activity activity;
 39  
   @SuppressWarnings("unused")
 40  6
   private AtomAttribute type = new AtomAttribute("application/xml");
 41  
   @SuppressWarnings("unused")
 42  
   private Object entry;
 43  
   @SuppressWarnings("unused")
 44  
   private Object value;
 45  
 
 46  
   /**
 47  
    * @param person
 48  
    */
 49  1
   public AtomContent(Person person) {
 50  1
     this.person = person;
 51  1
   }
 52  
 
 53  
   /**
 54  
    * @param activity
 55  
    */
 56  1
   public AtomContent(Activity activity) {
 57  1
     this.activity = activity;
 58  1
   }
 59  
 
 60  
   /**
 61  
    * @param value
 62  
    */
 63  4
   public AtomContent(Object value) {
 64  4
     if (value instanceof Map) {
 65  2
       Map<?, ?> entries = (Map<?, ?>) value;
 66  2
       List<AtomKeyValue> keyValues = Lists.newArrayList();
 67  2
       for ( Entry<?, ?> e : entries.entrySet() ) {
 68  2
         keyValues.add(new AtomKeyValue(e));
 69  2
       }
 70  2
       entry = keyValues;
 71  2
     } else {
 72  2
       this.value = value;
 73  
     }
 74  4
   }
 75  
 
 76  
 }