Search in sources :

Example 1 with PlatformPredicate

use of com.oracle.bedrock.runtime.options.PlatformPredicate in project oracle-bedrock by coherence-community.

the class StaticInfrastructure method getPlatform.

@Override
public Platform getPlatform(Option... options) {
    OptionsByType optionsByType = OptionsByType.of(options);
    PlatformPredicate predicate = optionsByType.getOrDefault(PlatformPredicate.class, PlatformPredicate.any());
    Optional<Platform> platform = platforms.stream().filter(predicate).unordered().findFirst();
    return platform.isPresent() ? platform.get() : null;
}
Also used : PlatformPredicate(com.oracle.bedrock.runtime.options.PlatformPredicate) OptionsByType(com.oracle.bedrock.OptionsByType)

Example 2 with PlatformPredicate

use of com.oracle.bedrock.runtime.options.PlatformPredicate in project oracle-bedrock by coherence-community.

the class Infrastructure method local.

/**
 * Obtains {@link Infrastructure} represents the {@link LocalPlatform}.
 * <p>
 * All calls to {@link #getPlatform(Option...)} will attempt to match against
 * the {@link LocalPlatform}.
 *
 * @return  {@link Infrastructure} representing the {@link LocalPlatform}
 */
static Infrastructure local() {
    return (options -> {
        // obtain the PlatformPredicate (just in case one has been provided)
        OptionsByType optionsByType = OptionsByType.of(options);
        // assume using the LocalPlatform if there's no predicate
        PlatformPredicate predicate = optionsByType.getOrDefault(PlatformPredicate.class, PlatformPredicate.isLocal());
        // only return the LocalPlatform if the predicate matches
        return predicate.test(LocalPlatform.get()) ? LocalPlatform.get() : null;
    });
}
Also used : PlatformPredicate(com.oracle.bedrock.runtime.options.PlatformPredicate) OptionsByType(com.oracle.bedrock.OptionsByType)

Example 3 with PlatformPredicate

use of com.oracle.bedrock.runtime.options.PlatformPredicate in project oracle-bedrock by coherence-community.

the class Platform method getPlatform.

@Override
default Platform getPlatform(Option... options) {
    OptionsByType platformOptions = OptionsByType.of(options);
    PlatformPredicate predicate = platformOptions.get(PlatformPredicate.class);
    return predicate.test(this) ? this : null;
}
Also used : PlatformPredicate(com.oracle.bedrock.runtime.options.PlatformPredicate) OptionsByType(com.oracle.bedrock.OptionsByType)

Aggregations

OptionsByType (com.oracle.bedrock.OptionsByType)3 PlatformPredicate (com.oracle.bedrock.runtime.options.PlatformPredicate)3