Example usage for java.util Objects nonNull

List of usage examples for java.util Objects nonNull

Introduction

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

Prototype

public static boolean nonNull(Object obj) 

Source Link

Document

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

Usage

From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java

public double[] getSunZenithAnglesRad() {
    if (Objects.nonNull(sunZenithAnglesRad)) {
        return sunZenithAnglesRad;
    }/*from   w  w  w .  j a  va 2s. c  o m*/
    throw new NullPointerException("The sun zenith angles is null.");
}

From source file:org.kitodo.production.plugin.importer.massimport.PicaMassImport.java

private void readIdentifier(LegacyDocStructHelperInterface child, LegacyDocStructHelperInterface logicalDS) {
    LegacyMetadataTypeHelper identifierType = prefs.getMetadataTypeByName("CatalogIDDigital");
    List<? extends LegacyMetadataHelper> childMdList = null;
    List<? extends LegacyMetadataHelper> mdList;
    if (Objects.nonNull(child)) {
        childMdList = child.getAllMetadataByType(identifierType);
    }/*from  w  ww.  j  av a  2  s .  co m*/
    if (Objects.nonNull(childMdList)) {
        mdList = childMdList;
    } else {
        mdList = logicalDS.getAllMetadataByType(identifierType);
    }
    if (Objects.nonNull(mdList) && !mdList.isEmpty()) {
        LegacyMetadataHelper identifier = mdList.get(0);
        currentIdentifier = identifier.getValue();
    } else {
        currentIdentifier = String.valueOf(System.currentTimeMillis());
    }
}

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

/**
 * The function creates label as informative representation that is easy for a
 * person to read and that "textually represents" this batch.
 *
 * @param batch// w w w  .j a  va2  s  . c  o m
 *            for which label is going to be created
 */
public void createLabel(Batch batch) {
    try {
        StringBuilder result = new StringBuilder(
                Objects.nonNull(batch.getTitle()) ? batch.getTitle().length() + 20 : 30);
        result.append(prepareLabel(batch));
        if (Objects.nonNull(batch.getType())) {
            result.append(" [");
            result.append(getTypeTranslated(batch));
            result.append(']');
        }
        batch.setLabel(result.toString());
    } catch (RuntimeException fallback) {
        batch.setLabel("");
    }
}

From source file:com.globocom.grou.report.ts.opentsdb.OpenTSDBClient.java

@SuppressWarnings("unchecked")
@Override/*from www . j av a2  s  .c  om*/
public Map<String, Double> makeReport(Test test) {
    final TreeMap<String, Double> mapOfResult = new TreeMap<>();
    ArrayList<HashMap<String, Object>> metrics = Optional.ofNullable(metrics(test)).orElse(new ArrayList<>());
    metrics.stream().filter(metric -> Objects.nonNull(metric.get("metric"))).forEach(metric -> {
        String key = (String) metric.get("metric");
        String aggr = (String) metric.get("aggr");
        int durationTimeMillis = test.getDurationTimeMillis();
        Map<String, Double> dps = Optional.ofNullable((Map<String, Double>) metric.get("dps"))
                .orElse(Collections.emptyMap());
        final AtomicDouble reduceSum = new AtomicDouble(0.0);
        final AtomicDouble reduceMax = new AtomicDouble(0.0);
        dps.entrySet().stream().mapToDouble(Map.Entry::getValue).forEach(delta -> {
            reduceSum.addAndGet(delta);
            if (reduceMax.get() < delta)
                reduceMax.set(delta);
        });
        double value = reduceSum.get();
        double max = reduceMax.get();
        if (!Double.isNaN(value)) {
            if ("sum".equals(aggr)) {
                int durationTimeSecs = durationTimeMillis / 1000;
                double avg = value / (double) durationTimeSecs;
                mapOfResult.put(key + " (total)", formatValue(value));
                mapOfResult.put(key + " (avg tps)", formatValue(avg));
                mapOfResult.put(key + " (max tps)",
                        formatValue(max / Math.max(1.0, (double) durationTimeSecs / (double) NUM_SAMPLES)));
            } else {
                value = value / (double) dps.size();
                mapOfResult.put(key, formatValue(value));
            }
        }
    });
    if (mapOfResult.isEmpty())
        LOGGER.error("Test {}.{}: makeReport return NULL", test.getProject(), test.getName());
    return mapOfResult;
}

From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java

public void setSunZenithAnglesRad(double[] sunZenithAngles) {
    if (Objects.nonNull(sunZenithAngles)) {
        sunZenithAnglesRad = SmileCorrectionUtils.convertDegreesToRadians(sunZenithAngles);
    }// ww w .ja  v a2 s  . c om
    setCosSZARads(sunZenithAnglesRad);
    setSinSZARads(sunZenithAnglesRad);
}

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

private Batch getBatch() {
    if (Objects.nonNull(importFile)) {
        List<String> arguments = new ArrayList<>();
        arguments.add(FilenameUtils.getBaseName(importFile.getAbsolutePath()));
        arguments.add(DateTimeFormat.shortDateTime().print(new DateTime()));
        return new Batch(Helper.getTranslation("importedBatchLabel", arguments), BatchType.LOGISTIC);
    } else {//from  w  w w . j  a v  a  2  s  . com
        return new Batch();
    }
}

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

@Override
public void generateId() {
    if (Objects.nonNull(paycheckOwner)) {
        try {//from  w  w w .  j av  a2  s . c om
            normalize(this, getClass().getDeclaredFields());
            Field idField = getClass().getDeclaredField("paycheckId");
            generateId(idField, paycheckOwner.getUserId(), String.valueOf(paycheckGrossAmount), paycheckSource);
        } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
                | SecurityException ex) {
            Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java

public double[] getViewZenithAnglesRad() {
    if (Objects.nonNull(viewZenithAnglesRad)) {
        return viewZenithAnglesRad;
    }//from www.  ja va  2s.  c  o m
    throw new NullPointerException("The view zenith angles is null.");
}

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

private Collection<View> buildStructureTreeRecursively(IncludedStructuralElement structure, TreeNode result) {

    StructuralElementViewInterface divisionView = dataEditor.getRuleset().getStructuralElementView(
            structure.getType(), dataEditor.getAcquisitionStage(), dataEditor.getPriorityList());
    /*/*w w  w  .  j  ava 2 s .c om*/
     * Creating the tree node by handing over the parent node automatically
     * appends it to the parent as a child. Thats the logic of the JSF
     * framework. So you do not have to add the result anywhere.
     */
    DefaultTreeNode parent = new DefaultTreeNode(
            new StructureTreeNode(this, divisionView.getLabel(), divisionView.isUndefined(), false, structure),
            result);
    parent.setExpanded(true);

    Set<View> viewsShowingOnAChild = new HashSet<>();
    for (IncludedStructuralElement child : structure.getChildren()) {
        viewsShowingOnAChild.addAll(buildStructureTreeRecursively(child, parent));
    }

    if (Boolean.FALSE.equals(separateMedia)) {
        String page = Helper.getTranslation("page").concat(" ");
        for (View view : structure.getViews()) {
            if (!viewsShowingOnAChild.contains(view) && Objects.nonNull(view.getMediaUnit())
                    && Objects.nonNull(view.getMediaUnit().getOrderlabel())) {
                new DefaultTreeNode(new StructureTreeNode(this,
                        page.concat(view.getMediaUnit().getOrderlabel()), false, false, view), parent)
                                .setExpanded(true);
                viewsShowingOnAChild.add(view);
            }
        }
    }
    return viewsShowingOnAChild;
}

From source file:org.esa.s3tbx.olci.radiometry.rayleigh.RayleighAux.java

public void setViewZenithAnglesRad(double[] viewZenithAngles) {
    if (Objects.nonNull(viewZenithAngles)) {
        viewZenithAnglesRad = SmileCorrectionUtils.convertDegreesToRadians(viewZenithAngles);
    }/*  ww w.  j  av  a 2  s  .  c  o  m*/
    setCosOZARads(viewZenithAnglesRad);
    setSinOZARads(viewZenithAnglesRad);
}