All pastes #491673 Raw Edit

Stuff

public java v1 · immutable
·published 2007-05-16 19:57 UTC
rendered paste body
// Makes for loose coupling, since string representation can be changed    // without changing the logic everywhere    public enum CmdArgs {	HELP    ("help"),	SINGLE  ("single"),	MULTI   ("multi");	private final String stringrep;	CmdArgs(String representation) {	    this.stringrep = representation;	}	public String getStringRep() { return stringrep;}    }    public static void  main (String args[])    {	String firstArg = args[0];		// Find the right enum based on textual representation	CmdArgs myenum = null;	for(CmdArgs enumversion : CmdArgs.values()){	    if(enumversion.getStringRep().equals(firstArg)){		myenum = enumversion;		break;	    }	}	if(myenum == null){	    // Temper tantrum! Argument incorrect!	    return;	}	switch(myenum){	    case HELP: 		//TODO		break;	    case SINGLE: 		//TODO		break;	    case MULTI: 		//TODO		break;	    // etc	}