SpecificationVo.java
001 /* This file is part of the project "Hilbert II" - http://www.qedeq.org
002  *
003  * Copyright 2000-2011,  Michael Meyling <mime@qedeq.org>.
004  *
005  * "Hilbert II" is free software; you can redistribute
006  * it and/or modify it under the terms of the GNU General Public
007  * License as published by the Free Software Foundation; either
008  * version 2 of the License, or (at your option) any later version.
009  *
010  * This program is distributed in the hope that it will be useful,
011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013  * GNU General Public License for more details.
014  */
015 
016 package org.qedeq.kernel.se.dto.module;
017 
018 import org.qedeq.base.utility.EqualsUtility;
019 import org.qedeq.kernel.se.base.module.LocationList;
020 import org.qedeq.kernel.se.base.module.Specification;
021 
022 
023 /**
024  * Describes a specification of a module, that means its name, versions and possible
025  * "physical" locations.
026  * The combination of {@link #getName()} and {@link #getRuleVersion()} defines the
027  * file name of that module.
028  *
029  @author  Michael Meyling
030  */
031 public class SpecificationVo implements Specification {
032 
033     /** Module name. */
034     private String name;
035 
036     /** Rule version, that is needed to verify the module. */
037     private String ruleVersion;
038 
039     /** List of locations for the module. */
040     private LocationList locationList;
041 
042     /**
043      * Constructs a module specification. The combination of <code>name</code> and
044      <code>ruleVersion</code> defines the file name of that module.
045      *
046      @param   name        Module name.
047      @param   ruleVersion Rule version. This version is at least needed to verify that module.
048      @param   locations   List of locations for that module.
049      */
050     public SpecificationVo(final String name, final String ruleVersion,
051             final LocationList locations) {
052         this.name = name;
053         this.ruleVersion = ruleVersion;
054         this.locationList = locations;
055     }
056 
057     /**
058      * Constructs an empty module specification.
059      */
060     public SpecificationVo() {
061         // nothing to do
062     }
063 
064     public final void setName(final String name) {
065        this.name = name;
066     }
067 
068     public final String getName() {
069        return name;
070     }
071 
072     public final void setRuleVersion(final String ruleVersion) {
073         this.ruleVersion = ruleVersion;
074     }
075 
076     public final String getRuleVersion() {
077         return ruleVersion;
078     }
079 
080     /**
081      * Set list of locations for the module.
082      *
083      @param   locations   List of locations for that module.
084      */
085     public final void setLocationList(final LocationListVo locations) {
086         this.locationList = locations;
087     }
088 
089     public final LocationList getLocationList() {
090         return locationList;
091     }
092 
093     public boolean equals(final Object obj) {
094         if (!(obj instanceof SpecificationVo)) {
095             return false;
096         }
097         final SpecificationVo other = (SpecificationVoobj;
098         return  EqualsUtility.equals(getName(), other.getName())
099             &&  EqualsUtility.equals(getRuleVersion(), other.getRuleVersion())
100             &&  EqualsUtility.equals(getLocationList(), other.getLocationList());
101     }
102 
103     public int hashCode() {
104         return (getName() != null ? getName().hashCode() 0)
105             (getRuleVersion() != null ^ getRuleVersion().hashCode() 0)
106             (getLocationList() != null ^ getLocationList().hashCode() 0);
107     }
108 
109     public String toString() {
110         return "Name: " + name + ", Rule Version: " + ruleVersion + "\n" + locationList;
111     }
112 
113 }