public <K, V> Composite[] createForQuery( PropertyMeta<K, V> propertyMeta, K start, K end, WideMap.BoundingMode bounds, WideMap.OrderingMode ordering) { Composite[] queryComp = new Composite[2]; ComponentEquality[] equalities = helper.determineEquality(bounds, ordering); Composite startComp = this.createForQuery(propertyMeta, start, equalities[0]); Composite endComp = this.createForQuery(propertyMeta, end, equalities[1]); queryComp[0] = startComp; queryComp[1] = endComp; return queryComp; }
@SuppressWarnings("unchecked") public <K, V, T> Composite createForQuery( PropertyMeta<K, V> propertyMeta, T keyValue, ComponentEquality equality) { log.trace("Creating query composite for propertyMeta {}", propertyMeta.getPropertyName()); Composite composite = new Composite(); String propertyName = propertyMeta.getPropertyName(); if (propertyMeta.isSingleKey()) { if (keyValue == null) { composite = null; } else { composite.addComponent(0, keyValue, equality); } } else { MultiKeyProperties multiKeyProperties = propertyMeta.getMultiKeyProperties(); List<Serializer<?>> componentSerializers = multiKeyProperties.getComponentSerializers(); List<Object> keyValues = entityHelper.determineMultiKey(keyValue, multiKeyProperties.getComponentGetters()); int srzCount = componentSerializers.size(); int valueCount = keyValues.size(); Validator.validateTrue( srzCount >= valueCount, "There should be at most" + srzCount + " values for the key of WideMap '" + propertyName + "'"); int lastNotNullIndex = helper.findLastNonNullIndexForComponents(propertyName, keyValues); for (int i = 0; i <= lastNotNullIndex; i++) { Serializer<Object> srz = (Serializer<Object>) componentSerializers.get(i); Object value = keyValues.get(i); if (i < lastNotNullIndex) { composite.setComponent(i, value, srz, srz.getComparatorType().getTypeName(), EQUAL); } else { composite.setComponent(i, value, srz, srz.getComparatorType().getTypeName(), equality); } } } return composite; }