private static int compareCompoundToSpec( final CompoundVersionSpec first, final VersionSpec second ) { if ( second instanceof SingleVersion ) { return -1 * compareSingleToCompound( (SingleVersion) second, first ); } else if ( second instanceof RangeVersionSpec ) { return -1 * compareRangeToCompound( (RangeVersionSpec) second, first ); } else { return compareCompoundToCompound( first, (CompoundVersionSpec) second ); } }
public static int compareTo( final VersionSpec first, final VersionSpec second ) { if ( first instanceof SingleVersion ) { return compareSingleToSpec( (SingleVersion) first, second ); } else if ( first instanceof RangeVersionSpec ) { return compareRangeToSpec( (RangeVersionSpec) first, second ); } else { return compareCompoundToSpec( (CompoundVersionSpec) first, second ); } }
@Override public int compareTo( final VersionPhrase other ) { return VersionSpecComparisons.comparePhraseToPhrase( this, other ); }
private static int compareRangeToSpec( final RangeVersionSpec first, final VersionSpec second ) { if ( second instanceof SingleVersion ) { return -1 * compareSingleToRange( (SingleVersion) second, first ); } else if ( second instanceof RangeVersionSpec ) { return compareRangeToRange( first, (RangeVersionSpec) second ); } else { return compareRangeToCompound( first, (CompoundVersionSpec) second ); } }
private static int compareSingleToSpec( final SingleVersion first, final VersionSpec second ) { if ( second instanceof SingleVersion ) { return compareSingleToSingle( first, (SingleVersion) second ); } else if ( second instanceof RangeVersionSpec ) { return compareSingleToRange( first, (RangeVersionSpec) second ); } else { return compareSingleToCompound( first, (CompoundVersionSpec) second ); } }
public CompoundVersionSpec( final String rawExpression, final VersionSpec... specs ) { this.rawExpression = rawExpression; final List<VersionSpec> s = new ArrayList<VersionSpec>(); for ( final VersionSpec spec : specs ) { if ( ( spec instanceof SingleVersion ) ) { throw new IllegalArgumentException( "Currently concrete versions are NOT supported in compound version specifications." ); } s.add( spec ); } Collections.sort( s, VersionSpecComparisons.comparator() ); this.specs = Collections.unmodifiableList( s ); }
private static int compareSingleToSingle( final SingleVersion first, final SingleVersion second ) { final int comp = comparePhrasesToPhrases( first.getVersionPhrases(), second.getVersionPhrases() ); if ( comp == 0 ) { if ( first.isRelease() && !second.isRelease() ) { return 1; } else if ( second.isRelease() && !first.isRelease() ) { return -1; } } return comp; }
comp = comparePartsToParts( first.getVersionParts(), second.getVersionParts() );
public CompoundVersionSpec( final String rawExpression, final List<VersionSpec> specs ) { this.rawExpression = rawExpression; final List<VersionSpec> s = new ArrayList<VersionSpec>(); for ( final VersionSpec spec : specs ) { if ( spec.isSingle() ) { final SingleVersion sv = (SingleVersion) spec; s.add( new RangeVersionSpec( "[" + spec.renderStandard() + "]", sv, sv, true, true ) ); } else { s.add( spec ); } } Collections.sort( s, VersionSpecComparisons.comparator() ); this.specs = Collections.unmodifiableList( s ); }
final VersionPhrase s = sp.get( i ); comp = comparePhraseToPhrase( f, s ); if ( comp != 0 )