
io.molr.commons.util.MissionParameters Maven / Gradle / Ivy
package io.molr.commons.util;
import io.molr.commons.domain.MissionParameter;
public final class MissionParameters {
/**
* Provides a default value for the given {@link MissionParameter}
*
* @param param the parameter
* @param the type of the default, returned, value
* @return the default value for the provided {@link MissionParameter}
*/
public static T defaultValueFor(MissionParameter param) {
if (param.defaultValue() != null) {
return param.defaultValue();
}
if (param.placeholder().type().equals(String.class)) {
return (T) "";
}
if (param.placeholder().type().equals(Integer.class)) {
return (T) new Integer(0);
}
if (param.placeholder().type().equals(Double.class)) {
return (T) new Double(0.0);
}
if (param.placeholder().type().equals(Boolean.class)) {
return (T) new Boolean(false);
}
return null;
}
private MissionParameters() {
/* only static ! */
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy