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.amanmehara.programming.android.activities.ProgramActivity.java

private JSONArray filterPrograms(JSONArray programs) {
    JSONArray filtered = new JSONArray();
    for (int i = 0; i < programs.length(); i++) {
        JSONObject program = programs.optJSONObject(i);
        if (Objects.nonNull(program)) {
            String name = program.optString("name");
            String type = program.optString("type");
            if (type.equals(Type.DIRECTORY.getValue()) && !exclusion(name)) {
                filtered.put(program);//from   ww  w  .  j a v a2 s . c o m
            }
        }
    }
    return filtered;
}

From source file:org.openecomp.sdc.heat.services.HeatStructureUtil.java

/**
 * Gets resource def.//from w w  w  .j a  va2s .  c o  m
 *
 * @param filename      the filename
 * @param resourceName  the resource name
 * @param resource      the resource
 * @param globalContext the global context
 * @return the resource def
 */
@SuppressWarnings("unchecked")
public static Resource getResourceDef(String filename, String resourceName, Resource resource,
        GlobalValidationContext globalContext) {
    Resource resourceDef = null;
    Map<String, Object> resourceDefValueMap = resource.getProperties() == null ? null
            : (Map<String, Object>) resource.getProperties()
                    .get(PropertiesMapKeyTypes.RESOURCE_DEF.getKeyMap());
    if (MapUtils.isNotEmpty(resourceDefValueMap)) {
        Object resourceDefType = resourceDefValueMap.get("type");
        if (Objects.nonNull(resourceDefType)) {
            if (resourceDefType instanceof String) {
                boolean isNested = checkIfResourceGroupTypeIsNested(filename, resourceName,
                        (String) resourceDefType, globalContext);
                if (isNested) {
                    resourceDef = new Resource();
                    resourceDef.setType((String) resourceDefType);
                    //noinspection unchecked
                    resourceDef.setProperties((Map<String, Object>) resourceDefValueMap.get("properties"));
                }
            } else {
                globalContext.addMessage(filename, ErrorLevel.WARNING,
                        ErrorMessagesFormatBuilder.getErrorWithParameters(
                                Messages.INVALID_RESOURCE_GROUP_TYPE.getErrorMessage(), resourceName,
                                resourceDefType.toString()));
            }
        } else {
            globalContext.addMessage(filename, ErrorLevel.WARNING,
                    ErrorMessagesFormatBuilder.getErrorWithParameters(
                            Messages.INVALID_RESOURCE_TYPE.getErrorMessage(), "null", resourceName));
        }

    }
    return resourceDef;
}

From source file:com.mac.holdempoker.app.impl.SimpleRound.java

@Override
public void addRoundObserver(RoundObserver ro) {
    if (Objects.nonNull(ro)) {
        observers.add(ro);
    }
}

From source file:org.codice.ddf.security.idp.client.IdpMetadata.java

private Optional<? extends Endpoint> initSingleSomething(List<? extends Endpoint> endpoints) {
    IDPSSODescriptor descriptor = getDescriptor();
    if (descriptor == null) {
        return Optional.empty();
    }//from  w w w  . j  av a  2  s.c  o m

    // Prefer HTTP-Redirect over HTTP-POST if both are present
    return endpoints.stream().filter(Objects::nonNull).filter(s -> Objects.nonNull(s.getBinding())).filter(
            s -> s.getBinding().equals(BINDINGS_HTTP_POST) || s.getBinding().equals(BINDINGS_HTTP_REDIRECT))
            .reduce((acc, val) -> {
                if (acc == null || !BINDINGS_HTTP_REDIRECT.equals(acc.getBinding())) {
                    return val;
                }
                return acc;
            });
}

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

@Override
public void generateId() {
    if (Objects.nonNull(incomeUserId) && Objects.nonNull(incomePaycheckId)) {
        try {// w  w w  . ja v  a2 s .  co m
            normalize(this, getClass().getDeclaredFields());
            Field idField = getClass().getDeclaredField("incomeId");
            generateId(idField, String.valueOf(incomeDate.getTime()), incomeUserId.getUserId(),
                    incomePaycheckId.getGeneratedId());
        } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException
                | SecurityException ex) {
            Logger.getLogger(User.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

From source file:org.kitodo.production.process.TiffHeaderGenerator.java

private String evaluateAdditionalFields(String token) throws ProcessGenerationException {
    StringBuilder newTiffHeader = new StringBuilder();

    for (AdditionalField additionalField : this.additionalFields) {
        String title = additionalField.getTitle();
        String value = additionalField.getValue();
        boolean showDependingOnDoctype = additionalField.showDependingOnDoctype();

        if ("Titel".equals(title) || "Title".equals(title) && !StringUtils.isEmpty(value)) {
            this.tiffHeader = value;
        }/*ww  w .  ja v  a2s  .  c o  m*/
        /*
         * if it is the ATS or TSL field, then use the calculated atstsl if it does not
         * already exist
         */
        if (("ATS".equals(title) || "TSL".equals(title)) && showDependingOnDoctype
                && StringUtils.isEmpty(value)) {
            additionalField.setValue(this.atstsl);
        }

        // add the content to the tiff header
        if (title.equals(token) && showDependingOnDoctype && Objects.nonNull(value)) {
            newTiffHeader.append(calculateProcessTitleCheck(title, value));
        }
    }

    return newTiffHeader.toString();
}

From source file:org.openecomp.sdc.translator.services.heattotosca.helper.VolumeTranslationHelper.java

private Optional<ResourceFileDataAndIDs> getResourceFileDataAndIDsForVolumeConnection(String resourceId,
        TranslateTo translateTo, List<FileData> fileDatas) {
    for (FileData data : fileDatas) {
        HeatOrchestrationTemplate heatOrchestrationTemplate = new YamlUtil().yamlToObject(
                translateTo.getContext().getFiles().getFileContent(data.getFile()),
                HeatOrchestrationTemplate.class);
        Map<String, Output> outputs = heatOrchestrationTemplate.getOutputs();
        if (Objects.isNull(outputs)) {
            continue;
        }//from  ww w . j  av a 2 s.  c o m
        Output output = outputs.get(resourceId);
        if (Objects.nonNull(output)) {
            Optional<AttachedResourceId> attachedOutputId = HeatToToscaUtil.extractAttachedResourceId(
                    data.getFile(), heatOrchestrationTemplate, translateTo.getContext(), output.getValue());
            if (attachedOutputId.isPresent()) {
                AttachedResourceId attachedResourceId = attachedOutputId.get();
                if (!isOutputIsGetResource(resourceId, data, attachedResourceId)) {
                    continue;
                }
                String translatedId = (String) attachedResourceId.getTranslatedId();
                if (isOutputOfTypeCinderVolume(translateTo, data, heatOrchestrationTemplate, translatedId)) {
                    ResourceFileDataAndIDs fileDataAndIDs = new ResourceFileDataAndIDs(
                            (String) attachedResourceId.getEntityId(), translatedId, data);
                    return Optional.of(fileDataAndIDs);
                } else {
                    logger.warn("output: '" + resourceId + "' in file '" + data.getFile() + "' is not of type '"
                            + HeatResourcesTypes.CINDER_VOLUME_RESOURCE_TYPE.getHeatResource() + "'");
                }
            }
        } else {
            logger.warn("output: '" + resourceId + "' in file '" + data.getFile() + "' is not found");
        }
    }
    return Optional.empty();
}

From source file:com.amanmehara.programming.android.activities.LanguageActivity.java

private JSONArray filterLanguages(JSONArray languages) {
    JSONArray filtered = new JSONArray();
    for (int i = 0; i < languages.length(); i++) {
        JSONObject language = languages.optJSONObject(i);
        if (Objects.nonNull(language)) {
            String type = language.optString("type");
            if (type.equals(Type.DIRECTORY.getValue())) {
                filtered.put(language);/*www  .  ja va  2s.c om*/
            }
        }
    }
    return filtered;
}

From source file:de.hybris.platform.mpintgomsbackoffice.actions.sync.SyncToMarketplaceAction.java

@Override
public boolean canPerform(final ActionContext<ConsignmentModel> actionContext) {
    final Object data = actionContext.getData();

    ConsignmentModel consignment = null;
    if (data instanceof ConsignmentModel) {
        consignment = (ConsignmentModel) data;
    }//from  w ww.  j  a  va  2s.  com

    // A consignment is not shippable when it is a pickup order or when there is no quantity pending
    if (Objects.isNull(consignment) || Objects.isNull(consignment.getConsignmentEntries())
            || consignment.getConsignmentEntries().stream()
                    .filter(entry -> Objects.nonNull(entry.getQuantityPending()))
                    .mapToLong(ConsignmentEntryModel::getQuantityPending).sum() == 0) {
        return false;
    }

    if (!checkflag(consignment)) {
        return false;
    }

    return true;
}

From source file:com.mac.holdempoker.app.impl.SimpleGameDealer.java

@Override
public void addPlayer(Player player) {
    if (Objects.nonNull(player) && this.players.size() < 4) {
        this.players.add(player);
    }//from  w w  w .j av a  2 s .com
    if (this.players.size() == 2) {
        dealAround();
    }
}