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

org.dmg.pmml.adapters.ProbabilityNumberAdapter Maven / Gradle / Ivy

There is a newer version: 1.6.5
Show newest version
/*
 * Copyright (c) 2019 Villu Ruusmann
 */
package org.dmg.pmml.adapters;

public class ProbabilityNumberAdapter extends NumberAdapter {

	@Override
	public Number unmarshal(String value){
		Number result = super.unmarshal(value);

		if(!isValid(result)){
			throw new IllegalArgumentException(value);
		}

		return result;
	}

	static
	public boolean isValid(Number value){
		double doubleValue = value.doubleValue();

		return (doubleValue >= 0d && doubleValue <= 1d);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy