public static InvalidEntityKanbaneryException mostSpecializedException ( String response ) { //todo refactor this!!! if ( response == null || "" . equals ( response ) ) { return new InvalidEntityKanbaneryException ( response ) ; } else if ( TaskAlreadyInFirstColumnException . isBestExceptionFor ( response ) ) { return new TaskAlreadyInFirstColumnException ( response ) ; } else if ( TaskAlreadyInLastColumnException . isBestExceptionFor ( response ) ) { return new TaskAlreadyInLastColumnException ( response ) ; } else if ( PositionExceedsNumberOfTasksInColumnException . isBestExceptionFor ( response ) ) { return new PositionExceedsNumberOfTasksInColumnException ( response ) ; } else if ( CanOnlyIceBoxTaskFromFirstColumnException . isBestExceptionFor ( response ) ) { return new CanOnlyIceBoxTaskFromFirstColumnException ( response ) ; } else if ( CanOnlyArchiveFromLastColumnException . isBestExceptionFor ( response ) ) { return new CanOnlyArchiveFromLastColumnException ( response ) ; } else if ( NotFixedColumnCannotBeFirstException . isBestExceptionFor ( response ) ) { return new NotFixedColumnCannotBeFirstException ( response ) ; } else if ( BodyMustNotBeBlankException . isBestExceptionFor ( response ) ) { return new BodyMustNotBeBlankException ( response ) ; } else if ( MaximumNumbersOfCollaboratorsReachedException . isBestExceptionFor ( response ) ) { return new MaximumNumbersOfCollaboratorsReachedException ( response ) ; } else if ( UserAlreadyAssignedToThisProjectException . isBestExceptionFor ( response ) ) { return new UserAlreadyAssignedToThisProjectException ( response ) ; } else if ( ProjectOwnerCanNotBeGivenProjectMembership . isBestExceptionFor ( response ) ) { return new ProjectOwnerCanNotBeGivenProjectMembership ( response ) ; } else if ( CanNotDeleteColumnThatContainsTasksException . isBestExceptionFor ( response ) ) { return new CanNotDeleteColumnThatContainsTasksException ( response ) ; } else { return new InvalidEntityKanbaneryException ( response ) ; } }
May be used as Exception factory to determine the best exception to be thrown for such JSON response . For example we may throw TaskAlreadyInFirstColumnException if the JSON contains a message informing us about this .