Coverage Report - org.jtheque.core.managers.persistence.AbstractEntity
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractEntity
50 %
6/12
0 %
0/2
1.2
 
 1  
 package org.jtheque.core.managers.persistence;
 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.persistence.able.Entity;
 20  
 import org.jtheque.core.managers.persistence.context.TemporaryContext;
 21  
 
 22  
 /**
 23  
  * Represents a persisted object of JTheque.
 24  
  *
 25  
  * @author Baptiste Wicht
 26  
  */
 27  0
 public abstract class AbstractEntity implements Entity {
 28  
     private int id;
 29  
 
 30  
     private final TemporaryContext temporaryContext;
 31  
 
 32  
     protected static final int HASHCODE_PRIME = 31;
 33  
 
 34  
     /**
 35  
      * Construct a new Entity.
 36  
      */
 37  
     public AbstractEntity() {
 38  16
         super();
 39  
 
 40  16
         temporaryContext = new TemporaryContext();
 41  16
     }
 42  
 
 43  
     @Override
 44  
     public TemporaryContext getTemporaryContext() {
 45  0
         return temporaryContext;
 46  
     }
 47  
 
 48  
     @Override
 49  
     public final int getId() {
 50  120
         return id;
 51  
     }
 52  
 
 53  
     @Override
 54  
     public final void setId(int id) {
 55  16
         this.id = id;
 56  16
     }
 57  
 
 58  
     @Override
 59  
     public final int compareTo(Entity object) {
 60  0
         return getDisplayableText().compareTo(object.getDisplayableText());
 61  
     }
 62  
 
 63  
     @Override
 64  
     public abstract boolean equals(Object object);
 65  
 
 66  
     @Override
 67  
     public abstract int hashCode();
 68  
 
 69  
     @Override
 70  
     public final boolean isSaved() {
 71  0
         return id != 0;
 72  
     }
 73  
 
 74  
     @Override
 75  
     public void saveToMemento() {
 76  0
         throw new UnsupportedOperationException();
 77  
     }
 78  
 
 79  
     @Override
 80  
     public void restoreMemento() {
 81  0
         throw new UnsupportedOperationException();
 82  
     }
 83  
 }