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

com.orctom.was.model.Command Maven / Gradle / Ivy

Go to download

Common Utils that talks to WebSphere used by was-maven-plugin and was-gradle-plugin

There is a newer version: 1.1.3.2
Show newest version
package com.orctom.was.model;

import com.google.common.base.Strings;
import com.google.common.collect.Maps;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * Shell Command
 * Created by hao on 11/11/15.
 */
public class Command {

	private String executable;
	private String workingDir;
	private String buildScriptPath;
	private Map args = Maps.newLinkedHashMap();

	public Command() {
	}

	public Command(String executable, String workingDir) {
		this.executable = executable;
		this.workingDir = workingDir;
	}

	public String getExecutable() {
		return executable;
	}

	public void setExecutable(String executable) {
		this.executable = executable;
	}

	public String getWorkingDir() {
		return workingDir;
	}

	public void setWorkingDir(String workingDir) {
		this.workingDir = workingDir;
	}

	public Map getArgs() {
		return args;
	}

	public void setArgs(Map args) {
		this.args = args;
	}

	public void addArg(String name, String value) {
		args.put(name, value);
	}

	public String getBuildScriptPath() {
		return buildScriptPath;
	}

	public void setBuildScriptPath(String buildScriptPath) {
		this.buildScriptPath = buildScriptPath;
	}

	public List getArgsAsList() {
		List list = new ArrayList(2 * args.size());
		for (Map.Entry entry : args.entrySet()) {
			list.add(entry.getKey());
			if (!Strings.isNullOrEmpty(entry.getValue())) {
				list.add(entry.getValue());
			}
		}
		return list;
	}

	public List getArgEntriesAsList() {
		List list = new ArrayList(args.size());
		for (Map.Entry entry : args.entrySet()) {
			list.add((entry.getKey() + " " + entry.getValue()).trim());
		}
		return list;
	}

	@Override
	public String toString() {
		StringBuilder str = new StringBuilder();
		if (!Strings.isNullOrEmpty(workingDir)) {
			str.append("cd ").append(workingDir).append(" && ");
		}
		str.append(executable).append(" ");
		for (Map.Entry entry : args.entrySet()) {
			str.append(entry.getKey()).append(" ").append(entry.getValue()).append(" ");
		}
		return str.toString();
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy