Coverage Report - net.sf.webphotos.model.AlbumVOBuilder
 
Classes in this File Line Coverage Branch Coverage Complexity
AlbumVOBuilder
0%
0/25
0%
0/4
1,222
 
 1  
 /**
 2  
  * Copyright 2008 WebPhotos
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *      http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package net.sf.webphotos.model;
 17  
 
 18  
 import java.util.Collection;
 19  
 import java.util.Date;
 20  
 import java.util.HashSet;
 21  
 import java.util.Iterator;
 22  
 
 23  
 /**
 24  
  * Builder for Entity AlbumVO
 25  
  * @author Guilherme
 26  
  */
 27  
 public class AlbumVOBuilder {
 28  
     
 29  
     private String nmalbum;
 30  
     private String descricao;
 31  
     private Date dtInsercao;
 32  
     private CategoryVO categoriasVO;
 33  
     private HashSet<PhotoVO> photoVOs;
 34  
     private Integer key;
 35  
 
 36  0
     AlbumVOBuilder() {
 37  0
         photoVOs = new HashSet<PhotoVO>();
 38  0
         key = 0;
 39  0
     }
 40  
 
 41  
     AlbumVOBuilder(Integer key) {
 42  0
         this();
 43  0
         this.key = key;
 44  0
     }
 45  
 
 46  
     public AlbumVOBuilder withAlbumName(String nmalbum) {
 47  0
         this.nmalbum = nmalbum;
 48  0
         return this;
 49  
     }
 50  
 
 51  
     public AlbumVOBuilder withDescription(String descricao) {
 52  0
         this.descricao = descricao;
 53  0
         return this;
 54  
     }
 55  
 
 56  
     public AlbumVOBuilder withCreationDate(Date dtInsercao) {
 57  0
         this.dtInsercao = dtInsercao;
 58  0
         return this;
 59  
     }
 60  
 
 61  
     public AlbumVOBuilder withCategory(CategoryVO categoriasVO) {
 62  0
         this.categoriasVO = categoriasVO;
 63  0
         return this;
 64  
     }
 65  
 
 66  
     public AlbumVOBuilder withPhoto(PhotoVO photoVO) {
 67  0
         this.photoVOs.add(photoVO);
 68  0
         return this;
 69  
     }
 70  
 
 71  
     public AlbumVOBuilder withPhotos(Collection<PhotoVO> photoVOs) {
 72  0
         this.photoVOs.addAll(photoVOs);
 73  0
         return this;
 74  
     }
 75  
 
 76  
     public AlbumVO build() {
 77  0
         final AlbumVO albumVO = (key > 0 ? 
 78  
                 new AlbumVO(key, nmalbum, descricao, dtInsercao, categoriasVO, photoVOs) : 
 79  
                 new AlbumVO(nmalbum, descricao, dtInsercao, categoriasVO, photoVOs));
 80  0
         for (Iterator<PhotoVO> it = photoVOs.iterator(); it.hasNext();) {
 81  0
             PhotoVO photoVO = it.next();
 82  0
             photoVO.setAlbum(albumVO);
 83  0
         }
 84  0
         return albumVO;
 85  
     }
 86  
     
 87  
 }