Creates a List of JavaFX CssMetaData instances that is merged by the given parameters - Java JavaFX

Java examples for JavaFX:CSS

Description

Creates a List of JavaFX CssMetaData instances that is merged by the given parameters

Demo Code


//package com.java2s;
import javafx.css.*;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    /**//  w w w .  j a v a 2s .c om
     * Creates a List of CssMetaData instances that is merged by the given parameters
     * @param baseList A basic list. All elements of the list will be in the returned list
     * @param metaData An array of CssMetaData instances. All instances will be in the returned list
     * @return A list with all given CssMetaData instances
     */
    public static List<CssMetaData<? extends Styleable, ?>> createCssMetaDataList(
            List<CssMetaData<? extends Styleable, ?>> baseList,
            CssMetaData<? extends Styleable, ?>... metaData) {
        List<CssMetaData<? extends Styleable, ?>> styleables = new ArrayList<>(
                baseList);
        styleables.addAll(Arrays.asList(metaData));
        return Collections.unmodifiableList(styleables);
    }

    /**
     * Creates a List of CssMetaData instances that is merged by the given parameters
     * @param metaData An array of CssMetaData instances. All instances will be in the returned list
     * @return A list with all given CssMetaData instances
     */
    public static List<CssMetaData<? extends Styleable, ?>> createCssMetaDataList(
            CssMetaData<? extends Styleable, ?>... metaData) {
        return createCssMetaDataList(new ArrayList<>(), metaData);
    }
}

Related Tutorials