Validates the query @throws IllegalArgumentException if one or more parameters were invalid
()
| 101 | * @throws IllegalArgumentException if one or more parameters were invalid |
| 102 | */ |
| 103 | public void validate() { |
| 104 | if (time == null) { |
| 105 | throw new IllegalArgumentException("missing time"); |
| 106 | } |
| 107 | |
| 108 | validatePOJO(time, "time"); |
| 109 | |
| 110 | if (metrics == null || metrics.isEmpty()) { |
| 111 | throw new IllegalArgumentException("missing or empty metrics"); |
| 112 | } |
| 113 | |
| 114 | final Set<String> variable_ids = new HashSet<String>(); |
| 115 | for (Metric metric : metrics) { |
| 116 | if (variable_ids.contains(metric.getId())) { |
| 117 | throw new IllegalArgumentException("duplicated metric id: " |
| 118 | + metric.getId()); |
| 119 | } |
| 120 | variable_ids.add(metric.getId()); |
| 121 | } |
| 122 | |
| 123 | final Set<String> filter_ids = new HashSet<String>(); |
| 124 | |
| 125 | if (filters != null) { |
| 126 | for (Filter filter : filters) { |
| 127 | if (filter_ids.contains(filter.getId())) { |
| 128 | throw new IllegalArgumentException("duplicated filter id: " |
| 129 | + filter.getId()); |
| 130 | } |
| 131 | filter_ids.add(filter.getId()); |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | if (expressions != null) { |
| 136 | for (Expression expression : expressions) { |
| 137 | if (variable_ids.contains(expression.getId())) { |
| 138 | throw new IllegalArgumentException("Duplicated variable or expression id: " |
| 139 | + expression.getId()); |
| 140 | } |
| 141 | variable_ids.add(expression.getId()); |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | validateCollection(metrics, "metric"); |
| 146 | |
| 147 | if (filters != null) { |
| 148 | validateCollection(filters, "filter"); |
| 149 | } |
| 150 | |
| 151 | if (expressions != null) { |
| 152 | validateCollection(expressions, "expression"); |
| 153 | } |
| 154 | |
| 155 | validateFilters(); |
| 156 | |
| 157 | if (expressions != null) { |
| 158 | validateCollection(expressions, "expression"); |
| 159 | for (final Expression exp : expressions) { |
| 160 | if (exp.getVariables() == null) { |