Java Code Examples for org.apache.commons.lang3.ObjectUtils#defaultIfNull()

The following examples show how to use org.apache.commons.lang3.ObjectUtils#defaultIfNull() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActionReport.java    From sailfish-core with Apache License 2.0 6 votes vote down vote up
@Override
public void close() {
    if(child != null) {
        throw new RuntimeException("Cannot close parent report while embedded report is open");
    }

    if(parent == null) {
        return;
    }

    parent.elementStats.add(getResultStatus(elementStats));
    parent.description = ObjectUtils.defaultIfNull(parent.description, description);
    parent.child = null;

    report.closeGroup(getStatusDescription());
}
 
Example 2
Source File: Version.java    From sailfish-core with Apache License 2.0 6 votes vote down vote up
/**
 * @param versionFile - file with VERSION content from plugin
 */
public static Version loadVersion(File versionFile) throws IOException {
    try (InputStream inputStream = new BufferedInputStream(new FileInputStream(versionFile))) {
        Properties properties = new Properties();

        properties.load(inputStream);
        String version = Objects.requireNonNull(properties.getProperty("version"), "'version' property is missing");

        Matcher matcher = VERSION_PATTERN.matcher(version);
        if (!matcher.matches()) {
            throw new IllegalArgumentException("'version' property has incorrect format. Actual '" + version + "', Expected '" + VERSION_REGEX + "'");
        }

        return new Version(
            MAJOR.extractComponent(matcher),
            MINOR.extractComponent(matcher),
            MAINTENANCE.extractComponent(matcher),
            BUILD.extractComponent(matcher),
            Objects.requireNonNull(properties.getProperty("plugin_alias"), "'plugin_alias' property is skipped"),
            Objects.requireNonNull(properties.getProperty("branch"), "'branch' property is skipped"),
            Objects.requireNonNull(properties.getProperty("name"), "'name' property is skipped"),
            ObjectUtils.defaultIfNull(properties.getProperty("plugin_version"), "std"),
            BooleanUtils.toBoolean(properties.getProperty("lightweight"))
        );
    }
}
 
Example 3
Source File: RubiconBidder.java    From prebid-server-java with Apache License 2.0 5 votes vote down vote up
private Banner makeBanner(Banner banner, List<Format> overriddenSizes) {
    final List<Format> sizes = ObjectUtils.defaultIfNull(overriddenSizes, banner.getFormat());
    if (CollectionUtils.isEmpty(sizes)) {
        throw new PreBidException("rubicon imps must have at least one imp.format element");
    }

    return banner.toBuilder()
            .format(sizes)
            .ext(mapper.mapper().valueToTree(makeBannerExt(sizes)))
            .build();
}
 
Example 4
Source File: StatisticScriptReport.java    From sailfish-core with Apache License 2.0 4 votes vote down vote up
private String extractFailReason(Throwable t) {
    Throwable root = ExceptionUtils.getRootCause(t);
    t = ObjectUtils.defaultIfNull(root, t);
    return t != null ? t.getMessage() : null;
}
 
Example 5
Source File: Hook.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public Hook setParameters(Map<String, Object> parameters) {
    this.parameters = ObjectUtils.defaultIfNull(parameters, this.parameters);
    return this;
}
 
Example 6
Source File: Hook.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public Hook setName(String name) {
    this.name = ObjectUtils.defaultIfNull(name, this.name);
    return this;
}
 
Example 7
Source File: ExtensionRequiredDependency.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public ExtensionRequiredDependency setName(String name) {
    this.name = ObjectUtils.defaultIfNull(name, this.name);
    return this;
}
 
Example 8
Source File: AdformBidder.java    From prebid-server-java with Apache License 2.0 4 votes vote down vote up
/**
 * Retrieves ifs from {@link Device}.
 */
private String getIfa(Device device) {
    return device != null ? ObjectUtils.defaultIfNull(device.getIfa(), "") : "";
}
 
Example 9
Source File: AdformBidder.java    From prebid-server-java with Apache License 2.0 4 votes vote down vote up
/**
 * Retrieves userAgent from {@link Device}.
 */
private String getUserAgent(Device device) {
    return device != null ? ObjectUtils.defaultIfNull(device.getUa(), "") : "";
}
 
Example 10
Source File: SecurityManager.java    From beihu-boot with Apache License 2.0 4 votes vote down vote up
public Encryptor encryptor(String algorithm) {
    if (ObjectUtils.defaultIfNull(missingEncryptorCache.getIfPresent(algorithm), false)) {
        return null;
    }
    return encryptorCache.getUnchecked(algorithm);
}
 
Example 11
Source File: ProvidedDependency.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public ProvidedDependency setParametersMetadata(Metadata parametersMetadata) {
    supportedSince(3);
    this.parametersMetadata = ObjectUtils.defaultIfNull(parametersMetadata, this.parametersMetadata);
    return this;
}
 
Example 12
Source File: OperationsTransformer.java    From spring-openapi with MIT License 4 votes vote down vote up
private void mapPut(PutMapping putMapping, Method method, Map<String, Path> operationsMap, String controllerClassName, String baseControllerPath) {
	Operation operation = mapOperation(putMapping.name(), HttpMethod.PUT, method, putMapping.produces(), putMapping.consumes(), controllerClassName);

	String path = ObjectUtils.defaultIfNull(getFirstFromArray(putMapping.value()), getFirstFromArray(putMapping.path()));
	updateOperationsMap(prepareUrl(baseControllerPath, "/", path), operationsMap, pathItem -> pathItem.setPut(operation));
}
 
Example 13
Source File: ExtensionDescriptor.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public ExtensionDescriptor setSchemaVersion(String schemaVersion) {
    this.schemaVersion = ObjectUtils.defaultIfNull(schemaVersion, this.schemaVersion);
    return this;
}
 
Example 14
Source File: Resource.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public Resource setActive(Boolean isActive) {
    supportedSince(3);
    this.isActive = ObjectUtils.defaultIfNull(isActive, this.isActive);
    return this;
}
 
Example 15
Source File: RequiredDependency.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public RequiredDependency setList(String list) {
    this.list = ObjectUtils.defaultIfNull(list, this.list);
    return this;
}
 
Example 16
Source File: Module.java    From multiapps with Apache License 2.0 4 votes vote down vote up
@Override
public Module setParametersMetadata(Metadata parametersMetadata) {
    supportedSince(3);
    this.parametersMetadata = ObjectUtils.defaultIfNull(parametersMetadata, this.parametersMetadata);
    return this;
}
 
Example 17
Source File: Platform.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public Platform setResourceTypes(List<ResourceType> resourceTypes) {
    this.resourceTypes = ObjectUtils.defaultIfNull(resourceTypes, this.resourceTypes);
    return this;
}
 
Example 18
Source File: ExtensionProvidedDependency.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public ExtensionProvidedDependency setProperties(Map<String, Object> properties) {
    this.properties = ObjectUtils.defaultIfNull(properties, this.properties);
    return this;
}
 
Example 19
Source File: IssuesTotalColumn.java    From warnings-ng-plugin with MIT License 4 votes vote down vote up
private LabelProviderFactory getLabelProviderFactory() {
    return ObjectUtils.defaultIfNull(labelProviderFactory, new LabelProviderFactory());
}
 
Example 20
Source File: RequiredDependency.java    From multiapps with Apache License 2.0 4 votes vote down vote up
public RequiredDependency setName(String name) {
    this.name = ObjectUtils.defaultIfNull(name, this.name);
    return this;
}