/** * Bind a given tag and value to a GQL query builder. * @param builder the builder holding a GQL query that is being built. * @param tagName the name of the tag to bind. * @param val the value to bind to the tag. */ public static void bindValueToGqlBuilder(Builder builder, String tagName, Object val) { Class valClass = getTypeForWrappingInDatastoreValue(val); if (!GQL_PARAM_BINDING_FUNC_MAP.containsKey(valClass)) { throw new DatastoreDataException( "Param value for GQL annotated query is not a supported Cloud " + "Datastore GQL param type: " + valClass); } // this value must be set due to compiler rule Object unusued = GQL_PARAM_BINDING_FUNC_MAP.get(valClass).apply(builder) .apply(tagName, val); }
/** * Bind a given tag and value to a GQL query builder. * @param builder the builder holding a GQL query that is being built. * @param tagName the name of the tag to bind. * @param val the value to bind to the tag. */ public static void bindValueToGqlBuilder(Builder builder, String tagName, Object val) { Class valClass = getTypeForWrappingInDatastoreValue(val); if (!GQL_PARAM_BINDING_FUNC_MAP.containsKey(valClass)) { throw new DatastoreDataException( "Param value for GQL annotated query is not a supported Cloud " + "Datastore GQL param type: " + valClass); } // this value must be set due to compiler rule Object unusued = GQL_PARAM_BINDING_FUNC_MAP.get(valClass).apply(builder) .apply(tagName, val); }
/** * Wraps Datastore native type to Datastore value type. * @param propertyVal the property value to wrap * @return the wrapped value */ @SuppressWarnings("unchecked") public static Value wrapValue(Object propertyVal) { if (propertyVal == null) { return new NullValue(); } Class propertyClass = getTypeForWrappingInDatastoreValue(propertyVal); Function wrapper = DatastoreNativeTypes.DATASTORE_TYPE_WRAPPERS .get(propertyClass); if (wrapper != null) { return (Value) wrapper.apply(propertyVal); } throw new DatastoreDataException( "Unable to convert " + propertyClass + " to Datastore supported type."); }
/** * Wraps Datastore native type to Datastore value type. * @param propertyVal the property value to wrap * @return the wrapped value */ @SuppressWarnings("unchecked") public static Value wrapValue(Object propertyVal) { if (propertyVal == null) { return new NullValue(); } Class propertyClass = getTypeForWrappingInDatastoreValue(propertyVal); Function wrapper = DatastoreNativeTypes.DATASTORE_TYPE_WRAPPERS .get(propertyClass); if (wrapper != null) { return (Value) wrapper.apply(propertyVal); } throw new DatastoreDataException( "Unable to convert " + propertyClass + " to Datastore supported type."); }