当前位置: 首页>>代码示例>>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;未经允许,请勿转载。