private Stream toCommand()

in arthur-impl/src/main/java/org/apache/geronimo/arthur/impl/nativeimage/graal/CommandGenerator.java [59:95]


    private Stream<? extends String> toCommand(final Field field,
                                               final ArthurNativeImageConfiguration.GraalCommandPart config,
                                               final Type genericType,
                                               final Object instance) {
        if (config.passthrough()) {
            if (genericType == String.class) {
                if (instance == null) {
                    return Stream.empty();
                }
                return Stream.of(instance.toString());
            } else if (isCollectionOfString(genericType)) {
                if (instance == null || Collection.class.cast(instance).isEmpty()) {
                    return Stream.empty();
                }
                return ((Collection<String>) instance).stream();
            }
            throw new IllegalArgumentException("@GraalCommandPart(passthrough=true) not supported for " + field);
        }

        if (isCollectionOfString(genericType)) {
            if (instance == null || Collection.class.cast(instance).isEmpty()) {
                return Stream.empty();
            }
            final Collection<String> strings = (Collection<String>) instance;
            return Stream.of(String.format(
                    config.template(),
                    String.join(
                            config.joiner().replace("${File.pathSeparator}", File.pathSeparator),
                            strings)));
        }

        // else assume "primitive"
        if (instance != null && !Boolean.FALSE.equals(instance) /*we skip disabled commands*/) {
            return Stream.of(String.format(config.template(), instance));
        }
        return Stream.empty();
    }