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

io.github.hlfsousa.ncml.examples.ucararray.GroupMapInitializer Maven / Gradle / Ivy

package io.github.hlfsousa.ncml.examples.ucararray;

/*-
 * #%L
 * ncml-io
 * %%
 * Copyright (C) 2020 - 2021 Henrique L. F. de Sousa
 * %%
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation, either version 2.1 of the
 * License, or (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Lesser Public License for more details.
 * 
 * You should have received a copy of the GNU General Lesser Public
 * License along with this program.  If not, see
 * .
 * #L%
 */

// imports >>
import java.util.*;
import java.util.function.Consumer;

import io.github.hlfsousa.ncml.io.ArrayUtils;
import ucar.nc2.Dimension;
import ucar.ma2.Array;
import io.github.hlfsousa.ncml.examples.ucararray.GroupMap.*;
import io.github.hlfsousa.ncml.examples.ucararray.GroupMapVO.*;
// << imports

public class GroupMapInitializer {

    private static final Map> INITIALIZERS = new HashMap<>();

    static {
        INITIALIZERS.put(null, model -> {
            // customGroupInit >>
            // << customGroupInit
        });
        // userGroupInitializers >>
        // << userGroupInitializers
    }

    public static GroupMap initialize(GroupMap value) {
        return initialize(null, value);
    }

    public static GroupMap initialize(String key, GroupMap value) {
        if (value == null) {
            value = new GroupMapVO();
        }
        if (!INITIALIZERS.containsKey(key)) {
            key = null;
        }
        INITIALIZERS.get(key).accept(value);
        return value;
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy