Coverage Report - org.jtheque.core.managers.update.versions.OnlineVersion
 
Classes in this File Line Coverage Branch Coverage Complexity
OnlineVersion
0 %
0/32
0 %
0/18
1.923
 
 1  
 package org.jtheque.core.managers.update.versions;
 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.patch.OnlinePatch;
 20  
 import org.jtheque.core.managers.update.actions.UpdateAction;
 21  
 import org.jtheque.utils.Constants;
 22  
 import org.jtheque.utils.bean.EqualsUtils;
 23  
 import org.jtheque.utils.bean.Version;
 24  
 import org.jtheque.utils.collections.CollectionUtils;
 25  
 
 26  
 import java.util.Collection;
 27  
 
 28  
 /**
 29  
  * An online version of JTheque.
 30  
  *
 31  
  * @author Baptiste Wicht
 32  
  */
 33  0
 public class OnlineVersion implements Comparable<OnlineVersion> {
 34  
     private Version version;
 35  
     private Version coreVersion;
 36  
     private Collection<UpdateAction> actions;
 37  
     private Collection<OnlinePatch> patches;
 38  
 
 39  
     /**
 40  
      * Return the JTheque's version.
 41  
      *
 42  
      * @return The JTheque's version.
 43  
      */
 44  
     public final Version getVersion() {
 45  0
         return version;
 46  
     }
 47  
 
 48  
     /**
 49  
      * Set the JTheque's version.
 50  
      *
 51  
      * @param version The JTheque's version.
 52  
      */
 53  
     public final void setVersion(Version version) {
 54  0
         this.version = version;
 55  0
     }
 56  
 
 57  
     /**
 58  
      * Return the actions to be executed when updating to this version.
 59  
      *
 60  
      * @return A list containing all the actions.
 61  
      */
 62  
     public final Collection<UpdateAction> getActions() {
 63  0
         return actions;
 64  
     }
 65  
 
 66  
     /**
 67  
      * Set the actions to be executed when updating to this version.
 68  
      *
 69  
      * @param actions A list containing all the actions.
 70  
      */
 71  
     public final void setActions(Collection<UpdateAction> actions) {
 72  0
         this.actions = CollectionUtils.copyOf(actions);
 73  0
     }
 74  
 
 75  
     /**
 76  
      * Return the version transformed to string.
 77  
      *
 78  
      * @return The string version.
 79  
      */
 80  
     public final String getStringVersion() {
 81  0
         return version.getVersion();
 82  
     }
 83  
 
 84  
     /**
 85  
      * Return the patches of the OnlineVersion.
 86  
      *
 87  
      * @return A List containing all the patches of the version.
 88  
      */
 89  
     public final Collection<OnlinePatch> getPatches() {
 90  0
         return patches;
 91  
     }
 92  
 
 93  
     /**
 94  
      * Set the versions of the OnlineVersion.
 95  
      *
 96  
      * @param patches A List containing all the patches of the version.
 97  
      */
 98  
     public final void setPatches(Collection<OnlinePatch> patches) {
 99  0
         this.patches = CollectionUtils.copyOf(patches);
 100  0
     }
 101  
 
 102  
     @Override
 103  
     public final int compareTo(OnlineVersion o) {
 104  0
         return version.compareTo(o.version);
 105  
     }
 106  
 
 107  
     /**
 108  
      * Return the necessary version of the core.
 109  
      *
 110  
      * @return The needed core version.
 111  
      */
 112  
     public final Version getCoreVersion() {
 113  0
         return coreVersion;
 114  
     }
 115  
 
 116  
     /**
 117  
      * Set the version of the core for this version.
 118  
      *
 119  
      * @param coreVersion The needed version of the core for this module.
 120  
      */
 121  
     public final void setCoreVersion(Version coreVersion) {
 122  0
         this.coreVersion = coreVersion;
 123  0
     }
 124  
 
 125  
     @Override
 126  
     public final boolean equals(Object o) {
 127  0
         if (EqualsUtils.areObjectIncompatible(this, o)) {
 128  0
             return false;
 129  
         }
 130  
 
 131  0
         OnlineVersion that = (OnlineVersion) o;
 132  
 
 133  0
         if (EqualsUtils.areNotEquals(actions, that.actions)) {
 134  0
             return false;
 135  
         }
 136  
 
 137  0
         if (EqualsUtils.areNotEquals(coreVersion, that.coreVersion)) {
 138  0
             return false;
 139  
         }
 140  
 
 141  0
         if (EqualsUtils.areNotEquals(patches, that.patches)) {
 142  0
             return false;
 143  
         }
 144  
 
 145  0
         return !EqualsUtils.areNotEquals(version, that.version);
 146  
     }
 147  
 
 148  
     @Override
 149  
     public final int hashCode() {
 150  0
         int result = Constants.HASH_CODE_START;
 151  
 
 152  0
         result = Constants.HASH_CODE_PRIME * result + (version == null ? 0 : version.hashCode());
 153  0
         result = Constants.HASH_CODE_PRIME * result + (coreVersion == null ? 0 : coreVersion.hashCode());
 154  0
         result = Constants.HASH_CODE_PRIME * result + (actions == null ? 0 : actions.hashCode());
 155  0
         result = Constants.HASH_CODE_PRIME * result + (patches == null ? 0 : patches.hashCode());
 156  
 
 157  0
         return result;
 158  
     }
 159  
 
 160  
     @Override
 161  
     public String toString() {
 162  0
         return "OnlineVersion{" +
 163  
                 "version=" + version +
 164  
                 ", core=" + coreVersion +
 165  
                 ", actions=" + actions +
 166  
                 ", patches=" + patches +
 167  
                 '}';
 168  
     }
 169  
 }