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

org.hidetake.groovy.ssh.interaction.StreamRule.groovy Maven / Gradle / Ivy

There is a newer version: 2.11.2
Show newest version
package org.hidetake.groovy.ssh.interaction

interface StreamRule {
    boolean matches(Stream stream)

    static final anyRule            = [matches: { Stream s -> true }] as StreamRule
    static final standardOutputRule = [matches: { Stream s -> s == Stream.StandardOutput }] as StreamRule
    static final standardErrorRule  = [matches: { Stream s -> s == Stream.StandardError }] as StreamRule

    static class Factory {
        static StreamRule create(fromParameter) {
            switch (fromParameter) {
                case null:                  return anyRule
                case Wildcard:              return anyRule
                case Stream.StandardOutput: return standardOutputRule
                case Stream.StandardError:  return standardErrorRule
                default: throw new IllegalArgumentException("parameter must be Wildcard or Stream: from=$fromParameter")
            }
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy