org.jpmml.translator.MapValuesTranslator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of pmml-transpiler Show documentation
Show all versions of pmml-transpiler Show documentation
JPMML class model transpiler
/*
* Copyright (c) 2021 Villu Ruusmann
*
* This file is part of JPMML-Transpiler
*
* JPMML-Transpiler 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-Transpiler 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-Transpiler. If not, see .
*/
package org.jpmml.translator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import com.google.common.collect.Iterables;
import com.google.common.collect.Table;
import com.sun.codemodel.JDefinedClass;
import com.sun.codemodel.JExpr;
import com.sun.codemodel.JInvocation;
import com.sun.codemodel.JMethod;
import com.sun.codemodel.JOp;
import com.sun.codemodel.JVar;
import org.dmg.pmml.DataType;
import org.dmg.pmml.FieldColumnPair;
import org.dmg.pmml.InlineTable;
import org.dmg.pmml.MapValues;
import org.dmg.pmml.OpType;
import org.jpmml.evaluator.FieldValue;
import org.jpmml.evaluator.FieldValueUtil;
import org.jpmml.evaluator.InlineTableUtil;
import org.jpmml.evaluator.TypeUtil;
import org.jpmml.model.InvalidElementException;
import org.jpmml.model.UnsupportedElementException;
public class MapValuesTranslator extends ExpressionTranslator {
public MapValuesTranslator(MapValues mapValues){
super(mapValues);
List fieldColumnPairs = mapValues.getFieldColumnPairs();
if(fieldColumnPairs.size() != 1){
throw new UnsupportedElementException(mapValues);
}
}
@Override
public void translateExpression(TranslationContext context){
JDefinedClass owner = context.getOwner();
MapValues mapValues = getExpression();
InlineTable inlineTable = InlineTableUtil.getInlineTable(mapValues);
List fieldColumnPairs = mapValues.getFieldColumnPairs();
FieldColumnPair fieldColumnPair = Iterables.getOnlyElement(fieldColumnPairs);
Map
© 2015 - 2024 Weber Informatics LLC | Privacy Policy