Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2014-2014 The Kuali Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ecl2.php Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
 
 package org.kuali.common.core.cli.api;
 
 import static com.google.common.base.Optional.absent;
 import static com.google.common.collect.Lists.newArrayList;
 import static com.google.common.collect.Maps.newHashMap;
 import static org.kuali.common.core.cli.api.PrintStreamStreamConsumer.systemErr;
 import static org.kuali.common.core.cli.api.PrintStreamStreamConsumer.systemOut;
 import static org.kuali.common.util.base.Precondition.checkMin;
 
 import java.io.File;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 
 
 
 public final class ExecRequest {
 
 	private final Optional<InputStreamstdin;
 	private final String executable;
 	private final ImmutableList<Stringargs;
 	private final Optional<IntegertimeoutInSeconds;
 	private final Optional<FileworkingDirectory;
 	private final StreamConsumer stdout;
 	private final StreamConsumer stderr;
 	private final boolean addSystemEnvironmentVariables;
 	private final Optional<Stringshell;
 	@Min(1)
 	private final int streamBufferSize;
 	private final ImmutableSet<IntegersuccessCodes;
 
 	private ExecRequest(Builder builder) {
 		this. = builder.stdin;
 		this. = builder.executable;
 		this. = ImmutableList.copyOf(builder.args);
 		this. = builder.timeoutInSeconds;
 		this. = builder.streamBufferSize;
 		this. = builder.workingDirectory;
 		this. = builder.stdout;
 		this. = builder.stderr;
 		this. = builder.addSystemEnvironmentVariables;
 		this. = builder.shell;
 		this. = ImmutableMap.copyOf(builder.environmentVariables);
 		this. = ImmutableSet.copyOf(builder.successCodes);
 	}
 
 	public static ExecRequest build(String executable) {
 		return builder(executable).build();
 	}
 
 	public static Builder builder(String executable) {
 		return new Builder(executable);
 	}
 
 	public static class Builder extends ValidatingBuilder<ExecRequest> {
 
 		// Required
 		private final String executable;
 
 		// Optional
 		private List<Stringargs = newArrayList();
 		private Optional<InputStreamstdin = absent();
 		private StreamConsumer stdout = systemOut();
 		private StreamConsumer stderr = systemErr();
 		private Optional<FileworkingDirectory = absent();
 		private boolean addSystemEnvironmentVariables = false;
 		private Optional<Stringshell = absent();
 		private int streamBufferSize = 1024;
 		private Set<IntegersuccessCodes = ImmutableSet.of(0);
 
 		public Builder(String executable) {
			this. = executable;
		}
		public Builder withSuccessCodes(Set<IntegersuccessCodes) {
			this. = successCodes;
			return this;
		}
		public Builder redirectOutput(StreamConsumer consumer) {
			return withStdout(consumer).withStderr(consumer);
		}
			this. = ImmutableSet.of();
			return this;
		}
		public Builder withEnvironmentVariables(Map<StringStringenvironmentVariables) {
			this. = environmentVariables;
			return this;
		}
		public Builder withStreamBufferSize(int streamBufferSize) {
			this. = streamBufferSize;
			return this;
		}
		public Builder withShell(String shell) {
			this. = Optional.of(shell);
			return this;
		}
		public Builder withStdin(InputStream stdin) {
			this. = Optional.of(stdin);
			return this;
		}
		public Builder withArgs(List<Stringargs) {
			this. = args;
			return this;
		}
		public Builder withTimeoutInSeconds(int timeoutInSeconds) {
			this. = Optional.of(timeoutInSeconds);
			return this;
		}
		public Builder withWorkingDirectory(File workingDirectory) {
			return withWorkingDirectory(Optional.of(workingDirectory));
		}
		public Builder withWorkingDirectory(Optional<FileworkingDirectory) {
			this. = workingDirectory;
			return this;
		}
		public Builder withStdout(StreamConsumer stdout) {
			this. = stdout;
			return this;
		}
		public Builder withStderr(StreamConsumer stderr) {
			this. = stderr;
			return this;
		}
		public Builder withAddSystemEnvironmentVariables(boolean addSystemEnvironmentVariables) {
			this. = addSystemEnvironmentVariables;
			return this;
		}
		public ExecRequest build() {
			ExecRequest instance = validate(new ExecRequest(this));
			// Zero or negative means the same thing as absent() (wait forever), so if they supply a value it must be greater than zero
			checkMin(instance.timeoutInSeconds, 1, "timeoutInSeconds");
			return instance;
		}
	}
		return ;
	}
	public String getExecutable() {
		return ;
	}
	public List<StringgetArgs() {
		return ;
	}
	}
	}
		return ;
	}
		return ;
	}
	public boolean isAddSystemEnvironmentVariables() {
	}
	public Optional<StringgetShell() {
		return ;
	}
	}
	public int getStreamBufferSize() {
	}
		return ;
	}
New to GrepCode? Check out our FAQ X