如何将 switch 语句转换为 if 语句?

How to conver switch statement to if statement?

我想知道是否可以将以下内容转换为 if 语句而不是 switch 语句。

switch (type) {
  case PROJECT:
  case STORY:
  case DEVELOPER:
    createdItem = new AggregateItem(name, desc, value);
    break;
  case STORY_DEVELOPER:
    createdItem = new SingleItem(name, value, child);
    break;
  default:
    createdItem = null;
}  

将前三个 switch casesor 连接起来。 然后是 else if 最后但并非最不重要的 else.

if(PROJECT.equals(type)|| STORY.equals(type) || STORY.equals(DEVELOPER)){
  createdItem = new AggregateItem(name, desc, value);
}else if (STORY_DEVELOPER.equals(type)){
  createdItem = new SingleItem(name, value, child);
}else{
  createdItem = null;
}