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

aQute.bnd.build.model.conversions.DefaultBooleanFormatter Maven / Gradle / Ivy

The newest version!
package aQute.bnd.build.model.conversions;

/**
 * Formatter for booleans with a default value; if the input value matches the
 * default then it is formatted to null.
 * 
 * @author Neil Bartlett
 */
public class DefaultBooleanFormatter implements Converter {

	private final boolean defaultValue;

	public DefaultBooleanFormatter(boolean defaultValue) {
		this.defaultValue = defaultValue;
	}

	@Override
	public String convert(Boolean input) throws IllegalArgumentException {
		String result = null;

		if (input != null && input.booleanValue() != defaultValue)
			result = input.toString();

		return result;
	}

	@Override
	public String error(String msg) {
		return msg;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy