當前位置: 首頁>>代碼示例>>Java>>正文


Java UUID.compareTo方法代碼示例

本文整理匯總了Java中java.util.UUID.compareTo方法的典型用法代碼示例。如果您正苦於以下問題:Java UUID.compareTo方法的具體用法?Java UUID.compareTo怎麽用?Java UUID.compareTo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.UUID的用法示例。


在下文中一共展示了UUID.compareTo方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: compare

import java.util.UUID; //導入方法依賴的package包/類
/**
 * Compare two UUID.
 * 
 * @param uuid1 The first UUID
 * @param uuid2 he second UUID
 * @return -1 if the first UUID is lower than the second UUID, 1 if it's higher, 0
 * if they are equal  
 */
public int compare( UUID uuid1, UUID uuid2 )
{
    if ( IS_DEBUG )
    {
        LOG.debug( "comparing UUID objects '{}' with '{}'", uuid1, uuid2 );
    }

    // -------------------------------------------------------------------
    // Handle some basis cases
    // -------------------------------------------------------------------
    if ( uuid1 == null )
    {
        return ( uuid2 == null ) ? 0 : -1;
    }

    if ( uuid2 == null )
    {
        return 1;
    }

    return uuid1.compareTo( uuid2 );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:31,代碼來源:UuidComparator.java

示例2: compareId

import java.util.UUID; //導入方法依賴的package包/類
@SuppressWarnings ( { "unchecked", "incomplete-switch" } )
private static boolean compareId ( final FilterAssertion assertion, final UUID left )
{
    if ( assertion.getAssertion () == Assertion.PRESENCE )
    {
        return left != null;
    }
    if ( assertion.getValue () == null )
    {
        return false;
    }
    if ( ! ( assertion.getValue () instanceof String || assertion.getValue () instanceof UUID || assertion.getValue () instanceof Collection<?> ) )
    {
        return false;
    }
    if ( assertion.getAssertion () == Assertion.SUBSTRING )
    {
        return left.toString ().matches ( toRegEx ( (Collection<String>)assertion.getValue () ) );
    }
    final UUID right = UUID.fromString ( assertion.getValue ().toString () );
    switch ( assertion.getAssertion () )
    {
        case LESSTHAN:
            return left.compareTo ( right ) == -1;
        case LESSEQ:
            return left.compareTo ( right ) == -1 || left.compareTo ( right ) == 0;
        case EQUALITY:
            return left.compareTo ( right ) == 0;
        case GREATEREQ:
            return left.compareTo ( right ) == 1 || left.compareTo ( right ) == 0;
        case GREATERTHAN:
            return left.compareTo ( right ) == 1;
        case APPROXIMATE:
            throw new IllegalArgumentException ( Messages.getString ( "EventMatcherImpl.Error.ApproximateNotSupported" ) ); //$NON-NLS-1$
    }
    return false;
}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:38,代碼來源:EventMatcherImpl.java

示例3: compare

import java.util.UUID; //導入方法依賴的package包/類
@Override
public int compare (AccessRestriction o1, AccessRestriction o2)
{
   UUID u1 = UUID.fromString (o1.getUUID ());
   UUID u2 = UUID.fromString (o2.getUUID ());
   
   return u1.compareTo (u2);
}
 
開發者ID:SentinelDataHub,項目名稱:dhus-core,代碼行數:9,代碼來源:RestrictionMap.java


注:本文中的java.util.UUID.compareTo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。