Coverage Report - org.apache.shindig.social.core.model.PersonImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
PersonImpl
96%
213/222
79%
19/24
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.model;
 19  
 
 20  
 import org.apache.shindig.social.opensocial.model.Account;
 21  
 import org.apache.shindig.social.opensocial.model.Address;
 22  
 import org.apache.shindig.social.opensocial.model.BodyType;
 23  
 import org.apache.shindig.social.opensocial.model.Enum;
 24  
 import org.apache.shindig.social.opensocial.model.ListField;
 25  
 import org.apache.shindig.social.opensocial.model.Name;
 26  
 import org.apache.shindig.social.opensocial.model.Organization;
 27  
 import org.apache.shindig.social.opensocial.model.Person;
 28  
 import org.apache.shindig.social.opensocial.model.Url;
 29  
 
 30  
 import com.google.common.collect.Lists;
 31  
 
 32  
 import java.util.Date;
 33  
 import java.util.List;
 34  
 
 35  
 /**
 36  
  * Default Implementation of the Person object in the model.
 37  
  */
 38  
 public class PersonImpl implements Person {
 39  
   private String aboutMe;
 40  
   private List<Account> accounts;
 41  
   private List<String> activities;
 42  
   private List<Address> addresses;
 43  
   private Integer age;
 44  
   private Date birthday;
 45  
   private BodyType bodyType;
 46  
   private List<String> books;
 47  
   private List<String> cars;
 48  
   private String children;
 49  
   private Address currentLocation;
 50  
   private String displayName;
 51  
   private Enum<Enum.Drinker> drinker;
 52  
   private List<ListField> emails;
 53  
   private String ethnicity;
 54  
   private String fashion;
 55  
   private List<String> food;
 56  
   private Gender gender;
 57  
   private String happiestWhen;
 58  
   private Boolean hasApp;
 59  
   private List<String> heroes;
 60  
   private String humor;
 61  
   private String id;
 62  
   private List<ListField> ims;
 63  
   private List<String> interests;
 64  
   private String jobInterests;
 65  
   private List<String> languagesSpoken;
 66  
   private String livingArrangement;
 67  
   private List<Enum<Enum.LookingFor>> lookingFor;
 68  
   private List<String> movies;
 69  
   private List<String> music;
 70  
   private Name name;
 71  
   private Enum<Enum.NetworkPresence> networkPresence;
 72  
   private String nickname;
 73  
   private List<Organization> organizations;
 74  
   private String pets;
 75  
   private List<ListField> phoneNumbers;
 76  
   private List<ListField> photos;
 77  
   private String politicalViews;
 78  
   private Url profileSong;
 79  
   private Url profileVideo;
 80  
   private List<String> quotes;
 81  
   private String relationshipStatus;
 82  
   private String religion;
 83  
   private String romance;
 84  
   private String scaredOf;
 85  
   private String sexualOrientation;
 86  
   private Enum<Enum.Smoker> smoker;
 87  
   private List<String> sports;
 88  
   private String status;
 89  
   private List<String> tags;
 90  
   private Long utcOffset;
 91  
   private List<String> turnOffs;
 92  
   private List<String> turnOns;
 93  
   private List<String> tvShows;
 94  
   private Date updated;
 95  
   private List<Url> urls;
 96  
 
 97  
   // Note: Not in the opensocial js person object directly
 98  86
   private boolean isOwner = false;
 99  86
   private boolean isViewer = false;
 100  
 
 101  38
   public PersonImpl() {
 102  38
   }
 103  
 
 104  
   /**
 105  
    * A constructor which contains all of the required fields on a person object
 106  
    * @param id The id of the person
 107  
    * @param displayName The displayName of the person
 108  
    * @param name The person's name broken down into components
 109  
    */
 110  48
   public PersonImpl(String id, String displayName, Name name) {
 111  48
     this.id = id;
 112  48
     this.displayName = displayName;
 113  48
     this.name = name;
 114  48
   }
 115  
 
 116  
   public String getAboutMe() {
 117  22
     return aboutMe;
 118  
   }
 119  
 
 120  
   public void setAboutMe(String aboutMe) {
 121  9
     this.aboutMe = aboutMe;
 122  9
   }
 123  
 
 124  
   public List<Account> getAccounts() {
 125  19
     return accounts;
 126  
   }
 127  
 
 128  
   public void setAccounts(List<Account> accounts) {
 129  0
     this.accounts = accounts;
 130  0
   }
 131  
 
 132  
   public List<String> getActivities() {
 133  21
     return activities;
 134  
   }
 135  
 
 136  
   public void setActivities(List<String> activities) {
 137  9
     this.activities = activities;
 138  9
   }
 139  
 
 140  
   public List<Address> getAddresses() {
 141  26
     return addresses;
 142  
   }
 143  
 
 144  
   public void setAddresses(List<Address> addresses) {
 145  50
     this.addresses = addresses;
 146  50
   }
 147  
 
 148  
   public Integer getAge() {
 149  22
     return age;
 150  
   }
 151  
 
 152  
   public void setAge(Integer age) {
 153  10
     this.age = age;
 154  10
   }
 155  
 
 156  
   public BodyType getBodyType() {
 157  21
     return bodyType;
 158  
   }
 159  
 
 160  
   public void setBodyType(BodyType bodyType) {
 161  9
     this.bodyType = bodyType;
 162  9
   }
 163  
 
 164  
   public List<String> getBooks() {
 165  21
     return books;
 166  
   }
 167  
 
 168  
   public void setBooks(List<String> books) {
 169  9
     this.books = books;
 170  9
   }
 171  
 
 172  
   public List<String> getCars() {
 173  21
     return cars;
 174  
   }
 175  
 
 176  
   public void setCars(List<String> cars) {
 177  9
     this.cars = cars;
 178  9
   }
 179  
 
 180  
   public String getChildren() {
 181  21
     return children;
 182  
   }
 183  
 
 184  
   public void setChildren(String children) {
 185  9
     this.children = children;
 186  9
   }
 187  
 
 188  
   public Address getCurrentLocation() {
 189  23
     return currentLocation;
 190  
   }
 191  
 
 192  
   public void setCurrentLocation(Address currentLocation) {
 193  9
     this.currentLocation = currentLocation;
 194  9
   }
 195  
 
 196  
   public Date getBirthday() {
 197  19
     if (birthday == null) {
 198  17
       return null;
 199  
     }
 200  2
     return new Date(birthday.getTime());
 201  
   }
 202  
 
 203  
   public void setBirthday(Date birthday) {
 204  9
     if (birthday == null) {
 205  0
       this.birthday = null;
 206  0
     } else {
 207  9
       this.birthday = new Date(birthday.getTime());
 208  
     }
 209  9
   }
 210  
 
 211  
   public String getDisplayName() {
 212  22
     return displayName;
 213  
   }
 214  
 
 215  
   public void setDisplayName(String displayName) {
 216  14
     this.displayName = displayName;
 217  14
   }
 218  
 
 219  
   public Enum<Enum.Drinker> getDrinker() {
 220  19
     return this.drinker;
 221  
   }
 222  
 
 223  
   public void setDrinker(Enum<Enum.Drinker> newDrinker) {
 224  9
     this.drinker = newDrinker;
 225  9
   }
 226  
 
 227  
   public List<ListField> getEmails() {
 228  38
     return emails;
 229  
   }
 230  
 
 231  
   public void setEmails(List<ListField> emails) {
 232  50
     this.emails = emails;
 233  50
   }
 234  
 
 235  
   public String getEthnicity() {
 236  21
     return ethnicity;
 237  
   }
 238  
 
 239  
   public void setEthnicity(String ethnicity) {
 240  9
     this.ethnicity = ethnicity;
 241  9
   }
 242  
 
 243  
   public String getFashion() {
 244  21
     return fashion;
 245  
   }
 246  
 
 247  
   public void setFashion(String fashion) {
 248  9
     this.fashion = fashion;
 249  9
   }
 250  
 
 251  
   public List<String> getFood() {
 252  21
     return food;
 253  
   }
 254  
 
 255  
   public void setFood(List<String> food) {
 256  9
     this.food = food;
 257  9
   }
 258  
 
 259  
   public Gender getGender() {
 260  21
     return gender;
 261  
   }
 262  
 
 263  
   public void setGender(Gender newGender) {
 264  18
     this.gender = newGender;
 265  18
   }
 266  
 
 267  
   public String getHappiestWhen() {
 268  21
     return happiestWhen;
 269  
   }
 270  
 
 271  
   public void setHappiestWhen(String happiestWhen) {
 272  9
     this.happiestWhen = happiestWhen;
 273  9
   }
 274  
 
 275  
   public Boolean getHasApp() {
 276  22
     return hasApp;
 277  
   }
 278  
 
 279  
   public void setHasApp(Boolean hasApp) {
 280  18
     this.hasApp = hasApp;
 281  18
   }
 282  
 
 283  
   public List<String> getHeroes() {
 284  21
     return heroes;
 285  
   }
 286  
 
 287  
   public void setHeroes(List<String> heroes) {
 288  9
     this.heroes = heroes;
 289  9
   }
 290  
 
 291  
   public String getHumor() {
 292  21
     return humor;
 293  
   }
 294  
 
 295  
   public void setHumor(String humor) {
 296  9
     this.humor = humor;
 297  9
   }
 298  
 
 299  
   public String getId() {
 300  77
     return id;
 301  
   }
 302  
 
 303  
   public void setId(String id) {
 304  33
     this.id = id;
 305  33
   }
 306  
 
 307  
   public List<ListField> getIms() {
 308  19
     return ims;
 309  
   }
 310  
 
 311  
   public void setIms(List<ListField> ims) {
 312  0
     this.ims = ims;
 313  0
   }
 314  
 
 315  
   public List<String> getInterests() {
 316  21
     return interests;
 317  
   }
 318  
 
 319  
   public void setInterests(List<String> interests) {
 320  9
     this.interests = interests;
 321  9
   }
 322  
 
 323  
   public String getJobInterests() {
 324  21
     return jobInterests;
 325  
   }
 326  
 
 327  
   public void setJobInterests(String jobInterests) {
 328  9
     this.jobInterests = jobInterests;
 329  9
   }
 330  
 
 331  
   public List<String> getLanguagesSpoken() {
 332  21
     return languagesSpoken;
 333  
   }
 334  
 
 335  
   public void setLanguagesSpoken(List<String> languagesSpoken) {
 336  9
     this.languagesSpoken = languagesSpoken;
 337  9
   }
 338  
 
 339  
   public Date getUpdated() {
 340  20
     if (updated == null) {
 341  18
       return null;
 342  
     }
 343  2
     return new Date(updated.getTime());
 344  
   }
 345  
 
 346  
   public void setUpdated(Date updated) {
 347  9
     if (updated == null) {
 348  0
       this.updated = null;
 349  0
     } else {
 350  9
       this.updated = new Date(updated.getTime());
 351  
     }
 352  9
   }
 353  
 
 354  
   public String getLivingArrangement() {
 355  21
     return livingArrangement;
 356  
   }
 357  
 
 358  
   public void setLivingArrangement(String livingArrangement) {
 359  9
     this.livingArrangement = livingArrangement;
 360  9
   }
 361  
 
 362  
   public List<Enum<Enum.LookingFor>> getLookingFor() {
 363  21
     return lookingFor;
 364  
   }
 365  
 
 366  
   public void setLookingFor(List<Enum<Enum.LookingFor>> lookingFor) {
 367  9
     this.lookingFor = lookingFor;
 368  9
   }
 369  
 
 370  
   public List<String> getMovies() {
 371  21
     return movies;
 372  
   }
 373  
 
 374  
   public void setMovies(List<String> movies) {
 375  9
     this.movies = movies;
 376  9
   }
 377  
 
 378  
   public List<String> getMusic() {
 379  21
     return music;
 380  
   }
 381  
 
 382  
   public void setMusic(List<String> music) {
 383  9
     this.music = music;
 384  9
   }
 385  
 
 386  
   public Name getName() {
 387  51
     return name;
 388  
   }
 389  
 
 390  
   public void setName(Name name) {
 391  33
     this.name = name;
 392  33
   }
 393  
 
 394  
   public Enum<Enum.NetworkPresence> getNetworkPresence() {
 395  21
     return networkPresence;
 396  
   }
 397  
 
 398  
   public void setNetworkPresence(Enum<Enum.NetworkPresence> networkPresence) {
 399  9
     this.networkPresence = networkPresence;
 400  9
   }
 401  
 
 402  
   public String getNickname() {
 403  21
     return nickname;
 404  
   }
 405  
 
 406  
   public void setNickname(String nickname) {
 407  9
     this.nickname = nickname;
 408  9
   }
 409  
 
 410  
   public List<Organization> getOrganizations() {
 411  21
     return organizations;
 412  
   }
 413  
 
 414  
   public void setOrganizations(List<Organization> organizations) {
 415  9
     this.organizations = organizations;
 416  9
   }
 417  
 
 418  
   public String getPets() {
 419  21
     return pets;
 420  
   }
 421  
 
 422  
   public void setPets(String pets) {
 423  9
     this.pets = pets;
 424  9
   }
 425  
 
 426  
   public List<ListField> getPhoneNumbers() {
 427  49
     return phoneNumbers;
 428  
   }
 429  
 
 430  
   public void setPhoneNumbers(List<ListField> phoneNumbers) {
 431  50
     this.phoneNumbers = phoneNumbers;
 432  50
   }
 433  
 
 434  
   public List<ListField> getPhotos() {
 435  71
     return photos;
 436  
   }
 437  
 
 438  
   public void setPhotos(List<ListField> photos) {
 439  11
     this.photos = photos;
 440  11
   }
 441  
 
 442  
   public String getPoliticalViews() {
 443  21
     return politicalViews;
 444  
   }
 445  
 
 446  
   public void setPoliticalViews(String politicalViews) {
 447  9
     this.politicalViews = politicalViews;
 448  9
   }
 449  
 
 450  
   public Url getProfileSong() {
 451  21
     return profileSong;
 452  
   }
 453  
 
 454  
   public void setProfileSong(Url profileSong) {
 455  9
     this.profileSong = profileSong;
 456  9
   }
 457  
 
 458  
   public Url getProfileVideo() {
 459  21
     return profileVideo;
 460  
   }
 461  
 
 462  
   public void setProfileVideo(Url profileVideo) {
 463  9
     this.profileVideo = profileVideo;
 464  9
   }
 465  
 
 466  
   public List<String> getQuotes() {
 467  21
     return quotes;
 468  
   }
 469  
 
 470  
   public void setQuotes(List<String> quotes) {
 471  9
     this.quotes = quotes;
 472  9
   }
 473  
 
 474  
   public String getRelationshipStatus() {
 475  21
     return relationshipStatus;
 476  
   }
 477  
 
 478  
   public void setRelationshipStatus(String relationshipStatus) {
 479  9
     this.relationshipStatus = relationshipStatus;
 480  9
   }
 481  
 
 482  
   public String getReligion() {
 483  21
     return religion;
 484  
   }
 485  
 
 486  
   public void setReligion(String religion) {
 487  9
     this.religion = religion;
 488  9
   }
 489  
 
 490  
   public String getRomance() {
 491  21
     return romance;
 492  
   }
 493  
 
 494  
   public void setRomance(String romance) {
 495  9
     this.romance = romance;
 496  9
   }
 497  
 
 498  
   public String getScaredOf() {
 499  21
     return scaredOf;
 500  
   }
 501  
 
 502  
   public void setScaredOf(String scaredOf) {
 503  9
     this.scaredOf = scaredOf;
 504  9
   }
 505  
 
 506  
   public String getSexualOrientation() {
 507  21
     return sexualOrientation;
 508  
   }
 509  
 
 510  
   public void setSexualOrientation(String sexualOrientation) {
 511  9
     this.sexualOrientation = sexualOrientation;
 512  9
   }
 513  
 
 514  
   public Enum<Enum.Smoker> getSmoker() {
 515  21
     return this.smoker;
 516  
   }
 517  
 
 518  
   public void setSmoker(Enum<Enum.Smoker> newSmoker) {
 519  9
     this.smoker = newSmoker;
 520  9
   }
 521  
 
 522  
   public List<String> getSports() {
 523  21
     return sports;
 524  
   }
 525  
 
 526  
   public void setSports(List<String> sports) {
 527  9
     this.sports = sports;
 528  9
   }
 529  
 
 530  
   public String getStatus() {
 531  21
     return status;
 532  
   }
 533  
 
 534  
   public void setStatus(String status) {
 535  9
     this.status = status;
 536  9
   }
 537  
 
 538  
   public List<String> getTags() {
 539  21
     return tags;
 540  
   }
 541  
 
 542  
   public void setTags(List<String> tags) {
 543  9
     this.tags = tags;
 544  9
   }
 545  
 
 546  
   public Long getUtcOffset() {
 547  19
     return utcOffset;
 548  
   }
 549  
 
 550  
   public void setUtcOffset(Long utcOffset) {
 551  9
     this.utcOffset = utcOffset;
 552  9
   }
 553  
 
 554  
   public List<String> getTurnOffs() {
 555  21
     return turnOffs;
 556  
   }
 557  
 
 558  
   public void setTurnOffs(List<String> turnOffs) {
 559  9
     this.turnOffs = turnOffs;
 560  9
   }
 561  
 
 562  
   public List<String> getTurnOns() {
 563  21
     return turnOns;
 564  
   }
 565  
 
 566  
   public void setTurnOns(List<String> turnOns) {
 567  9
     this.turnOns = turnOns;
 568  9
   }
 569  
 
 570  
   public List<String> getTvShows() {
 571  21
     return tvShows;
 572  
   }
 573  
 
 574  
   public void setTvShows(List<String> tvShows) {
 575  9
     this.tvShows = tvShows;
 576  9
   }
 577  
 
 578  
   public List<Url> getUrls() {
 579  54
     return urls;
 580  
   }
 581  
 
 582  
   public void setUrls(List<Url> urls) {
 583  10
     this.urls = urls;
 584  10
   }
 585  
 
 586  
   public boolean getIsOwner() {
 587  12
     return isOwner;
 588  
   }
 589  
 
 590  
   public void setIsOwner(boolean isOwner) {
 591  2
     this.isOwner = isOwner;
 592  2
   }
 593  
 
 594  
   public boolean getIsViewer() {
 595  13
     return isViewer;
 596  
   }
 597  
 
 598  
   public void setIsViewer(boolean isViewer) {
 599  3
     this.isViewer = isViewer;
 600  3
   }
 601  
 
 602  
 
 603  
   // Proxied fields
 604  
 
 605  
   public String getProfileUrl() {
 606  24
     Url url = getListFieldWithType(PROFILE_URL_TYPE, getUrls());
 607  24
     return url == null ? null : url.getValue();
 608  
   }
 609  
 
 610  
   public void setProfileUrl(String profileUrl) {
 611  5
     Url url = getListFieldWithType(PROFILE_URL_TYPE, getUrls());
 612  5
     if (url != null) {
 613  4
       url.setValue(profileUrl);
 614  4
     } else {
 615  1
       setUrls(addListField(new UrlImpl(profileUrl, null, PROFILE_URL_TYPE), getUrls()));
 616  
     }
 617  5
   }
 618  
 
 619  
   public String getThumbnailUrl() {
 620  25
     ListField photo = getListFieldWithType(THUMBNAIL_PHOTO_TYPE, getPhotos());
 621  25
     return photo == null ? null : photo.getValue();
 622  
   }
 623  
 
 624  
   public void setThumbnailUrl(String thumbnailUrl) {
 625  12
     ListField photo = getListFieldWithType(THUMBNAIL_PHOTO_TYPE, getPhotos());
 626  12
     if (photo != null) {
 627  1
       photo.setValue(thumbnailUrl);
 628  1
     } else {
 629  11
       setPhotos(addListField(new ListFieldImpl(THUMBNAIL_PHOTO_TYPE, thumbnailUrl), getPhotos()));
 630  
     }
 631  12
   }
 632  
 
 633  
   private <T extends ListField> T getListFieldWithType(String type, List<T> list) {
 634  66
     if (list != null) {
 635  18
       for (T url : list) {
 636  18
         if (type.equalsIgnoreCase(url.getType())) {
 637  18
           return url;
 638  
         }
 639  0
       }
 640  
     }
 641  
 
 642  48
     return null;
 643  
   }
 644  
 
 645  
   private <T extends ListField> List<T> addListField(T field, List<T> list) {
 646  12
     if (list == null) {
 647  12
       list = Lists.newArrayList();
 648  
     }
 649  12
     list.add(field);
 650  12
     return list;
 651  
   }
 652  
 }