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

org.jpmml.xjc.XJCUtil Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version
/*
 * Copyright (c) 2013 KNIME.com AG, Zurich, Switzerland
 */
package org.jpmml.xjc;

import java.util.Arrays;
import java.util.function.Predicate;

import com.sun.tools.xjc.outline.FieldOutline;

public class XJCUtil {

	private XJCUtil(){
	}

	static
	public FieldOutline findSingletonField(FieldOutline[] fieldOutlines, Predicate predicate){
		FieldOutline[] acceptedFieldOutlines = filterFields(fieldOutlines, predicate);

		if(acceptedFieldOutlines.length == 0){
			return null;
		} else

		if(acceptedFieldOutlines.length == 1){
			return acceptedFieldOutlines[0];
		} else

		{
			throw new IllegalArgumentException();
		}
	}

	static
	public FieldOutline[] filterFields(FieldOutline[] fieldOutlines, Predicate predicate){
		return Arrays.stream(fieldOutlines).filter(predicate).toArray(FieldOutline[]::new);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy