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

net.jbock.convert.matcher.OptionalPrimitive Maven / Gradle / Ivy

There is a newer version: 5.18
Show newest version
package net.jbock.convert.matcher;

import com.squareup.javapoet.CodeBlock;

import java.util.OptionalDouble;
import java.util.OptionalInt;
import java.util.OptionalLong;

enum OptionalPrimitive {

    INT(OptionalInt.class, Integer.class),
    LONG(OptionalLong.class, Long.class),
    DOUBLE(OptionalDouble.class, Double.class);

    private final Class type;
    private final String numberType;

    OptionalPrimitive(Class type, Class numberType) {
        this.type = type;
        this.numberType = numberType.getCanonicalName();
    }

    CodeBlock extractExpr() {
        return CodeBlock.of(".map($1T::of).orElse($1T.empty())", type);
    }

    String type() {
        return type.getCanonicalName();
    }

    String numberType() {
        return numberType;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy