List of usage examples for java.lang Long compareTo
public int compareTo(Long anotherLong)
From source file:org.ujorm.hotels.services.impl.DbServiceImpl.java
/** Check a read-only state */ private void checkReadOnly(Hotel ujo) throws ValidationException { final Long id = ujo.getId(); if (readOnly && id != null && id.compareTo(0L) < 0) { throwReadOnlyException();//from w w w. j ava 2s .co m } }
From source file:org.kuali.kpme.core.earncode.validation.EarnCodeValidation.java
boolean validateDefaultAmountOfTime(Long defaultAmountofTime) { boolean valid = true; if (defaultAmountofTime != null) { if (defaultAmountofTime.compareTo(24L) > 0 || defaultAmountofTime.compareTo(0L) < 0) { this.putFieldError("dataObject.defaultAmountofTime", "error.leaveCode.hours", "Default Amount of Time '" + defaultAmountofTime + "'"); valid = false;//from w ww.jav a 2 s .c o m } } return valid; }
From source file:ar.com.zauber.commons.web.cache.impl.repo.ehcache.EhCacheLastModifiedRepository.java
/** @see LastModifiedRepository#getMaxTimestamp(List) */ public final Long getMaxTimestamp(final List<StringEntityKey> keys) { Long maxTimestamp = null; for (StringEntityKey key : keys) { Long ts = getTimestamp(key); if (maxTimestamp == null) { maxTimestamp = ts;//from w w w . j a v a2s . c o m } else if (ts != null && maxTimestamp.compareTo(ts) < 0) { maxTimestamp = ts; } } return maxTimestamp; }
From source file:org.paxml.testng.PaxmlListener.java
/** * This controls the sorting logic of the paxml test case executions. *///from w ww. j a va 2s .com @Override public List<IMethodInstance> intercept(List<IMethodInstance> list, ITestContext context) { List<IMethodInstance> result = new ArrayList<IMethodInstance>(list); Collections.sort(result, new Comparator<IMethodInstance>() { @Override public int compare(IMethodInstance m1, IMethodInstance m2) { Long pid1 = getPid(m1.getInstances()[0]); Long pid2 = getPid(m2.getInstances()[0]); return pid1.compareTo(pid2); } }); return result; }
From source file:org.kuali.rice.kew.docsearch.SearchableAttributeLongValue.java
@Override public Boolean isRangeValid(String lowerValue, String upperValue) { if (allowsRangeSearches()) { Long lower = convertStringToLong(lowerValue); Long upper = convertStringToLong(upperValue); if ((lower != null) && (upper != null)) { return (lower.compareTo(upper) <= 0); }// ww w . j ava2 s. co m return true; } return null; }
From source file:edu.utah.further.mdr.ws.impl.service.soap.AssetServiceSoapImpl.java
/** * Validate input arguments to {@link #translateConcept(DtsConceptPair)}. * //from www .j a v a 2 s . co m * @param source * @param targetPropertyName * @param options */ private void validateId(final Long id) // throws WsException { final TextTemplate invalidArgumentMessage = new TextTemplate("Illegal ID %ID%", asList("ID")); if ((id == null) || (id.compareTo(LONG_ZERO) <= 0)) { throw new ApplicationException(INVALID_INPUT_ARGUMENT_VALUE, invalidArgumentMessage.evaluate(asList(EMPTY_STRING + id))); } }
From source file:org.openmrs.module.ModuleUtil.java
/** * Compares <code>version</code> to <code>value</code> version and value are strings like * 1.9.2.0 Returns <code>0</code> if either <code>version</code> or <code>value</code> is null. * * @param version String like 1.9.2.0/*from w w w. j a v a 2 s . c o m*/ * @param value String like 1.9.2.0 * @return the value <code>0</code> if <code>version</code> is equal to the argument * <code>value</code>; a value less than <code>0</code> if <code>version</code> is * numerically less than the argument <code>value</code>; and a value greater than * <code>0</code> if <code>version</code> is numerically greater than the argument * <code>value</code> * @should correctly comparing two version numbers * @should treat SNAPSHOT as earliest version */ public static int compareVersion(String version, String value) { try { if (version == null || value == null) { return 0; } List<String> versions = new Vector<String>(); List<String> values = new Vector<String>(); String separator = "-"; // strip off any qualifier e.g. "-SNAPSHOT" int qualifierIndex = version.indexOf(separator); if (qualifierIndex != -1) { version = version.substring(0, qualifierIndex); } qualifierIndex = value.indexOf(separator); if (qualifierIndex != -1) { value = value.substring(0, qualifierIndex); } Collections.addAll(versions, version.split("\\.")); Collections.addAll(values, value.split("\\.")); // match the sizes of the lists while (versions.size() < values.size()) { versions.add("0"); } while (values.size() < versions.size()) { values.add("0"); } for (int x = 0; x < versions.size(); x++) { String verNum = versions.get(x).trim(); String valNum = values.get(x).trim(); Long ver = NumberUtils.toLong(verNum, 0); Long val = NumberUtils.toLong(valNum, 0); int ret = ver.compareTo(val); if (ret != 0) { return ret; } } } catch (NumberFormatException e) { log.error("Error while converting a version/value to an integer: " + version + "/" + value, e); } // default return value if an error occurs or elements are equal return 0; }
From source file:com.jkenneth.droidovpn.ui.activity.MainActivity.java
private void sort(final int sortBy) { Collections.sort(mServers, new Comparator<Server>() { @Override//from ww w. j av a2 s.c om public int compare(Server server, Server server2) { int compareTo = 0; if (sortBy == SORT_COUNTRY) { compareTo = server.countryLong.compareTo(server2.countryLong); } else if (sortBy == SORT_SPEED) { compareTo = Long.valueOf(server2.speed).compareTo(server.speed); } else if (sortBy == SORT_PING) { Long ping = !server.ping.equals("-") ? Long.valueOf(server.ping) : 0L; Long ping2 = !server2.ping.equals("-") ? Long.valueOf(server2.ping) : 0L; compareTo = ping2.compareTo(ping); } return compareTo; } }); mAdapter.notifyDataSetChanged(); mSortedBy = sortBy; }
From source file:org.araqne.confdb.file.ShrinkTest.java
@Test public void testExistImport() throws IOException, ParseException, JSONException { for (int id = 0; id < 10; id++) col1.add(createObject(id));/*from w w w . ja v a2 s . com*/ List<CommitLog> logs = db.getCommitLogs(); Comparator<CommitLog> comparator = new Comparator<CommitLog>() { @Override public int compare(CommitLog o1, CommitLog o2) { Long rev1 = o1.getRev(); return rev1.compareTo(o2.getRev()); } }; assertEquals(11, db.getCommitCount()); assertEquals(1, db.getManifest(null).getCollectionId("testcol1")); Collections.sort(logs, comparator); export((int) logs.get(logs.size() - 1).getRev()); db.purge(); this.col2 = (FileConfigCollection) db.ensureCollection("testcol2"); col2.add(createObject(20)); assertEquals(1, db.getCollectionNames().size()); assertTrue(db.getCollectionNames().contains("testcol2")); assertFalse(db.getCollectionNames().contains("testcol1")); importData((int) logs.get(logs.size() - 1).getRev()); assertEquals(1, db.getCollectionNames().size()); assertTrue(db.getCollectionNames().contains("testcol1")); assertFalse(db.getCollectionNames().contains("testcol2")); assertEquals(2, db.getManifest(null).getCollectionId("testcol1")); importData((int) logs.get(logs.size() - 1).getRev()); new File(db.getDbDirectory(), "export_" + logs.get(logs.size() - 1).getRev() + ".txt").delete(); }
From source file:song.androidstudy.tracedump.java
boolean parseTrace(String traceFile) { ArrayList<TimeLineView.Record> records = null; DmTraceReader mReader = null;//w w w . j av a 2 s . c o m records = null; try { mReader = new DmTraceReader(traceFile, false); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); return false; } mTda = mReader.getThreads(); records = mReader.getThreadTimeRecords(); mTraceRecordList = records.toArray(new TimeLineView.Record[records.size()]); Arrays.sort(mTraceRecordList, new Comparator<TimeLineView.Record>() { public int compare(TimeLineView.Record rec1, TimeLineView.Record rec2) { Long start1 = new Long(rec1.block.getStartTime()); Long start2 = new Long(rec2.block.getStartTime()); return start1.compareTo(start2); } }); return true; }