Extract the creation of TsdbQuery objects into a QueryBuilder

If checkNotNull gets a null object it will throw a NullpointerException, we should handle this