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

com.github.siwenyan.potluck.ext01.GuestReplaceDriver Maven / Gradle / Ivy

There is a newer version: 1.9.0.0.1
Show newest version
package com.github.siwenyan.potluck.ext01;

import com.github.siwenyan.common.Feedback;
import com.github.siwenyan.dish_parser.Constants;
import com.github.siwenyan.dish_parser.IDish;
import com.github.siwenyan.potluck.AbstractSimpleGuest;

import java.util.Map;

public class GuestReplaceDriver extends AbstractSimpleGuest {
	private static final String FLAVOR_REPLACE_BROWSER = "replaceBrowser";

	@Override
	public String help(String flavor) {
		String help = "";

		if (flavor.equals(FLAVOR_REPLACE_BROWSER)) {
			help += Constants.OUTPUT_INDENT + FLAVOR_REPLACE_BROWSER + Constants.OUTPUT_FLAVOR_SEPARATOR
					+ "" + Constants.OUTPUT_LINE_SEPARATOR + "\r\n"
					+ Constants.OUTPUT_INDENT + Constants.OUTPUT_INDENT;
		}

		return help;
	}

	@Override
	public Feedback have(IDish dish) {
		try {
			String cmd = dish.getFlavor().getFlavorName();

			if (cmd.equals(FLAVOR_REPLACE_BROWSER)) {
				Map options = dish.asOptions();
				this.myTable.replaceDriver(options);
				return Feedback.yami();
			}
		} catch (Exception e) {
			return new Feedback(Feedback.EStatus.FAIL, e.getMessage());
		}

		return Feedback.yaki();
	}

	public String[] getFlavors() {
		return new String[] { FLAVOR_REPLACE_BROWSER };
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy