public static <T extends Comparable<T>> int compareObjectsNullSafe(T thisObject, T otherObject) { if (anyNull(thisObject, otherObject)) { return compareNulls(thisObject, otherObject); } return thisObject.compareTo(otherObject); }
private void validateArgs(CmdLineParser parser) throws CmdLineException { if (NullUtils.allNull(fileToLoad, orcid)) { throw new CmdLineException(parser, "At least one of -f | -o must be specificed"); } }
public Comparator<OrcidWork> workDisplayIndexComparator() { return (work1, work2) -> { Long displayIndex1 = work1.getDisplayIndex(); Long displayIndex2 = work2.getDisplayIndex(); if (displayIndex1 != null && displayIndex2 != null) { return -displayIndex1.compareTo(displayIndex2); } else { return NullUtils.compareNulls(displayIndex1, displayIndex2); } }; }
public static boolean noneNull(Object... objects) { return !anyNull(objects); }
@Override public int compareTo(BaseContributorEntity other) { if (other == null) { return -1; } int compareSequenceTypes = compareObjectsNullSafe(sequence, other.getSequence()); if (compareSequenceTypes != 0) { return compareSequenceTypes; } int compareRoles = compareObjectsNullSafe(contributorRole, other.getContributorRole()); if (compareRoles != 0) { return compareRoles; } int compareCreditNames = compareObjectsNullSafe(creditName, other.getCreditName()); if (compareCreditNames != 0) { return compareCreditNames; } int compareEmails = compareObjectsNullSafe(contributorEmail, other.getContributorEmail()); if (compareEmails != 0) { return compareEmails; } return compareCreditNames; }
protected boolean isBeingAccessedByCreator(OrcidProfile orcidProfile) { String amenderOrcid = sourceManager.retrieveSourceOrcid(); Source source = orcidProfile.getOrcidHistory().getSource(); if (NullUtils.noneNull(amenderOrcid, source)) { return amenderOrcid.equals(source.retrieveSourcePath()); } return false; }
/** * * @return The params encoded as a single string, as if in a URL query. The string is not url encoded because will * be encrypted by a manager first. email=?&gNames=?&fName=?&sponsor=?&identifier=?&institution=? */ public String toParamsString() { List<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>(); pairs.add(new ImmutablePair<String, String>(EMAIL_PARAM_KEY, email)); pairs.add(new ImmutablePair<String, String>(ISSUE_DATE_PARAM_KEY, String.valueOf(issueDate))); List<String> items = new ArrayList<String>(pairs.size()); for (Pair<String, String> pair : pairs) { items.add(pair.getLeft() + EQUALS + NullUtils.blankIfNull(pair.getRight())); } return StringUtils.join(items, SEPARATOR); }
public Comparator<OrcidWork> workPubDateComparator() { return (work1, work2) -> { PublicationDate pubDate1 = work1.getPublicationDate(); PublicationDate pubDate2 = work2.getPublicationDate(); if (pubDate1 != null && pubDate2 != null) { @SuppressWarnings("deprecation") String dateString1 = PojoUtil.createDateSortString(null, pubDate1); @SuppressWarnings("deprecation") String dateString2 = PojoUtil.createDateSortString(null, pubDate2); return -dateString1.compareTo(dateString2); } else { return NullUtils.compareNulls(pubDate1, pubDate2); } }; }
@Override public int compareTo(ClientSecretEntity other) { Date otherLastModified = other.getLastModified(); Date thisLastModified = getLastModified(); int dateComparison = NullUtils.compareObjectsNullSafe(thisLastModified, otherLastModified); if (dateComparison != 0) { return -dateComparison; } if(isPrimary() != other.isPrimary()) { return -1; } return clientSecret.compareTo(other.getClientSecret()); }
extIdRefs.add(externalIdReference.getContent()); if (NullUtils.noneNull(sourcePath, externalIdReference)) { extIdOrcidsAndRefs.add(sourcePath + "=" + externalIdReference.getContent());
/** * * @return The params encoded as a single string, as if in a URL query. The * string is not url encoded because will be encrypted by a manager * first. * email=?&gNames=?&fName=?&sponsor=?&identifier=?&institution=? */ public String toParamsString() { List<Pair<String, String>> pairs = new ArrayList<Pair<String, String>>(); pairs.add(new ImmutablePair<String, String>(EMAIL_PARAM_KEY, email)); pairs.add(new ImmutablePair<String, String>(GIVEN_NAMES_PARAM_KEY, givenNames)); pairs.add(new ImmutablePair<String, String>(FAMILY_NAME_PARAM_KEY, familyName)); pairs.add(new ImmutablePair<String, String>(VOCATIVE_NAME_PARAM_KEY, vocativeName)); pairs.add(new ImmutablePair<String, String>(SPONSOR_NAME_PARAM_KEY, sponsorName)); pairs.add(new ImmutablePair<String, String>(SPONSOR_ID_PARAM_KEY, sponsorId)); pairs.add(new ImmutablePair<String, String>(INSTITUTION_NAME_PARAM_KEY, institutionName)); List<String> items = new ArrayList<String>(pairs.size()); for (Pair<String, String> pair : pairs) { items.add(pair.getLeft() + EQUALS + NullUtils.blankIfNull(pair.getRight())); } return StringUtils.join(items, SEPARATOR); }
private int compareTypes(String affiliationType, String otherAffiliationType) { if (NullUtils.anyNull(affiliationType, otherAffiliationType)) { return NullUtils.compareNulls(affiliationType, otherAffiliationType); } return affiliationType.compareTo(otherAffiliationType); }
public Comparator<OrcidWork> workTitleComparator() { return (work1, work2) -> { WorkTitle title1 = work1.getWorkTitle(); WorkTitle title2 = work2.getWorkTitle(); if (title1 != null && title2 != null) { return title1.getTitle().getContent().compareTo(title2.getTitle().getContent()); } else { return NullUtils.compareNulls(title1, title2); } }; }
private void validateArgs(CmdLineParser parser) throws CmdLineException { if (NullUtils.allNull(orcid, orcidsToDelete)) { throw new CmdLineException(parser, "At least one of -f | -o must be specificed"); } }
int typeCompare = compareObjectsNullSafe(type, other.getType()); if(typeCompare != 0) { return typeCompare; int roleCompare = compareObjectsNullSafe(role, other.getRole()); if(roleCompare != 0) { return roleCompare; int completionDateCompare = compareObjectsNullSafe((FuzzyDateEntity)completionDate, (FuzzyDateEntity)other.getCompletionDate()); if(completionDateCompare != 0) { return completionDateCompare; int subjectTypeCompare = compareObjectsNullSafe(subjectType, other.getSubjectType()); if(subjectTypeCompare != 0) { return subjectTypeCompare;
private int compareNames(String name, String otherName) { if (NullUtils.anyNull(name, otherName)) { return NullUtils.compareNulls(name, otherName); } return name.compareTo(otherName); }
private void validateArgs(CmdLineParser parser) throws CmdLineException { if (NullUtils.allNull(workId, worksToDelete)) { throw new CmdLineException(parser, "At least one of -f | -o must be specificed"); } }
int compareNumericAmounts = compareObjectsNullSafe(numericAmount, other.getNumericAmount()); if (compareNumericAmounts != 0) { return compareNumericAmounts;
private int compareDepartments(String department, String otherDepartment) { if (NullUtils.anyNull(department, otherDepartment)) { return NullUtils.compareNulls(department, otherDepartment); } return department.compareTo(otherDepartment); }
private void validateArgs(CmdLineParser parser) throws CmdLineException { if (NullUtils.allNull(clientDetailsId, doAll, clientIdsFile)) { throw new CmdLineException(parser, "At least one of -c | -a | -f must be specificed"); } }