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

org.jpmml.rexp.evaluator.RExpFunctionRegistry Maven / Gradle / Ivy

There is a newer version: 1.6.1
Show newest version
/*
 * Copyright (c) 2024 Villu Ruusmann
 *
 * This file is part of JPMML-R
 *
 * JPMML-R is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * JPMML-R 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 Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with JPMML-R.  If not, see .
 */
package org.jpmml.rexp.evaluator;

import java.util.Collections;
import java.util.Map;
import java.util.Objects;
import java.util.function.Predicate;

import com.google.common.collect.ImmutableMap;
import org.jpmml.evaluator.Function;
import org.jpmml.evaluator.FunctionRegistry;
import org.jpmml.rexp.evaluator.functions.PPois;

/**
 * @see FunctionRegistry
 */
public class RExpFunctionRegistry {

	private RExpFunctionRegistry(){
	}

	static
	public void publish(String name){
		publish(key -> Objects.equals(name, key));
	}

	static
	public void publishAll(){
		publish(key -> true);
	}

	static
	private void publish(Predicate predicate){
		(RExpFunctionRegistry.rexpFunctions.entrySet()).stream()
			.filter(entry -> predicate.test(entry.getKey()))
			.forEach(entry -> FunctionRegistry.putFunction(entry.getKey(), entry.getValue()));

		(RExpFunctionRegistry.rexpFunctionClazzes.entrySet()).stream()
			.filter(entry -> predicate.test(entry.getKey()))
			.forEach(entry -> FunctionRegistry.putFunction(entry.getKey(), entry.getValue()));
	}

	private static final Map rexpFunctions;

	static {
		ImmutableMap.Builder builder = new ImmutableMap.Builder<>();

		builder.put(RExpFunctions.STATS_PPOIS, new PPois());

		rexpFunctions = builder.build();
	}

	private static final Map> rexpFunctionClazzes = Collections.emptyMap();
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy