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

org.jpmml.model.visitors.AttributeInterner Maven / Gradle / Ivy

There is a newer version: 1.6.6
Show newest version
/*
 * Copyright (c) 2022 Villu Ruusmann
 */
package org.jpmml.model.visitors;

import java.lang.reflect.Field;
import java.util.List;

import jakarta.xml.bind.annotation.XmlAttribute;
import jakarta.xml.bind.annotation.XmlList;
import org.dmg.pmml.PMMLObject;
import org.dmg.pmml.VisitorAction;
import org.jpmml.model.ReflectionUtil;

abstract
public class AttributeInterner extends Interner {

	public AttributeInterner(Class type){
		super(type);
	}

	@Override
	public VisitorAction visit(PMMLObject object){
		List fields = ReflectionUtil.getFields(object.getClass());

		for(Field field : fields){
			XmlAttribute attribute = field.getAnnotation(XmlAttribute.class);
			XmlList list = field.getAnnotation(XmlList.class);

			if((attribute == null) && (list == null)){
				continue;
			}

			apply(field, object);
		}

		return super.visit(object);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy