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

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

There is a newer version: 5.0.0-rc.1
Show newest version
package io.dropwizard.jersey.params;

import com.google.common.base.Strings;

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(String input) {
        super(input);
    }

    @Override
    protected Optional parse(String input) throws Exception {
        return Optional.ofNullable(Strings.emptyToNull(input));
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy