Coverage Report - org.directdemocracyportal.democracy.model.core.Environment
 
Classes in this File Line Coverage Branch Coverage Complexity
Environment
11%
4/34
0%
0/22
3
 
 1  
 /*
 2  
 Copyright 2010 James Pether Sörling Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. 
 3  
         $Id
 4  
 */
 5  
 package org.directdemocracyportal.democracy.model.core;
 6  
 
 7  
 import java.util.HashSet;
 8  
 import java.util.Set;
 9  
 
 10  
 import javax.persistence.Entity;
 11  
 import javax.persistence.FetchType;
 12  
 import javax.persistence.GeneratedValue;
 13  
 import javax.persistence.GenerationType;
 14  
 import javax.persistence.Id;
 15  
 import javax.persistence.Inheritance;
 16  
 import javax.persistence.InheritanceType;
 17  
 import javax.persistence.ManyToMany;
 18  
 
 19  
 import org.hibernate.annotations.Cache;
 20  
 import org.hibernate.annotations.CacheConcurrencyStrategy;
 21  
 
 22  
 /**
 23  
  * The Class Environment.
 24  
  */
 25  
 @Entity
 26  
 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
 27  
 @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
 28  
 public abstract class Environment extends BaseEntity
 29  
 {
 30  
 
 31  
     /** The id. */
 32  
     private Long id;
 33  
 
 34  
     /** The name. */
 35  
     private String name;
 36  
 
 37  
     /** The agents. */
 38  3
     private Set<Agent> agents = new HashSet<Agent>();
 39  
 
 40  
     /**
 41  
      * Instantiates a new environment.
 42  
      */
 43  3
     public Environment() {
 44  3
     }
 45  
 
 46  
     /*
 47  
      * (non-Javadoc)
 48  
      *
 49  
      * @see org.directdemocracyportal.democracy.model.core.BaseEntity#getId()
 50  
      */
 51  
     @Override
 52  
     @Id
 53  
     @GeneratedValue(strategy = GenerationType.AUTO)
 54  
     public Long getId() {
 55  3
         return this.id;
 56  
     }
 57  
 
 58  
     /**
 59  
      * Sets the id.
 60  
      *
 61  
      * @param id the new id
 62  
      */
 63  
     public void setId(Long id) {
 64  0
         this.id = id;
 65  0
     }
 66  
 
 67  
     /**
 68  
      * Gets the name.
 69  
      *
 70  
      * @return the name
 71  
      */
 72  
     public String getName() {
 73  0
         return name;
 74  
     }
 75  
 
 76  
     /**
 77  
      * Sets the name.
 78  
      *
 79  
      * @param name the new name
 80  
      */
 81  
     public void setName(String name) {
 82  0
         this.name = name;
 83  0
     }
 84  
 
 85  
     /**
 86  
      * Gets the agents.
 87  
      *
 88  
      * @return the agents
 89  
      */
 90  
     @ManyToMany(fetch = FetchType.LAZY)
 91  
     public Set<Agent> getAgents() {
 92  0
         return agents;
 93  
     }
 94  
 
 95  
     /**
 96  
      * Sets the agents.
 97  
      *
 98  
      * @param agents the new agents
 99  
      */
 100  
     public void setAgents(Set<Agent> agents) {
 101  0
         this.agents = agents;
 102  0
     }
 103  
 
 104  
     /*
 105  
      * (non-Javadoc)
 106  
      *
 107  
      * @see java.lang.Object#hashCode()
 108  
      */
 109  
     @Override
 110  
     public int hashCode() {
 111  
         final int prime = 31;
 112  0
         int result = 1;
 113  0
         result = prime * result + ((id == null) ? 0 : id.hashCode());
 114  0
         result = prime * result + ((name == null) ? 0 : name.hashCode());
 115  0
         return result;
 116  
     }
 117  
 
 118  
     /*
 119  
      * (non-Javadoc)
 120  
      *
 121  
      * @see java.lang.Object#equals(java.lang.Object)
 122  
      */
 123  
     @Override
 124  
     public boolean equals(Object obj) {
 125  0
         if (this == obj)
 126  0
             return true;
 127  0
         if (obj == null)
 128  0
             return false;
 129  0
         if (getClass() != obj.getClass())
 130  0
             return false;
 131  0
         final Environment other = (Environment) obj;
 132  0
         if (id == null) {
 133  0
             if (other.id != null)
 134  0
                 return false;
 135  0
         } else if (!id.equals(other.id))
 136  0
             return false;
 137  0
         if (name == null) {
 138  0
             if (other.name != null)
 139  0
                 return false;
 140  0
         } else if (!name.equals(other.name))
 141  0
             return false;
 142  0
         return true;
 143  
     }
 144  
 }