本文整理汇总了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 );
}
示例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;
}
示例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);
}