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.kitodo.production.model.bibliography.course.Course.java

/**
 * The function getIndividualIssues() generates a list of IndividualIssue
 * objects, each of them representing a stamping of one physically appeared
 * issue.//w  ww  .  j a  v  a2 s.  c  o  m
 *
 * @return a LinkedHashSet of IndividualIssue objects, each of them
 *         representing one physically appeared issue
 */
public Set<IndividualIssue> getIndividualIssues() {
    LinkedHashSet<IndividualIssue> result = new LinkedHashSet<>();
    LocalDate lastAppearance = getLastAppearance();
    LocalDate firstAppearance = getFirstAppearance();
    if (Objects.nonNull(firstAppearance)) {
        for (LocalDate day = firstAppearance; !day.isAfter(lastAppearance); day = day.plusDays(1)) {
            for (Block block : this) {
                result.addAll(block.getIndividualIssues(day));
            }
        }
    }
    return result;
}

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

public void setSinSZARads(double[] sunZenithAnglesRad) {
    if (Objects.nonNull(sunZenithAnglesRad)) {
        sinSZARads = Arrays.stream(sunZenithAnglesRad).map(Math::sin).toArray();
    }// w  w w.  ja  v a 2s  .  com
}

From source file:org.kitodo.production.services.image.ImageGenerator.java

/**
 * If the task is started, it will execute this run() method which will
 * start the export on the ExportDms. This task instance is passed in
 * addition so that the ExportDms can update the tasks state.
 *
 * @see org.kitodo.production.helper.tasks.EmptyTask#run()
 *//*www  . java 2  s .  c o m*/
@Override
public void run() {
    do {
        state.accept(this);
        setPosition(getPosition() + 1);
        setProgress();
        if (Objects.nonNull(supervisor) && supervisor.isInterrupted()) {
            return;
        }
    } while (!(state.equals(ImageGeneratorStep.GENERATE_IMAGES)
            && getPosition() == getContentToBeGenerated().size()));
    logger.info("Completed");
}

From source file:org.openecomp.sdc.translator.services.heattotosca.impl.ResourceTranslationBase.java

NodeType getNodeTypeWithFlatHierarchy(String nodeTypeId, ServiceTemplate serviceTemplate,
        TranslationContext context) {//from   w w w  .  ja  v a 2  s  . c  o m
    NodeType nodeType;
    if (serviceTemplate != null && serviceTemplate.getNode_types() != null) {
        nodeType = serviceTemplate.getNode_types().get(nodeTypeId);

        if (nodeType != null) {
            return enrichNodeType(nodeType, serviceTemplate, context);
        }
    }
    Map<String, Map<String, NodeType>> globalNodeTypesMap = new HashMap<>();
    Collection<ServiceTemplate> globalNodeTypes = GlobalTypesGenerator.getGlobalTypesServiceTemplate().values();
    ServiceTemplate nativeNodeTypeServiceTemplate = ToscaNativeTypesServiceTemplate.createServiceTemplate();
    for (ServiceTemplate globalNodeType : globalNodeTypes) {
        globalNodeTypesMap.put(globalNodeType.getMetadata().getTemplate_name(), globalNodeType.getNode_types());
    }
    if (Objects.nonNull(serviceTemplate) && MapUtils.isNotEmpty(serviceTemplate.getImports())) {
        for (Map.Entry<String, Import> entry : serviceTemplate.getImports().entrySet()) {
            if (globalNodeTypesMap.containsKey(entry.getKey())) {
                Map<String, NodeType> nodeTypes = globalNodeTypesMap.get(entry.getKey());
                if (nodeTypes != null && nodeTypes.containsKey(nodeTypeId)) {
                    return enrichNodeType(nodeTypes.get(nodeTypeId), serviceTemplate, context);
                }
            }
            if (context.getGlobalSubstitutionServiceTemplate() != null
                    && context.getGlobalSubstitutionServiceTemplate().getNode_types() != null
                    && context.getGlobalSubstitutionServiceTemplate().getNode_types().containsKey(nodeTypeId)) {
                return enrichNodeType(
                        context.getGlobalSubstitutionServiceTemplate().getNode_types().get(nodeTypeId),
                        serviceTemplate, context);
            }
            if (nativeNodeTypeServiceTemplate.getNode_types().containsKey(nodeTypeId)) {
                return enrichNodeType(nativeNodeTypeServiceTemplate.getNode_types().get(nodeTypeId),
                        serviceTemplate, context);
            }
        }
    }
    return new NodeType();

}

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

public double[] getSinOZARads() {
    if (Objects.nonNull(sinOZARads)) {
        return sinOZARads;
    }//w w w .  j  a va 2  s .c  om
    throw new NullPointerException("The view zenith angles is null.");
}

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

/**
 * Get project(s). If the task belongs to a template, the projects are in
 * the template. If the task belongs to a process, the project is in the
 * process./*  w  ww .  j ava2  s.c  o  m*/
 *
 * @return value of project(s)
 */
public static List<Project> getProjects(Task task) {
    Process process = task.getProcess();
    Template template = task.getTemplate();
    if (Objects.nonNull(process)) {
        return Collections.singletonList(process.getProject());
    } else if (Objects.nonNull(template)) {
        return template.getProjects();
    } else {
        return Collections.emptyList();
    }
}

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

private QueryBuilder createUserProjectQuery() {
    User currentUser = ServiceManager.getUserService().getCurrentUser();

    if (Objects.nonNull(currentUser)) {
        List<Project> projects = currentUser.getProjects();
        return createSetQueryForBeans(ProcessTypeField.PROJECT_ID.getKey(), projects, true);
    }//w w  w  .ja  va2  s . c om

    return null;
}

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

public void setSinOZARads(double[] zenithAnglesRad) {
    if (Objects.nonNull(zenithAnglesRad)) {
        sinOZARads = Arrays.stream(zenithAnglesRad).map(Math::sin).toArray();
    }//www  .  j  av a  2 s . c  o  m
}

From source file:org.egov.pgr.elasticsearch.service.ComplaintIndexService.java

public void createComplaintIndex(final Complaint complaint) {
    final ComplaintIndex complaintIndex = new ComplaintIndex();
    beanMapperConfiguration.map(complaint, complaintIndex);

    final City city = cityService.getCityByURL(ApplicationThreadLocals.getDomainName());
    complaintIndex.setCityCode(city.getCode());
    complaintIndex.setCityDistrictCode(city.getDistrictCode());
    complaintIndex.setCityDistrictName(city.getDistrictName());
    complaintIndex.setCityGrade(city.getGrade());
    complaintIndex.setCityDomainUrl(city.getDomainURL());
    complaintIndex.setCityName(city.getName());
    complaintIndex.setCityRegionName(city.getRegionName());
    complaintIndex.setSource(complaint.getReceivingMode().getName());
    complaintIndex.setClosed(false);//from  ww w.j av a2 s . c om
    complaintIndex.setComplaintIsClosed("N");
    complaintIndex.setIfClosed(0);
    complaintIndex.setComplaintDuration(0);
    complaintIndex.setDurationRange("");
    final Position position = complaint.getAssignee();
    final List<Assignment> assignments = assignmentService.getAssignmentsForPosition(position.getId(),
            new Date());
    final User assignedUser = !assignments.isEmpty() ? assignments.get(0).getEmployee() : null;
    complaintIndex.setComplaintPeriod(0);
    complaintIndex.setComplaintSLADays(complaint.getComplaintType().getSlaHours());
    complaintIndex.setComplaintAgeingFromDue(0);
    complaintIndex.setIsSLA("Y");
    complaintIndex.setIfSLA(1);
    complaintIndex.setInitialFunctionaryName(assignedUser != null
            ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName()
            : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName());
    complaintIndex.setInitialFunctionaryAssigneddate(new Date());
    complaintIndex.setInitialFunctionarySLADays(getFunctionarySlaDays(complaint));
    complaintIndex.setInitialFunctionaryAgeingFromDue(0);
    complaintIndex.setInitialFunctionaryIsSLA("Y");
    complaintIndex.setInitialFunctionaryIfSLA(1);
    complaintIndex.setCurrentFunctionaryName(assignedUser != null
            ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName()
            : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName());
    complaintIndex.setCurrentFunctionaryMobileNumber(
            Objects.nonNull(assignedUser) ? assignedUser.getMobileNumber() : EMPTY);
    complaintIndex.setInitialFunctionaryMobileNumber(
            Objects.nonNull(assignedUser) ? assignedUser.getMobileNumber() : EMPTY);
    complaintIndex.setCurrentFunctionaryAssigneddate(new Date());
    complaintIndex.setCurrentFunctionarySLADays(getFunctionarySlaDays(complaint));
    complaintIndex.setCurrentFunctionaryAgeingFromDue(0);
    complaintIndex.setCurrentFunctionaryIsSLA("Y");
    complaintIndex.setCurrentFunctionaryIfSLA(1);
    complaintIndex.setEscalationLevel(0);
    complaintIndex.setReasonForRejection("");
    complaintIndex.setRegistered(1);
    complaintIndex.setInProcess(1);
    complaintIndex.setAddressed(0);
    complaintIndex.setRejected(0);
    complaintIndex.setReOpened(0);
    // New fields included in PGR Index
    complaintIndex.setComplaintAgeingdaysFromDue(0);

    complaintIndexRepository.save(complaintIndex);
}

From source file:org.kitodo.production.services.image.ImageGenerator.java

/**
 * Calculates and reports the progress of the task.
 *///  w  w  w .j  a v  a 2  s . co m
private void setProgress() {
    if (Objects.nonNull(supervisor)) {
        int checked = state.equals(ImageGeneratorStep.GENERATE_IMAGES)
                ? getMode().equals(GenerationMode.ALL) ? 1 : sources.size()
                : 0;
        int generated = getMode().equals(GenerationMode.ALL)
                && state.equals(ImageGeneratorStep.DETERMINE_WHICH_IMAGES_NEED_TO_BE_GENERATED) ? 0
                        : getPosition();
        int total = sources.size()
                + (getMode().equals(GenerationMode.ALL) ? 1 : getContentToBeGenerated().size()) + 1;
        supervisor.setProgress(100d * (1 + checked + generated) / total);
    }
}