All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.gradle.api.internal.TestNamedProvider.groovy Maven / Gradle / Ivy

There is a newer version: 8.11.1
Show newest version
/*
 * Copyright 2023 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.gradle.api.internal

import org.gradle.api.Named
import org.gradle.api.Transformer
import org.gradle.api.internal.provider.ProviderInternal
import org.gradle.api.internal.provider.ValueSanitizer
import org.gradle.api.internal.tasks.TaskDependencyResolveContext
import org.gradle.api.provider.Provider
import org.gradle.api.specs.Spec
import org.gradle.internal.DisplayName

import java.util.function.BiFunction

class TestNamedProvider implements ProviderInternal, Named {

    private final String name
    private final T t

    TestNamedProvider(String name, T t) {
        this.name = name
        this.t = t
    }

    @Override
    String getName() {
        return name
    }

    @Override
    T get() {
        return T
    }

    @Override
    T getOrNull() {
        return t
    }

    @Override
    T getOrElse(T defaultValue) {
        return t == null ? t : defaultValue
    }

    @Override
    boolean isPresent() {
        return t != null
    }

    @Override
    Provider orElse(T t) {
        throw new UnsupportedOperationException()
    }

    @Override
    Provider orElse(Provider provider) {
        throw new UnsupportedOperationException()
    }

    @Override
    Provider forUseAtConfigurationTime() {
        throw new UnsupportedOperationException()
    }

    @Override
     Provider zip(Provider right, BiFunction combiner) {
        throw new UnsupportedOperationException()
    }

    @Override
    ValueProducer getProducer() {
        throw new UnsupportedOperationException()
    }

    @Override
    boolean calculatePresence(ValueConsumer consumer) {
        throw new UnsupportedOperationException()
    }

    @Override
    void visitDependencies(TaskDependencyResolveContext context) {
        throw new UnsupportedOperationException()
    }

    @Override
    Class getType() {
        return t.class
    }

    @Override
     ProviderInternal map(Transformer transformer) {
        throw new UnsupportedOperationException()
    }

    @Override
    Value calculateValue(ValueConsumer consumer) {
        Value.ofNullable(t)
    }

    @Override
    ProviderInternal asSupplier(DisplayName owner, Class targetType, ValueSanitizer sanitizer) {
        throw new UnsupportedOperationException()
    }

    @Override
    ProviderInternal withFinalValue(ValueConsumer consumer) {
        throw new UnsupportedOperationException()
    }

    @Override
    ExecutionTimeValue calculateExecutionTimeValue() {
        throw new UnsupportedOperationException()
    }

    @Override
    Provider filter(Spec spec) {
        throw new UnsupportedOperationException()
    }

    @Override
     Provider flatMap(Transformer, ? super T> transformer) {
        throw new UnsupportedOperationException()
    }
}