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:com.mac.holdempoker.app.impl.util.HandMatrix.java

private boolean hasValidHand() {
    int count = 0;
    for (Integer rCount : rankHistogram.values()) {
        if (Objects.nonNull(rCount)) {
            count += rCount;/*from  w  w  w  .  j  a  va 2 s  . c  om*/
            if (count >= 5 && count <= 7) {
                return true;
            }
        }
    }
    return false;
}

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

boolean isResourceTypeSupported(Resource resource, List<String> supportedTypes) {
    return Objects.nonNull(resource) && supportedTypes.contains(resource.getType());
}

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

private void closeConnections(LdapContext ctx, StartTlsResponse tls) {
    if (Objects.nonNull(tls)) {
        try {/*from   www . j a  v a  2  s  .c  om*/
            // Tear down TLS connection
            tls.close();
        } catch (IOException e) {
            logger.error(e.getMessage(), e);
        }
    }
    if (Objects.nonNull(ctx)) {
        try {
            // Close LDAP connection
            ctx.close();
        } catch (NamingException e) {
            logger.error(e.getMessage(), e);
        }
    }
}

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

/**
 * Checks if scheduler's time data satisfies existing time parameters.
 *
 * @param dto           scheduler job data.
 * @param dateTime      existing time data.
 * @param desiredStatus target exploratory status which has influence for time/date checking ('running' status
 *                      requires for checking start time, 'stopped' - for end time, 'terminated' - for
 *                      'terminatedDateTime').
 * @return true/false./*from www  .  ja v  a  2  s.co m*/
 */
private boolean isSchedulerJobDtoSatisfyCondition(SchedulerJobDTO dto, OffsetDateTime dateTime,
        UserInstanceStatus desiredStatus) {
    ZoneOffset zOffset = dto.getTimeZoneOffset();
    OffsetDateTime roundedDateTime = OffsetDateTime.of(dateTime.toLocalDate(),
            LocalTime.of(dateTime.toLocalTime().getHour(), dateTime.toLocalTime().getMinute()),
            dateTime.getOffset());

    LocalDateTime convertedDateTime = ZonedDateTime
            .ofInstant(roundedDateTime.toInstant(), ZoneId.ofOffset(TIMEZONE_PREFIX, zOffset))
            .toLocalDateTime();

    return desiredStatus == TERMINATED
            ? Objects.nonNull(dto.getTerminateDateTime())
                    && convertedDateTime.toLocalDate().equals(dto.getTerminateDateTime().toLocalDate())
                    && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus))
            : !convertedDateTime.toLocalDate().isBefore(dto.getBeginDate())
                    && isFinishDateMatchesCondition(dto, convertedDateTime)
                    && getDaysRepeat(dto, desiredStatus)
                            .contains(convertedDateTime.toLocalDate().getDayOfWeek())
                    && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus));
}

From source file:org.kuali.kra.award.AwardForm.java

private void initializeAccountBean() {
    accountInformationBean = new AccountInformationBean();
    if (getAwardDocument().getAward().getAccountNumber() != null && isFinancialRestApiEnabled()) {
        AwardAccount account = getAccountFromQueue();
        if (Objects.nonNull(account)) {
            accountInformationBean.setIncome(account.getIncome());
            accountInformationBean.setBudgeted(account.getBudgeted());
            accountInformationBean.setAvailable(account.getAvailable());
            accountInformationBean.setExpense(account.getExpense());
            accountInformationBean.setPending(account.getPending());
        }/*www . j a va  2  s .  c  o m*/
    }
}

From source file:org.kitodo.production.metadata.MetadataProcessor.java

/**
 * Read metadata./*from  w ww. ja  v  a 2 s .c o m*/
 */
public void readXmlStart() throws IOException {
    currentRepresentativePage = "";
    this.myPrefs = ServiceManager.getRulesetService().getPreferences(this.process.getRuleset());
    // TODO: Make file pattern configurable
    this.image = null;
    this.imageNumber = 1;
    this.imageRotation = 0;
    this.currentTifFolder = null;
    readAllTifFolders();

    /*
     * Dokument einlesen
     */
    this.gdzfile = ServiceManager.getProcessService().readMetadataFile(this.process);
    this.digitalDocument = this.gdzfile.getDigitalDocument();
    this.digitalDocument.addAllContentFiles();
    this.metaHelper = new MetadataHelper(this.myPrefs);
    this.imageHelper = new ImageHelper(this.myPrefs, this.digitalDocument);

    /*
     * Das Hauptelement ermitteln
     */

    // TODO: think something up, how to handle a not matching ruleset
    // causing logicalDocstruct to be null
    this.logicalTopstruct = this.digitalDocument.getLogicalDocStruct();

    // this exception needs some serious feedback because data is corrupted
    if (this.logicalTopstruct == null) {
        throw new IOException(Helper.getTranslation("metadataError"));
    }

    retrieveAllImages();
    if (ConfigCore.getBooleanParameterOrDefaultValue(ParameterCore.WITH_AUTOMATIC_PAGINATION)
            && (this.digitalDocument.getPhysicalDocStruct() == null
                    || this.digitalDocument.getPhysicalDocStruct().getAllChildren() == null
                    || this.digitalDocument.getPhysicalDocStruct().getAllChildren().isEmpty())) {
        createPagination();
    }

    List<LegacyMetadataHelper> allMetadata = this.digitalDocument.getPhysicalDocStruct().getAllMetadata();
    if (Objects.nonNull(allMetadata)) {
        for (LegacyMetadataHelper md : allMetadata) {
            if (md.getMetadataType().getName().equals("_representative")) {
                try {
                    Integer value = Integer.valueOf(md.getValue());
                    currentRepresentativePage = String.valueOf(value - 1);
                } catch (RuntimeException e) {
                    logger.error(e.getMessage(), e);
                }
            }
        }
    }

    createDefaultValues(this.logicalTopstruct);
    saveMetadataAsBean(this.logicalTopstruct);
    readMetadataAsFirstTree();

}

From source file:org.openecomp.sdc.validation.impl.validators.HeatValidator.java

@SuppressWarnings("unchecked")
private void getSecurityGroupsReferencedResourcesFromOutputs(Set<String> securityGroupsNamesFromOutputsMap,
        Map<String, Output> outputMap, Map<String, Resource> resourceMap) {
    if (MapUtils.isNotEmpty(outputMap)) {
        for (Map.Entry<String, Output> outputEntry : outputMap.entrySet()) {
            Object outputValue = outputEntry.getValue().getValue();
            if (Objects.nonNull(outputValue) && outputValue instanceof Map) {
                String resourceName = (String) ((Map) outputValue)
                        .get(ResourceReferenceFunctions.GET_RESOURCE.getFunction());
                if (Objects.nonNull(resourceName)) {
                    Resource resource = resourceMap.get(resourceName);
                    if (Objects.nonNull(resource) && resource.getType().equals(
                            HeatResourcesTypes.NEUTRON_SECURITY_GROUP_RESOURCE_TYPE.getHeatResource())) {
                        securityGroupsNamesFromOutputsMap.add(outputEntry.getKey());
                    }//from   w  w  w. ja  v a  2 s .co  m
                }
            }
        }
    }
}

From source file:org.kitodo.production.exporter.ExportXmlLog.java

/**
 * Check task for non-open step state and step has a regular user assigned.
 *
 * @param task//  w w w  .ja  v  a 2  s.  co  m
 *            task to check
 * @return boolean
 */
private boolean isNonOpenStateAndHasRegularUser(Task task) {
    return !TaskStatus.OPEN.equals(task.getProcessingStatus()) && Objects.nonNull(task.getProcessingUser())
            && task.getProcessingUser().getId() != 0
            && Objects.nonNull(ServiceManager.getUserService().getFullName(task.getProcessingUser()));
}

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

private boolean isNodeTypeCreated(ServiceTemplate serviceTemplate, String nodeTypeName) {
    return !MapUtils.isEmpty(serviceTemplate.getNode_types())
            && Objects.nonNull(serviceTemplate.getNode_types().get(nodeTypeName));
}

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

public void updateComplaintEscalationIndexValues(final Complaint complaint) {

    // fetch the complaint from index and then update the new fields
    ComplaintIndex complaintIndex = complaintIndexRepository.findByCrnAndCityCode(complaint.getCrn(),
            getCityCode());/*  w  w w.  j a va  2s  .  co  m*/
    beanMapperConfiguration.map(complaint, complaintIndex);

    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;
    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());
    // Update current Functionary Complaint index variables
    complaintIndex.setCurrentFunctionaryName(assignedUser != null
            ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName()
            : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName());
    complaintIndex.setCurrentFunctionaryMobileNumber(
            Objects.nonNull(assignedUser) ? assignedUser.getMobileNumber() : EMPTY);
    complaintIndex.setCurrentFunctionaryAssigneddate(new Date());
    complaintIndex.setCurrentFunctionarySLADays(getFunctionarySlaDays(complaint));
    complaintIndex = updateComplaintLevelIndexFields(complaintIndex);
    int escalationLevel = complaintIndex.getEscalationLevel();
    // For Escalation level1
    if (escalationLevel == 0) {
        complaintIndex.setEscalation1FunctionaryName(assignedUser != null
                ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName()
                : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName());
        complaintIndex.setEscalation1FunctionaryAssigneddate(new Date());
        complaintIndex.setEscalation1FunctionarySLADays(getFunctionarySlaDays(complaint));
        complaintIndex.setEscalation1FunctionaryAgeingFromDue(0);
        complaintIndex.setEscalation1FunctionaryIsSLA("Y");
        complaintIndex.setEscalation1FunctionaryIfSLA(1);
        complaintIndex.setEscalationLevel(++escalationLevel);
    } else if (escalationLevel == 1) {
        // update escalation level 2 fields
        complaintIndex.setEscalation2FunctionaryName(assignedUser != null
                ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName()
                : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName());
        complaintIndex.setEscalation2FunctionaryAssigneddate(new Date());
        complaintIndex.setEscalation2FunctionarySLADays(getFunctionarySlaDays(complaint));
        complaintIndex.setEscalation2FunctionaryAgeingFromDue(0);
        complaintIndex.setEscalation2FunctionaryIsSLA("Y");
        complaintIndex.setEscalation2FunctionaryIfSLA(1);
        complaintIndex.setEscalationLevel(++escalationLevel);
    } else if (escalationLevel == 2) {
        // update escalation level 3 fields
        complaintIndex.setEscalation3FunctionaryName(assignedUser != null
                ? assignedUser.getName() + " : " + position.getDeptDesig().getDesignation().getName()
                : NOASSIGNMENT + " : " + position.getDeptDesig().getDesignation().getName());
        complaintIndex.setEscalation3FunctionaryAssigneddate(new Date());
        complaintIndex.setEscalation3FunctionarySLADays(getFunctionarySlaDays(complaint));
        complaintIndex.setEscalation3FunctionaryAgeingFromDue(0);
        complaintIndex.setEscalation3FunctionaryIsSLA("Y");
        complaintIndex.setEscalation3FunctionaryIfSLA(1);
        complaintIndex.setEscalationLevel(++escalationLevel);
    }
    complaintIndex = updateEscalationLevelIndexFields(complaintIndex);
    // update status related fields in index
    updateComplaintIndexStatusRelatedFields(complaintIndex);

    complaintIndexRepository.save(complaintIndex);
}