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

griffon.javafx.GriffonFXCollectionsExtension.groovy Maven / Gradle / Ivy

The newest version!
/*
 * SPDX-License-Identifier: Apache-2.0
 *
 * Copyright 2008-2021 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 griffon.javafx

import griffon.javafx.collections.GriffonFXCollections
import griffon.javafx.collections.MappingObservableList
import groovy.transform.CompileStatic
import javafx.beans.value.ObservableValue
import javafx.collections.ObservableList
import javafx.collections.ObservableMap
import javafx.collections.ObservableSet

import javax.annotation.Nonnull
import java.util.function.Function

/**
 * @author Andres Almiray
 * @since 2.13.0
 */
@CompileStatic
final class GriffonFXCollectionsExtension {
    @Nonnull
    static  ObservableList uiThreadAware(@Nonnull ObservableList self) {
        return GriffonFXCollections.uiThreadAwareObservableList(self)
    }

    @Nonnull
    static  ObservableSet uiThreadAware(@Nonnull ObservableSet self) {
        return GriffonFXCollections.uiThreadAwareObservableSet(self)
    }

    @Nonnull
    static  ObservableMap uiThreadAware(@Nonnull ObservableMap self) {
        return GriffonFXCollections.uiThreadAwareObservableMap(self)
    }

    @Nonnull
    static  ObservableList mappedWith(@Nonnull ObservableList self, @Nonnull Function mapper) {
        new MappingObservableList(self, mapper)
    }

    @Nonnull
    static  ObservableList mappedWith(
        @Nonnull ObservableList self, @Nonnull ObservableValue> mapper) {
        new MappingObservableList(self, mapper)
    }
}