View Javadoc

1   /*
2    * Copyright 2008-2013 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package de.smartics.maven.issues;
17  
18  import org.apache.maven.artifact.versioning.ArtifactVersion;
19  import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
20  
21  /**
22   * A factory to create version instances. Version conventions may be different
23   * in different projects. The factory ensures that for each project a specific
24   * version syntax can be supported.
25   * <p>
26   * The instance created provides information about the version string parsed.
27   * The main support it provides is the implementation of a comparable interface.
28   * The natural order should be ascending from lowest version number to highest.
29   * </p>
30   * <p>
31   * The instances created by the factory are expected to be performing well as
32   * hash keys.
33   * </p>
34   *
35   * @Taglets.taglet.note Currently it is not expected that the instances are
36   *                      serializable, but this may change in future.
37   * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a>
38   * @version $Revision:591 $
39   */
40  public interface VersionFactory
41  {
42    // ********************************* Fields *********************************
43  
44    // --- constants ------------------------------------------------------------
45  
46    // ****************************** Initializer *******************************
47  
48    // ****************************** Inner Classes *****************************
49  
50    // ********************************* Methods ********************************
51  
52    // --- get&set --------------------------------------------------------------
53  
54    // --- business -------------------------------------------------------------
55  
56    /**
57     * Creates a version instance from the given version string.
58     *
59     * @param versionString the version string to parse.
60     * @return the version instance.
61     * @warning Please note that it is not expected that parse exceptions occur.
62     *          The implementation should make sure that at least a default
63     *          representation of the version string is returned.
64     */
65    ArtifactVersion createVersion(String versionString);
66  
67    /**
68     * Creates a version range by the given specification.
69     *
70     * @param versionSpecification the specification of the version range to
71     *          create.
72     * @return the range instance built from the specification.
73     * @throws InvalidVersionSpecificationException if the specification cannot be
74     *           parsed.
75     */
76    ArtifactVersionRange createRange(String versionSpecification)
77      throws InvalidVersionSpecificationException;
78  
79    // --- object basics --------------------------------------------------------
80  
81  }