本文整理匯總了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);
}