Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package com.fasterxml.jackson.core;

Object that encapsulates versioning information of a component. Version information includes not just version number but also optionally group and artifact ids of the component being versioned.

Note that optional group and artifact id properties are new with Jackson 2.0: if provided, they should align with Maven artifact information.

 
 public class Version
     implements Comparable<Version>,
         java.io.Serializable
 {
     private static final long serialVersionUID = 1L;
 
     private final static Version UNKNOWN_VERSION = new Version(0, 0, 0, nullnullnull);
     
     protected final int _majorVersion;
 
     protected final int _minorVersion;
 
     protected final int _patchLevel;
 
     protected final String _groupId;
     
     protected final String _artifactId;
    
    
Additional information for snapshot versions; null for non-snapshot (release) versions.
 
     protected final String _snapshotInfo;

    

Deprecated:
Use variant that takes group and artifact ids
Since:
2.1
 
     @Deprecated
     public Version(int majorint minorint patchLevelString snapshotInfo)
     {
         this(majorminorpatchLevelsnapshotInfonullnull);
     }
     
     public Version(int majorint minorint patchLevelString snapshotInfo,
             String groupIdString artifactId)
     {
          = major;
          = minor;
          = patchLevel;
          = snapshotInfo;
          = (groupId == null) ? "" : groupId;
          = (artifactId == null) ? "" : artifactId;
     }

    
Method returns canonical "not known" version, which is used as version in cases where actual version information is not known (instead of null).
 
     public static Version unknownVersion() { return ; }
 
     public boolean isUknownVersion() { return (this == ); }
     public boolean isSnapshot() { return ( != null && .length() > 0); }
     
     public int getMajorVersion() { return ; }
     public int getMinorVersion() { return ; }
     public int getPatchLevel() { return ; }
 
     public String getGroupId() { return ; }
     public String getArtifactId() { return ; }
     
     @Override
     public String toString()
     {
         StringBuilder sb = new StringBuilder();
         sb.append().append('.');
         sb.append().append('.');
         sb.append();
         if (isSnapshot()) {
             sb.append('-').append();
         }
         return sb.toString();
     }
 
     @Override
     public int hashCode() {
         return .hashCode() ^ .hashCode() +  -  + ;
     }
 
     @Override
     public boolean equals(Object o)
     {
         if (o == thisreturn true;
         if (o == nullreturn false;
         if (o.getClass() != getClass()) return false;
         Version other = (Versiono;
         return (other._majorVersion == )
             && (other._minorVersion == )
            && (other._patchLevel == )
            && other._artifactId.equals()
            && other._groupId.equals()
            ;
    }
//  @Override
    public int compareTo(Version other)
    {
        if (other == thisreturn 0;
        
        int diff = .compareTo(other._groupId);
        if (diff == 0) {
            diff = .compareTo(other._artifactId);
            if (diff == 0) {
                diff =  - other._majorVersion;
                if (diff == 0) {
                    diff =  - other._minorVersion;
                    if (diff == 0) {
                        diff =  - other._patchLevel;
                    }
                }
            }
        }
        return diff;
    }
New to GrepCode? Check out our FAQ X