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;
if(Resource.class.isAssignableFrom(accessType.getTypeClass())) {
erManagement = new ResourceTypeDefinitionManagement();
}else if(Facet.class.isAssignableFrom(accessType.getTypeClass())) {
erManagement = new FacetTypeDefinitionManagement();
} else if(IsRelatedTo.class.isAssignableFrom(accessType.getTypeClass())) {
erManagement = new IsRelatedToTypeDefinitionManagement();
} else if(ConsistsOf.class.isAssignableFrom(accessType.getTypeClass())) {
erManagement = new ConsistsOfTypeDefinitionManagement();
} else if(Property.class.isAssignableFrom(accessType.getTypeClass())) {
erManagement = new PropertyTypeDefinitionManagement();
switch(accessType) {
case PROPERTY:
erManagement = new PropertyTypeDefinitionManagement();
break;
case RESOURCE:
erManagement = new ResourceTypeDefinitionManagement();
break;
case FACET:
erManagement = new FacetTypeDefinitionManagement();
break;
case IS_RELATED_TO:
erManagement = new IsRelatedToTypeDefinitionManagement();
break;
case CONSISTS_OF:
erManagement = new ConsistsOfTypeDefinitionManagement();
break;
default:
break;
}
String ret = null;

View File

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