1 /* 2 * Copyright 2008-2010 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 17 package de.smartics.maven.issues; 18 19 import org.apache.maven.artifact.versioning.ArtifactVersion; 20 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; 21 22 /** 23 * A factory to create version instances. Version conventions may be different 24 * in different projects. The factory ensures that for each project a specific 25 * version syntax can be supported. 26 * <p> 27 * The instance created provides information about the version string parsed. 28 * The main support it provides is the implementation of a comparable interface. 29 * The natural order should be ascending from lowest version number to highest. 30 * </p> 31 * <p> 32 * The instances created by the factory are expected to be performing well as 33 * hash keys. 34 * </p> 35 * 36 * @Taglets.taglet.note Currently it is not expected that the instances are 37 * serializable, but this may change in future. 38 * @author <a href="mailto:robert.reiner@smartics.de">Robert Reiner</a> 39 * @version $Revision:591 $ 40 */ 41 public interface VersionFactory 42 { 43 // ********************************* Fields ********************************* 44 45 // --- constants ------------------------------------------------------------ 46 47 // ****************************** Initializer ******************************* 48 49 // ****************************** Inner Classes ***************************** 50 51 // ********************************* Methods ******************************** 52 53 // --- get&set -------------------------------------------------------------- 54 55 // --- business ------------------------------------------------------------- 56 57 /** 58 * Creates a version instance from the given version string. 59 * 60 * @param versionString the version string to parse. 61 * @return the version instance. 62 * @warning Please note that it is not expected that parse exceptions occur. 63 * The implementation should make sure that at least a default 64 * representation of the version string is returned. 65 */ 66 ArtifactVersion createVersion(String versionString); 67 68 /** 69 * Creates a version range by the given specification. 70 * 71 * @param versionSpecification the specification of the version range to 72 * create. 73 * @return the range instance built from the specification. 74 * @throws InvalidVersionSpecificationException if the specification cannot be 75 * parsed. 76 */ 77 ArtifactVersionRange createRange(String versionSpecification) 78 throws InvalidVersionSpecificationException; 79 80 // --- object basics -------------------------------------------------------- 81 82 }