This whole switch block is duplicated in the other getEntityId method. I suggest to reconsider this whole code structure. Right now you have two methods that may each return either a propertyId or an itemId. The calling code always knows which of those is wanted and you need a cast to get the expected format. Moreover, each method contains several switch statements to distinguish the property and the item case. If you had four methods instead, the code might end up shorter overall and you would get rid of the casting.