Coverage Report - org.jtheque.films.persistence.od.FilmImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
FilmImpl
0 %
0/58
0 %
0/56
2.944
 
 1  
 package org.jtheque.films.persistence.od;
 2  
 
 3  
 /*
 4  
  * This file is part of JTheque.
 5  
  *
 6  
  * JTheque is free software: you can redistribute it and/or modify
 7  
  * it under the terms of the GNU General Public License as published by
 8  
  * the Free Software Foundation, either version 3 of the License.
 9  
  *
 10  
  * JTheque is distributed in the hope that it will be useful,
 11  
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 12  
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 13  
  * GNU General Public License for more details.
 14  
  *
 15  
  * You should have received a copy of the GNU General Public License
 16  
  * along with JTheque.  If not, see <http://www.gnu.org/licenses/>.
 17  
  */
 18  
 
 19  
 import org.jtheque.core.managers.Managers;
 20  
 import org.jtheque.core.managers.resource.IResourceManager;
 21  
 import org.jtheque.core.managers.resource.ImageType;
 22  
 import org.jtheque.core.managers.properties.IPropertiesManager;
 23  
 import org.jtheque.films.persistence.od.abstraction.Film;
 24  
 import org.jtheque.films.persistence.od.temp.FilmTemporaryContext;
 25  
 import org.jtheque.films.utils.Constants;
 26  
 import org.jtheque.utils.EqualsUtils;
 27  
 
 28  
 import javax.swing.Icon;
 29  
 
 30  
 /**
 31  
  * Cette classe repr�sente un film et toutes ses donn�es.
 32  
  *
 33  
  * @author Baptiste Wicht
 34  
  */
 35  0
 public final class FilmImpl extends Film {
 36  
     private FilmImpl memento;
 37  
     private boolean mementoState;
 38  
 
 39  
     private final FilmTemporaryContext temporaryContext;
 40  
 
 41  
     /**
 42  
      * Construct a new FilmImpl.
 43  
      */
 44  
     public FilmImpl() {
 45  0
         super();
 46  
 
 47  0
         temporaryContext = new FilmTemporaryContext();
 48  0
     }
 49  
 
 50  
     @Override
 51  
     public FilmTemporaryContext getTemporaryContext() {
 52  0
         return temporaryContext;
 53  
     }
 54  
 
 55  
     @Override
 56  
     public String getAffichableText() {
 57  0
         return getTitle();
 58  
     }
 59  
 
 60  
     @Override
 61  
     public String toString() {
 62  0
         return getAffichableText();
 63  
     }
 64  
 
 65  
     @Override
 66  
     public int hashCode() {
 67  0
         return Managers.getManager(IPropertiesManager.class).hashCode(this);
 68  
     }
 69  
 
 70  
     @Override
 71  
     public boolean equals(Object obj) {
 72  0
         if (this == obj) {
 73  0
             return true;
 74  
         }
 75  
 
 76  0
         if(EqualsUtils.areObjectIncompatible(this, obj)){
 77  0
             return false;
 78  
         }
 79  
 
 80  0
         final Film other = (Film) obj;
 81  
 
 82  0
         if(EqualsUtils.areNotEquals(getTitle(), other.getTitle())){
 83  0
             return false;
 84  
         }
 85  
 
 86  0
         if(EqualsUtils.areNotEquals(getActors(), other.getActors())){
 87  0
             return false;
 88  
         }
 89  
 
 90  0
         if(EqualsUtils.areNotEquals(getYear(), other.getYear())){
 91  0
             return false;
 92  
         }
 93  
 
 94  0
         if(EqualsUtils.areNotEquals(getKinds(), other.getKinds())){
 95  0
             return false;
 96  
         }
 97  
 
 98  0
         if(EqualsUtils.areNotEquals(getComment(), other.getComment())){
 99  0
             return false;
 100  
         }
 101  
 
 102  0
         if(EqualsUtils.areNotEquals(getDuration(), other.getDuration())){
 103  0
             return false;
 104  
         }
 105  
 
 106  0
         if(EqualsUtils.areNotEquals(getDuration(), other.getDuration())){
 107  0
             return false;
 108  
         }
 109  
 
 110  0
         if(EqualsUtils.areNotEquals(getTheLending(), other.getTheLending())){
 111  0
             return false;
 112  
         }
 113  
 
 114  0
         if(EqualsUtils.areNotEquals(getImage(), other.getImage())){
 115  0
             return false;
 116  
         }
 117  
 
 118  0
         if(EqualsUtils.areNotEquals(getTheLanguage(), other.getTheLanguage())){
 119  0
             return false;
 120  
         }
 121  
 
 122  0
         if(EqualsUtils.areNotEquals(getNote(), other.getNote())){
 123  0
             return false;
 124  
         }
 125  
 
 126  0
         if(EqualsUtils.areNotEquals(getTheRealizer(), other.getTheRealizer())){
 127  0
             return false;
 128  
         }
 129  
 
 130  0
         if(EqualsUtils.areNotEquals(getResume(), other.getResume())){
 131  0
             return false;
 132  
         }
 133  
 
 134  0
         return !EqualsUtils.areNotEquals(getTheType(), other.getTheType());
 135  
 
 136  
     }
 137  
 
 138  
     @Override
 139  
     public Icon getIcon() {
 140  0
         return Managers.getManager(IResourceManager.class).getIcon(Constants.IMAGE_BASENAME, Constants.FILM_ICON, ImageType.PNG);
 141  
     }
 142  
 
 143  
     @Override
 144  
     public void saveToMemento() {
 145  0
         mementoState = true;
 146  
 
 147  0
         memento = Managers.getManager(IPropertiesManager.class).createMemento(this);
 148  
 
 149  0
         if (memento == null) {
 150  0
             mementoState = false;
 151  
         }
 152  0
     }
 153  
 
 154  
     @Override
 155  
     public void restoreMemento() {
 156  0
         if (mementoState) {
 157  0
             Managers.getManager(IPropertiesManager.class).restoreMemento(this, memento);
 158  
         }
 159  0
     }
 160  
 
 161  
     /**
 162  
      * Indicate if the film is in lending or not.
 163  
      *
 164  
      * @return <code>true</code> if the film has a lending else <code>false</code>
 165  
      */
 166  
     public boolean hasLending() {
 167  0
         return getTheLending() != null;
 168  
     }
 169  
 
 170  
     /**
 171  
      * Indicate if the film is in lending or not.
 172  
      *
 173  
      * @return <code>true</code> if the film has a lending else <code>false</code>
 174  
      */
 175  
     public boolean hasType() {
 176  0
         return getTheType() != null;
 177  
     }
 178  
 
 179  
     /**
 180  
      * Indicate if the film has kinds or not.
 181  
      *
 182  
      * @return <code>true</code> if the film has kinds else <code>false</code>
 183  
      */
 184  
     public boolean hasKinds() {
 185  0
         return getKinds().isEmpty();
 186  
     }
 187  
 
 188  
     /**
 189  
      * Indicate if the film has actors or not.
 190  
      *
 191  
      * @return <code>true</code> if the film has actors else <code>false</code>
 192  
      */
 193  
     public boolean hasActors() {
 194  0
         return getActors().isEmpty();
 195  
     }
 196  
 
 197  
     /**
 198  
      * Indicate if the film has a language or not.
 199  
      *
 200  
      * @return <code>true</code> if the film has a language else <code>false</code>
 201  
      */
 202  
     public boolean hasLanguage() {
 203  0
         return getTheLanguage() != null;
 204  
     }
 205  
 
 206  
     /**
 207  
      * Indicate if the film has a realizer or not.
 208  
      *
 209  
      * @return <code>true</code> if the film has a realizer else <code>false</code>
 210  
      */
 211  
     public boolean hasRealizer() {
 212  0
         return getTheRealizer() != null;
 213  
     }
 214  
 
 215  
     /**
 216  
      * Indicate if the film has a resume or not.
 217  
      *
 218  
      * @return <code>true</code> if the film has a resume else <code>false</code>
 219  
      */
 220  
     public boolean hasResume() {
 221  0
         return getResume() != null && !getResume().isEmpty();
 222  
     }
 223  
 
 224  
     /**
 225  
      * Indicate if the film has a comment or not.
 226  
      *
 227  
      * @return <code>true</code> if the film has a comment else <code>false</code>
 228  
      */
 229  
     public boolean hasComment() {
 230  0
         return getComment() != null && !getComment().isEmpty();
 231  
     }
 232  
 
 233  
     /**
 234  
      * Indicate if the film has an image or not.
 235  
      *
 236  
      * @return <code>true</code> if the film has an image else <code>false</code>
 237  
      */
 238  
     public boolean hasImage() {
 239  0
         return getImage() != null && !getImage().isEmpty();
 240  
     }
 241  
 }