1 31 32 package org.opencms.module; 33 34 47 public class CmsModuleDependency implements Comparable { 48 49 50 private int m_hashCode; 51 52 53 private String m_name; 54 55 56 private CmsModuleVersion m_version; 57 58 62 public CmsModuleDependency() { 63 64 super(); 65 m_name = new String (); 66 m_version = new CmsModuleVersion("0"); 67 68 m_hashCode = m_name.concat(m_version.toString()).hashCode(); 70 } 71 72 78 public CmsModuleDependency(String moduleName, CmsModuleVersion minVersion) { 79 80 super(); 81 m_name = moduleName; 82 m_version = minVersion; 83 84 m_hashCode = m_name.concat(m_version.toString()).hashCode(); 86 } 87 88 91 public int compareTo(Object obj) { 92 93 if (obj == this) { 94 return 0; 95 } 96 if (obj instanceof CmsModuleDependency) { 97 CmsModuleDependency other = (CmsModuleDependency)obj; 98 if (!m_name.equals(other.m_name)) { 99 return 0; 101 } 102 return m_version.compareTo(other.m_version); 104 } 105 return 0; 106 } 107 108 114 public boolean dependesOn(CmsModuleDependency other) { 115 116 if (!m_name.equals(other.m_name)) { 117 return false; 119 } 120 121 return (m_version.compareTo(other.m_version) <= 0); 123 } 124 125 128 public boolean equals(Object obj) { 129 130 if (obj == this) { 131 return true; 132 } 133 if (obj instanceof CmsModuleDependency) { 134 CmsModuleDependency other = (CmsModuleDependency)obj; 135 return m_name.equals(other.m_name) && m_version.equals(other.m_version); 136 } 137 return false; 138 } 139 140 145 public String getName() { 146 147 return m_name; 148 } 149 150 155 public CmsModuleVersion getVersion() { 156 157 return m_version; 158 } 159 160 163 public int hashCode() { 164 165 return m_hashCode; 166 } 167 168 172 public void setName(String value) { 173 174 m_name = value; 175 } 176 177 181 public void setVersion(CmsModuleVersion value) { 182 183 m_version = value; 184 } 185 186 189 public String toString() { 190 191 return "[" + getClass().getName() + ", name: " + m_name + ", version: " + m_version + "]"; 192 } 193 } | Popular Tags |