File: DefaultModuleInfo.java

package info (click to toggle)
libbase 1.1.6-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 944 kB
  • sloc: java: 8,709; xml: 1,522; makefile: 18
file content (241 lines) | stat: -rw-r--r-- 6,386 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
/*
 * This program is free software; you can redistribute it and/or modify it under the
 * terms of the GNU Lesser General Public License, version 2.1 as published by the Free Software
 * Foundation.
 *
 * You should have received a copy of the GNU Lesser General Public License along with this
 * program; if not, you can obtain a copy at http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html
 * or from the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * Copyright (c) 2007 - 2009 Pentaho Corporation and Contributors.  All rights reserved.
 */

package org.pentaho.reporting.libraries.base.boot;

/**
 * Provides a default implementation of the module info interface.
 *
 * @author Thomas Morgner
 */
public class DefaultModuleInfo implements ModuleInfo
{
  /**
   * The name of the module class.
   */
  private String moduleClass;
  /**
   * The major version of the described module.
   */
  private String majorVersion;
  /**
   * The minor version of the described module.
   */
  private String minorVersion;
  /**
   * The patchlevel version of the described module.
   */
  private String patchLevel;

  /**
   * DefaultConstructor.
   */
  public DefaultModuleInfo()
  {
    // nothing required
  }

  /**
   * Creates a new module info an initalizes it with the given values.
   *
   * @param moduleClass  the class name of the module implementation holding the module
   *                     description.
   * @param majorVersion the modules major version.
   * @param minorVersion the modules minor version.
   * @param patchLevel   the modules patchlevel.
   * @throws NullPointerException if the moduleClass is null.
   */
  public DefaultModuleInfo(final String moduleClass, final String majorVersion,
                           final String minorVersion, final String patchLevel)
  {
    if (moduleClass == null)
    {
      throw new NullPointerException("Module class must not be null.");
    }
    this.moduleClass = moduleClass;
    this.majorVersion = majorVersion;
    this.minorVersion = minorVersion;
    this.patchLevel = patchLevel;
  }

  /**
   * Returns the class name of the module described implementation.
   *
   * @return the module class name.
   * @see ModuleInfo#getModuleClass()
   */
  public String getModuleClass()
  {
    return this.moduleClass;
  }

  /**
   * Defines the module class name.
   *
   * @param moduleClass the class name of the module implementation.
   */
  public void setModuleClass(final String moduleClass)
  {
    if (moduleClass == null)
    {
      throw new NullPointerException();
    }
    this.moduleClass = moduleClass;
  }

  /**
   * Returns the major version of the module. This property may be
   * null to indicate that the module version is not specified.
   *
   * @return the major version.
   * @see ModuleInfo#getMajorVersion()
   */
  public String getMajorVersion()
  {
    return this.majorVersion;
  }

  /**
   * Defines the major version of the module. This property may be
   * null to indicate that the module version is not specified.
   *
   * @param majorVersion the major version.
   * @see ModuleInfo#getMajorVersion()
   */
  public void setMajorVersion(final String majorVersion)
  {
    this.majorVersion = majorVersion;
  }

  /**
   * Returns the minor version of the module. This property may be
   * null to indicate that the module version is not specified.
   *
   * @return the minor version.
   * @see ModuleInfo#getMajorVersion()
   */
  public String getMinorVersion()
  {
    return this.minorVersion;
  }

  /**
   * Defines the minor version of the module. This property may be
   * null to indicate that the module version is not specified.
   *
   * @param minorVersion the minor version.
   * @see ModuleInfo#getMajorVersion()
   */
  public void setMinorVersion(final String minorVersion)
  {
    this.minorVersion = minorVersion;
  }

  /**
   * Returns the patch level version of the module. This property may be
   * null to indicate that the module version is not specified.
   *
   * @return the patch level version.
   * @see ModuleInfo#getMajorVersion()
   */
  public String getPatchLevel()
  {
    return this.patchLevel;
  }

  /**
   * Defines the patch level version of the module. This property may be
   * null to indicate that the module version is not specified.
   *
   * @param patchLevel the patch level version.
   * @see ModuleInfo#getMajorVersion()
   */
  public void setPatchLevel(final String patchLevel)
  {
    this.patchLevel = patchLevel;
  }

  /**
   * Two moduleinfos are equal,if they have the same module class.
   *
   * @param o the other object to compare.
   * @return true, if the module points to the same module, false otherwise.
   */
  public boolean equals(final Object o)
  {
    if (this == o)
    {
      return true;
    }
    if (!(o instanceof DefaultModuleInfo))
    {
      return false;
    }

    final ModuleInfo defaultModuleInfo = (ModuleInfo) o;

    if (!this.moduleClass.equals(defaultModuleInfo.getModuleClass()))
    {
      return false;
    }
    return true;
  }

  /**
   * Computes an hashcode for this module information.
   *
   * @return the hashcode.
   * @see Object#hashCode()
   */
  public int hashCode()
  {
    final int result;
    result = this.moduleClass.hashCode();
    return result;
  }

  /**
   * Returns a string representation of this module information.
   *
   * @return a string describing this class.
   * @see Object#toString()
   */
  public String toString()
  {
    final StringBuffer buffer = new StringBuffer(128);
    buffer.append(getClass().getName());
    buffer.append("={ModuleClass=");
    buffer.append(getModuleClass());
    if (getMajorVersion() != null)
    {
      buffer.append("; Version=");
      buffer.append(getMajorVersion());
      if (getMinorVersion() != null)
      {
        buffer.append('-');
        buffer.append(getMinorVersion());
        if (getPatchLevel() != null)
        {
          buffer.append('_');
          buffer.append(getPatchLevel());
        }
      }
    }
    buffer.append('}');
    return buffer.toString();
  }
}