brooklyn.event.feed.ssh.SshValueFunctions Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-core Show documentation
Show all versions of brooklyn-core Show documentation
Entity implementation classes, events, and other core elements
package brooklyn.event.feed.ssh;
import javax.annotation.Nullable;
import com.google.common.base.Function;
import com.google.common.base.Functions;
import com.google.common.base.Predicates;
public class SshValueFunctions {
public static Function exitStatus() {
return new Function() {
@Override public Integer apply(SshPollValue input) {
return input.getExitStatus();
}
};
}
public static Function stdout() {
return new Function() {
@Override public String apply(SshPollValue input) {
return input.getStdout();
}
};
}
public static Function stderr() {
return new Function() {
@Override public String apply(SshPollValue input) {
return input.getStderr();
}
};
}
public static Function exitStatusEquals(final int expected) {
return chain(SshValueFunctions.exitStatus(), Functions.forPredicate(Predicates.equalTo(expected)));
}
// TODO Do we want these chain methods? Does guava have them already? Duplicated in HttpValueFunctions.
public static Function chain(final Function f1, final Function f2) {
return new Function() {
@Override public C apply(@Nullable A input) {
return f2.apply(f1.apply(input));
}
};
}
public static Function chain(final Function f1, final Function f2, final Function f3) {
return new Function() {
@Override public D apply(@Nullable A input) {
return f3.apply(f2.apply(f1.apply(input)));
}
};
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy