public override int CompareTo(ComparableVersion.Item item) { if (item == null) { // 1-rc < 1, 1-ga > 1 return(string.CompareOrdinal(ComparableQualifier(value), ReleaseVersionIndex)); } switch (item.GetType()) { case IntegerItem: { return(-1); } case StringItem: { // 1.any < 1.1 ? return(string.CompareOrdinal(ComparableQualifier(value), ComparableQualifier(((ComparableVersion.StringItem )item).value))); } case ListItem: { return(-1); } default: { // 1.any < 1-1 throw new RuntimeException("invalid item: " + item.GetType()); } } }
public override int CompareTo(ComparableVersion.Item item) { if (item == null) { return(BigIntegerZero.Equals(value) ? 0 : 1); } switch (item.GetType()) { case IntegerItem: { // 1.0 == 1, 1.1 > 1 return(value.CompareTo(((ComparableVersion.IntegerItem)item).value)); } case StringItem: { return(1); } case ListItem: { // 1.1 > 1-sp return(1); } default: { // 1.1 > 1-1 throw new RuntimeException("invalid item: " + item.GetType()); } } }
/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ public abstract int CompareTo(ComparableVersion.Item item);