Skip to content

Commit

Permalink
introduced right exception for metrcc type null
Browse files Browse the repository at this point in the history
  • Loading branch information
angelo.andreussi authored and Coduz committed Jul 20, 2023
1 parent 6fe286b commit 6ba39ec
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import com.google.common.base.Strings;
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.KapuaIllegalNullArgumentException;
import org.eclipse.kapua.app.api.core.resources.AbstractKapuaResource;
import org.eclipse.kapua.app.api.core.model.CountResult;
import org.eclipse.kapua.app.api.core.model.DateParam;
Expand Down Expand Up @@ -221,11 +222,14 @@ private StorablePredicate getChannelPredicate(String channel, boolean strictChan
return channelPredicate;
}

private <V extends Comparable<V>> StorablePredicate getMetricPredicate(String metricName, MetricType<V> metricType, String metricMinValue, String metricMaxValue) {
private <V extends Comparable<V>> StorablePredicate getMetricPredicate(String metricName, MetricType<V> metricType, String metricMinValue, String metricMaxValue) throws KapuaIllegalNullArgumentException {
if (metricMinValue == null && metricMaxValue == null) {
Class<V> type = metricType != null ? metricType.getType() : null;
return DATASTORE_PREDICATE_FACTORY.newMetricExistsPredicate(metricName, type);
} else {
if (metricType == null) {
throw new KapuaIllegalNullArgumentException("metricType");
}
V minValue = (V) ObjectValueConverter.fromString(metricMinValue, metricType.getType());
V maxValue = (V) ObjectValueConverter.fromString(metricMaxValue, metricType.getType());

Expand Down

0 comments on commit 6ba39ec

Please sign in to comment.