could be simplified by 

```java
try {
    Granularity gran = Granularity.fromString((String)rollupEventObjects[0];
    if (gran == null)
        // log invalid granularity and return.
} catch (ClassCast) {
    // log something and return
}

// send messages to topic
```