I have a method that accepts only a String.
public void setVerticalAlignment(String align) {
...
gd.verticalAlignment = align; // accepts only
Sounds like you want a map:
// Ideally use ImmutableMap from Guava
private static final Map ALIGNMENTS = mapAlignments();
private static final Map mapAlignments() {
Map ret = new HashMap();
ret.put ("SWT.TOP", SWT.TOP);
// etc
return ret;
}
Then you can just fetch from the map (and unbox) later.
Or, better, change your method declaration to avoid this in the first place :)