Example usage for java.util Objects isNull

List of usage examples for java.util Objects isNull

Introduction

In this page you can find the example usage for java.util Objects isNull.

Prototype

public static boolean isNull(Object obj) 

Source Link

Document

Returns true if the provided reference is null otherwise returns false .

Usage

From source file:org.kitodo.filemanagement.FileManagement.java

/**
 * Get part of URI specific for process and process sub type.
 *
 * @param processTitle/* w  ww .jav a  2s.co  m*/
 *            tile of process
 * @param processSubType
 *            object
 * @param resourceName
 *            as String
 * @return process specific part of URI
 */
private String getProcessSubType(String processID, String processTitle, ProcessSubType processSubType,
        String resourceName) {
    processTitle = encodeTitle(processTitle);
    final String ocr = "/ocr/";
    if (Objects.isNull(resourceName)) {
        resourceName = "";
    }

    switch (processSubType) {
    case IMAGE:
        return processID + "/" + IMAGES_DIRECTORY_NAME + "/" + resourceName;
    case IMAGE_SOURCE:
        return getSourceDirectory(processID, processTitle) + resourceName;
    case META_XML:
        return processID + "/meta.xml";
    case TEMPLATE:
        return processID + "/template.xml";
    case IMPORT:
        return processID + "/import/" + resourceName;
    case OCR:
        return processID + ocr;
    case OCR_PDF:
        return processID + ocr + processTitle + "_pdf/" + resourceName;
    case OCR_TXT:
        return processID + ocr + processTitle + "_txt/" + resourceName;
    case OCR_WORD:
        return processID + ocr + processTitle + "_wc/" + resourceName;
    case OCR_ALTO:
        return processID + ocr + processTitle + "_alto/" + resourceName;
    default:
        return "";
    }
}

From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java

private Rank getHighestRank() {
    Rank highestRank = null;/*  ww w  . j  av  a 2 s .  com*/
    for (Entry<Rank, Integer> entry : rankHistogram.entrySet()) {
        if (entry.getValue() >= 1) {
            if (Objects.isNull(highestRank)) {
                highestRank = entry.getKey();
            } else {
                if (entry.getKey().value() > highestRank.value()) {
                    highestRank = entry.getKey();
                }
            }
        }
    }
    return highestRank;
}

From source file:org.openecomp.sdc.validation.impl.util.ResourceValidationHeatValidator.java

@SuppressWarnings("unchecked")
private static void validateAllSecurityGroupsAreUsed(String filename, Map.Entry<String, Resource> resourceEntry,
        List<String> securityGroupResourceNameList, GlobalValidationContext globalContext) {
    Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties();

    if (MapUtils.isEmpty(propertiesMap)) {
        return;/*from   w  w w  .jav a  2 s . c om*/
    }

    Object securityGroupsValue = propertiesMap.get("security_groups");

    if (Objects.isNull(securityGroupsValue)) {
        return;
    }

    if (securityGroupsValue instanceof List) {
        List<Object> securityGroupsListFromCurrResource = (List<Object>) propertiesMap.get("security_groups");
        for (Object securityGroup : securityGroupsListFromCurrResource) {
            removeSecurityGroupNamesFromListByGivenFunction(filename,
                    ResourceReferenceFunctions.GET_RESOURCE.getFunction(), securityGroup,
                    securityGroupResourceNameList, globalContext);
        }
    }
}

From source file:org.eclipse.winery.accountability.AccountabilityManagerImpl.java

protected ProvenanceVerification verifyFileInManifest(ModelProvenanceElement element, String fileId,
        String checksum) throws SerializationException {
    // 1. parse element.state as ManifestContent
    ManifestContents manifestContents = new RecoveringManifestParser().parse(element.getFingerprint());

    if (manifestContents.getSectionNames().contains(fileId)) {
        String storedHash = manifestContents.getAttributesForSection(fileId).get(TOSCAMetaFileAttributes.HASH);
        if (Objects.isNull(storedHash)) {
            return NO_HASH_AVAILABLE;
        } else if (storedHash.equals(checksum)) {
            // 2.1 if section == fileId and hash == checksum -> file verified
            return VERIFIED;
        } else {//from w w w. j a  va2  s  .c  om
            return INVALID;
        }
    }

    return ID_NOT_FOUND;
}

From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java

private Rank getHighestSingleRank() {
    Rank highestRank = null;/*ww w .j  a  va  2s . c  om*/
    for (Entry<Rank, Integer> entry : rankHistogram.entrySet()) {
        if (entry.getValue() == 1) {
            if (Objects.isNull(highestRank)) {
                highestRank = entry.getKey();
            } else {
                if (entry.getKey().value() > highestRank.value()) {
                    highestRank = entry.getKey();
                }
            }
        }
    }
    return highestRank;
}

From source file:com.mac.holdempoker.app.impl.util.HandMatrix.java

private Rank getNextHighestRank(Rank rank) {
    Rank nextHighestRank = null;//from ww  w . j av a  2  s. com
    Set<Rank> keys = rankHistogram.keySet();
    Rank[] ranks = keys.toArray(new Rank[keys.size()]);
    ArrayUtils.reverse(ranks);

    for (Rank r : ranks) {
        Integer val = rankHistogram.get(r);
        if (Objects.nonNull(val)) {
            if (val >= 1) {
                if (Objects.isNull(nextHighestRank)) {
                    nextHighestRank = r;
                } else {
                    if (r.value() < rank.value()) {
                        return r;
                    }
                }
            }
        }
    }
    return nextHighestRank;
}

From source file:org.kitodo.production.services.data.TaskService.java

/**
 * Execute script for task./*w  w  w  .  ja va 2  s .  c  o  m*/
 *
 * @param task
 *            object
 * @param script
 *            String
 * @param automatic
 *            boolean
 * @return int
 */
public boolean executeScript(Task task, String script, boolean automatic) throws DataException {
    if (Objects.isNull(script) || script.isEmpty()) {
        return false;
    }
    script = script.replace("{", "(").replace("}", ")");
    LegacyMetsModsDigitalDocumentHelper dd = null;
    Process po = task.getProcess();

    LegacyPrefsHelper prefs = ServiceManager.getRulesetService().getPreferences(po.getRuleset());

    try {
        dd = ServiceManager.getProcessService()
                .readMetadataFile(ServiceManager.getFileService().getMetadataFilePath(po), prefs)
                .getDigitalDocument();
    } catch (IOException e2) {
        logger.error(e2);
    }
    VariableReplacer replacer = new VariableReplacer(dd, prefs, po, task);

    script = replacer.replace(script);
    boolean executedSuccessful = false;
    try {
        logger.info("Calling the shell: {}", script);

        CommandService commandService = ServiceManager.getCommandService();
        CommandResult commandResult = commandService.runCommand(script);
        executedSuccessful = commandResult.isSuccessful();
        finishOrReturnAutomaticTask(task, automatic, commandResult.isSuccessful());
    } catch (IOException e) {
        Helper.setErrorMessage(e.getLocalizedMessage(), logger, e);
    }
    return executedSuccessful;
}

From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java

private boolean areSchedulersEqualForSyncStarting(SchedulerJobDTO notebookScheduler,
        SchedulerJobDTO clusterScheduler) {
    return !Objects.isNull(notebookScheduler) && !Objects.isNull(clusterScheduler)
            && notebookScheduler.getBeginDate().equals(clusterScheduler.getBeginDate())
            && notebookScheduler.getStartTime().equals(clusterScheduler.getStartTime())
            && areCollectionsEqual(notebookScheduler.getStartDaysRepeat(),
                    clusterScheduler.getStartDaysRepeat())
            && notebookScheduler.getTimeZoneOffset().equals(clusterScheduler.getTimeZoneOffset())
            && notebookScheduler.isSyncStartRequired() && clusterScheduler.isSyncStartRequired();
}

From source file:org.kitodo.production.forms.dataeditor.FieldedMetadataTableRow.java

/**
 * Reads the contents of the meta-data panel and stores the values in the
 * appropriate place. If the line is used to edit a field of the METS
 * structure, this field is set, otherwise the meta-data will be stored in
 * the list. The hidden meta-data is also written back there again.
 *
 * @throws InvalidMetadataValueException
 *             if the content of a meta-data input field is syntactically
 *             wrong/*  w w w . j  a  v  a2s .c  o m*/
 * @throws NoSuchMetadataFieldException
 *             if an input shall be saved to a field of the structure, but
 *             there is no setter corresponding to the name configured in
 *             the rule set
 */
void preserve() throws InvalidMetadataValueException, NoSuchMetadataFieldException {
    try {
        metadata.clear();
        for (MetadataTableRow row : rows) {
            Pair<Method, Object> metsFieldValue = row.getStructureFieldValue();
            if (Objects.nonNull(metsFieldValue)) {
                try {
                    metsFieldValue.getKey().invoke(structure, metsFieldValue.getValue());
                } catch (IllegalAccessException | InvocationTargetException e) {
                    throw new IllegalStateException(e);
                }
            } else {
                metadata.addAll(row.getMetadata());
            }
        }
        metadata.addAll(hiddenMetadata);
    } catch (InvalidMetadataValueException invalidValueException) {
        if (Objects.isNull(structure)) {
            invalidValueException.addParent(metadataView.getId());
        }
        throw invalidValueException;
    }
}

From source file:org.kitodo.production.forms.MassImportForm.java

/**
 * Get format.// w  w  w.  j  av a2  s  .com
 *
 * @return the format
 */
public String getFormat() {
    if (Objects.isNull(this.format)) {
        return null;
    }
    return this.format.getTitle();
}