Used switch case in place of if else if

This commit is contained in:
Luca Frosini 2020-01-28 10:09:58 +01:00
parent d780357089
commit 1e02edd42c
2 changed files with 19 additions and 12 deletions

View File

@ -421,16 +421,24 @@ public class SchemaManagementImpl implements SchemaManagement {
ERManagement<? extends OElement> erManagement = null; ERManagement<? extends OElement> erManagement = null;
if(Resource.class.isAssignableFrom(accessType.getTypeClass())) { switch(accessType) {
erManagement = new ResourceTypeDefinitionManagement(); case PROPERTY:
}else if(Facet.class.isAssignableFrom(accessType.getTypeClass())) { erManagement = new PropertyTypeDefinitionManagement();
erManagement = new FacetTypeDefinitionManagement(); break;
} else if(IsRelatedTo.class.isAssignableFrom(accessType.getTypeClass())) { case RESOURCE:
erManagement = new IsRelatedToTypeDefinitionManagement(); erManagement = new ResourceTypeDefinitionManagement();
} else if(ConsistsOf.class.isAssignableFrom(accessType.getTypeClass())) { break;
erManagement = new ConsistsOfTypeDefinitionManagement(); case FACET:
} else if(Property.class.isAssignableFrom(accessType.getTypeClass())) { erManagement = new FacetTypeDefinitionManagement();
erManagement = new PropertyTypeDefinitionManagement(); break;
case IS_RELATED_TO:
erManagement = new IsRelatedToTypeDefinitionManagement();
break;
case CONSISTS_OF:
erManagement = new ConsistsOfTypeDefinitionManagement();
break;
default:
break;
} }
String ret = null; String ret = null;

View File

@ -191,8 +191,7 @@ public class SchemaManagementImplTest {
} }
//@Test(expected=SchemaAlreadyPresentException.class) @Test(expected=SchemaAlreadyPresentException.class)
@Test
public void createPropertyType() throws Exception { public void createPropertyType() throws Exception {
PropertyTypeDefinition<ValueSchema> propertyTypeDefinition = new PropertyTypeDefinitionImpl<>(ValueSchema.class); PropertyTypeDefinition<ValueSchema> propertyTypeDefinition = new PropertyTypeDefinitionImpl<>(ValueSchema.class);