In the code for org.apache.webbeans.context.ContextFactory, we currently have:
switch (type.getName())
{
case 0:
context = getRequestContext();
break;
case 1:
context = getSessionContext();
break;
case 2:
context = getApplicationContext();
break;
case 3:
context = getConversationContext();
break;
case 4:
context = getDependentContext();
break;
default:
throw new IllegalArgumentException("There is no such a
standard context with name id=" + type.getName());
}
This should be changed to (the Java language supports switching on enum values):
switch (type)
{
case REQUEST:
context = getRequestContext();
break;
case SESSION:
context = getSessionContext();
break;
case APPLICATION:
context = getApplicationContext();
break;
case CONVERSATION:
context = getConversationContext();
break;
case DEPENDENT:
context = getDependentContext();
break;
default:
throw new IllegalArgumentException("There is no such a
standard context with name id=" + type.getName());
}
This is much more readable.