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

io.dropwizard.jersey.params.NonEmptyStringParam Maven / Gradle / Ivy

package io.dropwizard.jersey.params;

import org.checkerframework.checker.nullness.qual.Nullable;

import java.util.Optional;

/**
 * A parameter encapsulating optional string values with the condition that empty string inputs are
 * interpreted as being absent. This class is useful when it is desired for empty parameters to be
 * synonymous with absent parameters instead of empty parameters evaluating to
 * {@code Optional.of("")}.
 */
public class NonEmptyStringParam extends AbstractParam> {
    public NonEmptyStringParam(@Nullable String input) {
        super(input);
    }

    public NonEmptyStringParam(@Nullable String input, String parameterName) {
        super(input, parameterName);
    }

    @Override
    protected Optional parse(@Nullable String input) {
        return Optional.ofNullable(input).filter(s -> !s.isEmpty());
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy