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

@Override
public boolean delete(URI uri) throws IOException {
    if (Objects.isNull(uri) || uri.getPath().isEmpty()) {
        /*/*from   w  w w .  j a v a  2  s .  com*/
        This exception is thrown when the passed URI is empty or null.
        Using this URI would cause the deletion of the metadata directory.
        */
        throw new IOException("Attempt to delete subdirectory with URI that is empty or null!");
    }
    uri = fileMapper.mapUriToKitodoDataDirectoryUri(uri);
    File file = new File(uri);
    if (file.exists()) {
        if (file.isFile()) {
            return Files.deleteIfExists(file.toPath());
        }
        if (file.isDirectory()) {
            FileUtils.deleteDirectory(file);
            return true;
        }
        return false;
    }
    return true;
}

From source file:org.kitodo.production.process.field.AdditionalField.java

/**
 * Set is document type.//from   w w w  .  ja  v  a 2  s.com
 *
 * @param isDocType
 *            String
 */
public void setIsDocType(String isDocType) {
    this.isDocType = isDocType;
    if (Objects.isNull(this.isDocType)) {
        this.isDocType = "";
    }
}

From source file:org.sleuthkit.autopsy.imagegallery.datamodel.DrawableTagsManager.java

private Object getBookmarkTagName() throws TskCoreException {
    synchronized (autopsyTagsManagerLock) {
        if (Objects.isNull(bookmarkTagName)) {
            bookmarkTagName = getTagName(BOOKMARK);
        }// w  w  w .j  a  v a2  s .  c  o  m
        return bookmarkTagName;
    }
}

From source file:com.caricah.iotracah.datastore.ignitecache.internal.impl.MessageHandler.java

private int getPartitionClientMessageId(String sessionId, boolean isInBound, long id) {

    String queryForCount = "SELECT "
            + "(SELECT MAX(messageId) FROM PublishMessage WHERE clientId = ? AND isInbound = ? AND id < ? ) "
            + "+ (SELECT COUNT(id) FROM PublishMessage WHERE clientId = ? AND isInbound = ? AND id <= ? ) "
            + " AS newId";
    Object[] params = { sessionId, isInBound, id, sessionId, isInBound, id };

    Long currentMax = getByQueryAsValue(Long.class, queryForCount, params).toBlocking().single();
    if (Objects.isNull(currentMax)) {
        return 1;
    } else {//  www.j av a2 s.  com

        return currentMax.intValue();
    }
}

From source file:org.kitodo.production.services.command.KitodoScriptService.java

private boolean executeScript(List<Process> processes) throws DataException {
    // call the correct method via the parameter
    switch (this.parameters.get("action")) {
    case "importFromFileSystem":
        importFromFileSystem(processes);
        break;/* ww  w .j av a2 s.  c o m*/
    case "addRole":
        addRole(processes);
        break;
    case "setTaskProperty":
        setTaskProperty(processes);
        break;
    case "setStepStatus":
        setTaskStatus(processes);
        break;
    case "addShellScriptToStep":
        addShellScriptToStep(processes);
        break;
    case "updateContentFiles":
        updateContentFiles(processes);
        break;
    case "deleteTiffHeaderFile":
        deleteTiffHeaderFile(processes);
        break;
    case "setRuleset":
        setRuleset(processes);
        break;
    case "exportDms":
    case "export":
        exportDms(processes, this.parameters.get("exportImages"));
        break;
    case "doit":
    case "doit2":
        exportDms(processes, String.valueOf(Boolean.FALSE));
        break;
    case "runscript":
        String taskName = this.parameters.get("stepname");
        String scriptName = this.parameters.get(SCRIPT);
        if (Objects.isNull(scriptName)) {
            Helper.setErrorMessage(KITODO_SCRIPT_FIELD, "", "Missing parameter");
            return false;
        } else {
            runScript(processes, taskName, scriptName);
        }
        break;
    case "deleteProcess":
        String value = parameters.get("contentOnly");
        boolean contentOnly = true;
        if (Objects.nonNull(value) && value.equalsIgnoreCase("false")) {
            contentOnly = false;
        }
        deleteProcess(processes, contentOnly);
        break;
    default:
        Helper.setErrorMessage(KITODO_SCRIPT_FIELD, "Unknown action",
                " - use: 'action:addRole, action:setTaskProperty, action:setStepStatus, "
                        + "action:swapprozessesout, action:swapprozessesin, action:deleteTiffHeaderFile, "
                        + "action:importFromFileSystem'");
        return false;
    }
    return true;
}

From source file:co.mafiagame.telegraminterface.outputhandler.TelegramChannel.java

@Override
public void send(ResultMessage resultMessage) {
    if (resultMessage.getChannelType() == ChannelType.NONE)
        return;/*from   w ww  .  j a  v a2s.  c om*/
    TelegramInterfaceContext ic = (TelegramInterfaceContext) resultMessage.getIc();
    for (Message msg : resultMessage.getMessages()) {
        OutputMessageHandler outputMessageHandler = handlers.get(msg.getMessageCode());
        if (Objects.isNull(outputMessageHandler))
            outputMessageHandler = defaultOutputMessageHandler;
        outputMessageHandler.execute(msg, resultMessage.getChannelType(), ic);

    }

    //        sendMessage(msg, resultMessage.getChannelType(), ic);
}

From source file:org.kitodo.api.dataformat.MediaUnit.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }// w  w  w.ja  va  2s  . c om
    if (!(obj instanceof MediaUnit)) {
        return false;
    }
    MediaUnit other = (MediaUnit) obj;
    if (mediaFiles == null) {
        if (other.mediaFiles != null) {
            return false;
        }
    } else if (!mediaFiles.equals(other.mediaFiles)) {
        return false;
    }
    if (order != other.order) {
        return false;
    }
    if (orderlabel == null) {
        if (other.orderlabel != null) {
            return false;
        }
    } else if (!orderlabel.equals(other.orderlabel)) {
        return false;
    }
    if (Objects.isNull(type)) {
        return !Objects.nonNull(other.type);
    } else {
        return type.equals(other.type);
    }
}

From source file:org.kitodo.production.process.field.AdditionalField.java

/**
 * Set is not document type.//from ww w .  j  a v  a2 s  .  c  om
 *
 * @param isNotDoctype
 *            String with list of not document types
 */
public void setIsNotDoctype(String isNotDoctype) {
    this.isNotDoctype = isNotDoctype;
    if (Objects.isNull(this.isNotDoctype)) {
        this.isNotDoctype = "";
    }
}

From source file:com.mac.abstractrepository.entities.budget.Payment.java

@Override
public void generateId() {
    if (Objects.isNull(paymentId) || paymentId.isEmpty()) {
        if (Objects.nonNull(paymentBillId) && Objects.nonNull(paymentUserId)) {
            try {
                normalize(this, getClass().getDeclaredFields());
                Field idField = getClass().getDeclaredField("paymentId");
                generateId(idField, paymentBillId.getBillId(), paymentUserId.getUserId(),
                        String.valueOf(paymentDueDate.getTime()), String.valueOf(paymentFilingDate.getTime()));
            } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
                    | SecurityException ex) {
                Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
            }//w  w  w. java2  s  .  c  om
        }
    }
}

From source file:org.kitodo.export.ExportDms.java

/**
 * Start export./*w w  w .  j a v a 2  s. c  om*/
 *
 * @param process
 *            object
 * @param destination
 *            String
 * @param newFile
 *            DigitalDocument
 * @return boolean
 */
public boolean startExport(Process process, URI destination, LegacyMetsModsDigitalDocumentHelper newFile)
        throws IOException {

    this.myPrefs = ServiceManager.getRulesetService().getPreferences(process.getRuleset());
    this.atsPpnBand = Helper.getNormalizedTitle(process.getTitle());

    LegacyMetsModsDigitalDocumentHelper gdzfile = readDocument(process, newFile);
    if (Objects.isNull(gdzfile)) {
        return false;
    }

    boolean dataCopierResult = executeDataCopierProcess(gdzfile, process);
    if (!dataCopierResult) {
        return false;
    }

    trimAllMetadata(gdzfile.getDigitalDocument().getLogicalDocStruct());

    // validate metadata
    if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.USE_META_DATA_VALIDATION)
            && !ServiceManager.getMetadataValidationService().validate(gdzfile, this.myPrefs, process)) {
        return false;
    }

    return prepareAndDownloadSaveLocation(process, destination, gdzfile);
}