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;
}
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;
});
}
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;
}
Aggregations