[java-identity-provider COMMIT] /trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/CounterStorageKeyCo...
noreply at shibboleth.net
noreply at shibboleth.net
Tue Feb 24 21:04:21 EST 2015
Author: tzeller
Date: Tue Feb 24 21:04:21 2015
New Revision: 7375
URL: http://svn.shibboleth.net/view/java-identity-provider?rev=7375&view=rev
Log:
Simplify comparator.
Modified:
trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/CounterStorageKeyComparator.java
Modified: trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/CounterStorageKeyComparator.java
URL: http://svn.shibboleth.net/view/java-identity-provider/trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/CounterStorageKeyComparator.java?rev=7375&r1=7374&r2=7375&view=diff
==============================================================================
--- trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/CounterStorageKeyComparator.java (original)
+++ trunk/idp-consent/src/main/java/net/shibboleth/idp/consent/logic/CounterStorageKeyComparator.java Tue Feb 24 21:04:21 2015
@@ -60,24 +60,16 @@
/** {@inheritDoc} */
public int compare(String o1, String o2) {
- final Long counter1 = keyToCounterMap.get(o1);
- final Long counter2 = keyToCounterMap.get(o2);
+ final Long counter1 = keyToCounterMap.containsKey(o1) ? keyToCounterMap.get(o1) : 0;
+ final Long counter2 = keyToCounterMap.containsKey(o2) ? keyToCounterMap.get(o2) : 0;
- if (counter1 == null && counter2 == null) {
+ if (counter1.equals(counter2)) {
// Compare based on storage key list ordering.
return Integer.compare(storageKeys.indexOf(o1), storageKeys.indexOf(o2));
- } else if (counter1 == null) {
- return -1;
- } else if (counter2 == null) {
- return 1;
- } else if (counter1.equals(counter2)) {
- // Compare based on storage key list ordering.
- return Integer.compare(storageKeys.indexOf(o1), storageKeys.indexOf(o2));
- } else {
- // Compare counters.
- return Long.compare(counter1, counter2);
}
+ // Compare counters.
+ return Long.compare(counter1, counter2);
}
}
More information about the commits
mailing list