List of usage examples for java.util UUID compareTo
public int compareTo(UUID val)
From source file:Main.java
public static void main(String[] args) { // creating UUIDs UUID u1 = UUID.randomUUID(); UUID u2 = UUID.randomUUID(); // comparing uuids System.out.println("Comparing two UUIDs: " + u1.compareTo(u2)); }
From source file:Main.java
public static boolean equalsUUID(UUID uuida, UUID uuidb) { return (uuida.compareTo(uuidb) == 0 ? true : false); }
From source file:Main.java
/** * Checks if the given UUID starts with the given service UUID i.e. their beginnings match. * * @param uuidToCheck The UUID to check. * @param serviceUuid The expected service UUID to compare against. * @return True, if the beginnings match. False otherwise. *///from w ww .ja v a 2s .com public static boolean uuidStartsWithExpectedServiceUuid(UUID uuidToCheck, UUID serviceUuid) { boolean startsWithExpectedServiceUuid = false; if (uuidToCheck != null && serviceUuid != null) { if (serviceUuid.compareTo(uuidToCheck) == 0) { // The UUID is a match // No need to do anything startsWithExpectedServiceUuid = true; } else { // Get the beginning of the parsed UUID, leave out the last seven bytes (11 chars) String beginningOfUuidToCheck = uuidToCheck.toString().substring(0, 22); startsWithExpectedServiceUuid = serviceUuid.toString().startsWith(beginningOfUuidToCheck); } } return startsWithExpectedServiceUuid; }
From source file:org.olegz.uuid.TimeBasedUUIDGeneratorTests.java
@Test public void testGreaterThen() { UUID id = TimeBasedUUIDGenerator.generateId(); for (int i = 0; i < 100000; i++) { UUID newId = TimeBasedUUIDGenerator.generateId(); // tests, that newly created UUID is always greater then the previous one. Assert.assertTrue(newId.compareTo(id) >= 0); id = newId;//from www . j a v a 2 s . c om } }
From source file:core.Reconciler.java
public void run() { System.out.println("Reconciler: Started the reconciler thread"); sfdcService = new SalesforceService(Configuration.getSalesForceConsumerSecret(), Configuration.getSalesForceConsumerKey(), Configuration.getSalesForceUsername(), Configuration.getSalesForcePassword(), Configuration.isSalesforceSandbox()); SendGridClient.initV2(Configuration.getSendGridUsername(), Configuration.getSendGridPassword(), Configuration.getAlertEmailRecipient(), Configuration.getAlertEmailSender()); NiprClient lClient = NiprClientConfiguration.getNiprClient(Configuration.getGetNiprAlertEndpoint(), Configuration.getNiprUsername(), Configuration.getNiprPassword()); AtomicLong lRetryInterval = null; UUID lResyncTriggerId = LicenseDB.getResyncTriggerId(); while (true) { if (Configuration.isPauseSync()) { System.out.println("System has been paused"); try { Thread.sleep(36000000); } catch (Exception ex) { }// w w w . j a v a2s .co m continue; } try { lRetryInterval = new AtomicLong(Configuration.getReconcilerRetry()); lResyncTriggerId = LicenseDB.getResyncTriggerId(); System.out.println("Reconciler: Current triggered Resync ID " + lResyncTriggerId); // Get the latest copy. This is a Deep Copy Map<String, LicenseInternal> lUnprocessedLicenses = LicenseDB.getUnprocessedLicenses(); Map<String, GregorianCalendar> lDaysToSync = LicenseDB.getPendingNiprSyncDates(); Map<String, LicenseInternal> lLicenses = new HashMap<String, LicenseInternal>(); Map<String, GregorianCalendar> lSuccessDates = new HashMap<String, GregorianCalendar>(); DoNiprSync(lClient, lDaysToSync, lUnprocessedLicenses, lLicenses, lSuccessDates); System.out.println( "Reconciler: " + lLicenses.size() + " new licenses to be processed in Sales Force "); if (lLicenses.size() > 0) { // Process information in sales force, save the remaining // for next run lUnprocessedLicenses = ProcessInfoInSalesForce(lLicenses, lRetryInterval); } System.out.println( "Reconciler: Total Failed licenses in in the system " + lUnprocessedLicenses.size()); // This transfers reference, do not use the map after this call // but get a fresh copy. // Update in the cache, which also serves the UI LicenseDB.setUnprocessedLicenses(lUnprocessedLicenses); LicenseDB.updateNiprSyncDates(lSuccessDates); UUID lLatestTriggerId = LicenseDB.getResyncTriggerId(); if (lLatestTriggerId.compareTo(lResyncTriggerId) != 0) { System.out.println( "Reconciler: Reconciler retrying with minimum sleep as resync triggered by user"); Thread.sleep(MIN_SLEEP_INTERVAL); continue; } long lInterval = lRetryInterval.get(); if (lUnprocessedLicenses.isEmpty()) { // Get the current time and set the interval till next day noon. Calendar cal = Calendar.getInstance(); int lCurrentHour = cal.get(Calendar.HOUR_OF_DAY); // If currentHour is in the morning before 9am, we want to run at 12pm today, since nipr alerts is not generated yet // If currentHour is after 9am, we want to run next day noon which will be 12 hours + 24 - lCurrentHour if (lCurrentHour < 9) { lInterval = (12 - lCurrentHour) * 60 * 60 * 1000; } else { lInterval = (24 - lCurrentHour + 12) * 60 * 60 * 1000; } } System.out.println("Reconciler: Sleeping for " + lInterval + "ms"); try { Thread.sleep(lInterval); } catch (InterruptedException lIntrEx) { System.out.println("Reconciler: interrupted"); } } catch (Exception ex) { System.out.println("Reconciler mainloop threw an exception " + ex.getMessage()); } } }
From source file:com.cognitect.transit.TransitMPTest.java
public void testReadUUID() throws IOException { UUID uuid = UUID.randomUUID(); final long hi64 = uuid.getMostSignificantBits(); final long lo64 = uuid.getLeastSignificantBits(); assertEquals(0, uuid.compareTo((UUID) readerOf("~u" + uuid.toString()).read())); List thing = new ArrayList() { {//from w w w. j ava 2 s . c o m add("~#u"); add(new ArrayList() { { add(hi64); add(lo64); } }); } }; assertEquals(0, uuid.compareTo((UUID) readerOf(thing).read())); }
From source file:net.sourceforge.msscodefactory.cfcrm.v2_0.CFCrm.CFCrmHPKey.java
public int compareTo(Object obj) { if (obj == null) { return (-1); } else if (obj instanceof CFCrmHPKey) { CFCrmHPKey rhs = (CFCrmHPKey) obj; {// w w w. ja v a 2s .c o m long lhsAuditClusterId = getAuditClusterId(); long rhsAuditClusterId = rhs.getAuditClusterId(); if (lhsAuditClusterId < rhsAuditClusterId) { return (-1); } else if (lhsAuditClusterId > rhsAuditClusterId) { return (1); } } { Calendar lhsAuditStamp = getAuditStamp(); Calendar rhsAuditStamp = rhs.getAuditStamp(); if (lhsAuditStamp == null) { if (rhsAuditStamp != null) { return (-1); } } else if (rhsAuditStamp == null) { return (1); } else { int cmpstat = lhsAuditStamp.compareTo(rhsAuditStamp); if (cmpstat != 0) { return (cmpstat); } } } { short lhsAuditActionId = getAuditActionId(); short rhsAuditActionId = rhs.getAuditActionId(); if (lhsAuditActionId < rhsAuditActionId) { return (-1); } else if (lhsAuditActionId > rhsAuditActionId) { return (1); } } { int lhsRequiredRevision = getRequiredRevision(); int rhsRequiredRevision = rhs.getRequiredRevision(); if (lhsRequiredRevision < rhsRequiredRevision) { return (-1); } else if (lhsRequiredRevision > rhsRequiredRevision) { return (1); } } { UUID lhsAuditSessionId = getAuditSessionId(); UUID rhsAuditSessionId = rhs.getAuditSessionId(); if (lhsAuditSessionId == null) { if (rhsAuditSessionId != null) { return (-1); } } else if (rhsAuditSessionId == null) { return (1); } else { int cmpstat = lhsAuditSessionId.compareTo(rhsAuditSessionId); if (cmpstat != 0) { return (cmpstat); } } } return (0); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "compareTo", "obj", obj, "CFCrmHPKey"); } }
From source file:net.sourceforge.msscodefactory.cfacc.v2_0.CFAcc.CFAccHPKey.java
public int compareTo(Object obj) { if (obj == null) { return (-1); } else if (obj instanceof CFAccHPKey) { CFAccHPKey rhs = (CFAccHPKey) obj; {// w ww . j a v a 2 s. c o m long lhsAuditClusterId = getAuditClusterId(); long rhsAuditClusterId = rhs.getAuditClusterId(); if (lhsAuditClusterId < rhsAuditClusterId) { return (-1); } else if (lhsAuditClusterId > rhsAuditClusterId) { return (1); } } { Calendar lhsAuditStamp = getAuditStamp(); Calendar rhsAuditStamp = rhs.getAuditStamp(); if (lhsAuditStamp == null) { if (rhsAuditStamp != null) { return (-1); } } else if (rhsAuditStamp == null) { return (1); } else { int cmpstat = lhsAuditStamp.compareTo(rhsAuditStamp); if (cmpstat != 0) { return (cmpstat); } } } { short lhsAuditActionId = getAuditActionId(); short rhsAuditActionId = rhs.getAuditActionId(); if (lhsAuditActionId < rhsAuditActionId) { return (-1); } else if (lhsAuditActionId > rhsAuditActionId) { return (1); } } { int lhsRequiredRevision = getRequiredRevision(); int rhsRequiredRevision = rhs.getRequiredRevision(); if (lhsRequiredRevision < rhsRequiredRevision) { return (-1); } else if (lhsRequiredRevision > rhsRequiredRevision) { return (1); } } { UUID lhsAuditSessionId = getAuditSessionId(); UUID rhsAuditSessionId = rhs.getAuditSessionId(); if (lhsAuditSessionId == null) { if (rhsAuditSessionId != null) { return (-1); } } else if (rhsAuditSessionId == null) { return (1); } else { int cmpstat = lhsAuditSessionId.compareTo(rhsAuditSessionId); if (cmpstat != 0) { return (cmpstat); } } } return (0); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "compareTo", "obj", obj, "CFAccHPKey"); } }
From source file:net.sourceforge.msscodefactory.cfasterisk.v2_0.CFAst.CFAstHPKey.java
public int compareTo(Object obj) { if (obj == null) { return (-1); } else if (obj instanceof CFAstHPKey) { CFAstHPKey rhs = (CFAstHPKey) obj; {//from www.j av a 2 s . c o m long lhsAuditClusterId = getAuditClusterId(); long rhsAuditClusterId = rhs.getAuditClusterId(); if (lhsAuditClusterId < rhsAuditClusterId) { return (-1); } else if (lhsAuditClusterId > rhsAuditClusterId) { return (1); } } { Calendar lhsAuditStamp = getAuditStamp(); Calendar rhsAuditStamp = rhs.getAuditStamp(); if (lhsAuditStamp == null) { if (rhsAuditStamp != null) { return (-1); } } else if (rhsAuditStamp == null) { return (1); } else { int cmpstat = lhsAuditStamp.compareTo(rhsAuditStamp); if (cmpstat != 0) { return (cmpstat); } } } { short lhsAuditActionId = getAuditActionId(); short rhsAuditActionId = rhs.getAuditActionId(); if (lhsAuditActionId < rhsAuditActionId) { return (-1); } else if (lhsAuditActionId > rhsAuditActionId) { return (1); } } { int lhsRequiredRevision = getRequiredRevision(); int rhsRequiredRevision = rhs.getRequiredRevision(); if (lhsRequiredRevision < rhsRequiredRevision) { return (-1); } else if (lhsRequiredRevision > rhsRequiredRevision) { return (1); } } { UUID lhsAuditSessionId = getAuditSessionId(); UUID rhsAuditSessionId = rhs.getAuditSessionId(); if (lhsAuditSessionId == null) { if (rhsAuditSessionId != null) { return (-1); } } else if (rhsAuditSessionId == null) { return (1); } else { int cmpstat = lhsAuditSessionId.compareTo(rhsAuditSessionId); if (cmpstat != 0) { return (cmpstat); } } } return (0); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "compareTo", "obj", obj, "CFAstHPKey"); } }
From source file:net.sourceforge.msscodefactory.cfcore.v2_0.CFGenKb.CFGenKbHPKey.java
public int compareTo(Object obj) { if (obj == null) { return (-1); } else if (obj instanceof CFGenKbHPKey) { CFGenKbHPKey rhs = (CFGenKbHPKey) obj; {/* www .ja v a2s. c o m*/ long lhsAuditClusterId = getAuditClusterId(); long rhsAuditClusterId = rhs.getAuditClusterId(); if (lhsAuditClusterId < rhsAuditClusterId) { return (-1); } else if (lhsAuditClusterId > rhsAuditClusterId) { return (1); } } { Calendar lhsAuditStamp = getAuditStamp(); Calendar rhsAuditStamp = rhs.getAuditStamp(); if (lhsAuditStamp == null) { if (rhsAuditStamp != null) { return (-1); } } else if (rhsAuditStamp == null) { return (1); } else { int cmpstat = lhsAuditStamp.compareTo(rhsAuditStamp); if (cmpstat != 0) { return (cmpstat); } } } { short lhsAuditActionId = getAuditActionId(); short rhsAuditActionId = rhs.getAuditActionId(); if (lhsAuditActionId < rhsAuditActionId) { return (-1); } else if (lhsAuditActionId > rhsAuditActionId) { return (1); } } { int lhsRequiredRevision = getRequiredRevision(); int rhsRequiredRevision = rhs.getRequiredRevision(); if (lhsRequiredRevision < rhsRequiredRevision) { return (-1); } else if (lhsRequiredRevision > rhsRequiredRevision) { return (1); } } { UUID lhsAuditSessionId = getAuditSessionId(); UUID rhsAuditSessionId = rhs.getAuditSessionId(); if (lhsAuditSessionId == null) { if (rhsAuditSessionId != null) { return (-1); } } else if (rhsAuditSessionId == null) { return (1); } else { int cmpstat = lhsAuditSessionId.compareTo(rhsAuditSessionId); if (cmpstat != 0) { return (cmpstat); } } } return (0); } else { throw CFLib.getDefaultExceptionFactory().newUnsupportedClassException(getClass(), "compareTo", "obj", obj, "CFGenKbHPKey"); } }