diff --git a/firebase-firestore/api.txt b/firebase-firestore/api.txt index d3f073e974c..cd59b8392fa 100644 --- a/firebase-firestore/api.txt +++ b/firebase-firestore/api.txt @@ -423,14 +423,16 @@ package com.google.firebase.firestore { public final class Pipeline { method public com.google.firebase.firestore.Pipeline addFields(com.google.firebase.firestore.pipeline.Selectable field, com.google.firebase.firestore.pipeline.Selectable... additionalFields); method public com.google.firebase.firestore.Pipeline aggregate(com.google.firebase.firestore.pipeline.AggregateStage aggregateStage); - method public com.google.firebase.firestore.Pipeline aggregate(com.google.firebase.firestore.pipeline.AggregateWithAlias accumulator, com.google.firebase.firestore.pipeline.AggregateWithAlias... additionalAccumulators); + method public com.google.firebase.firestore.Pipeline aggregate(com.google.firebase.firestore.pipeline.AggregateStage aggregateStage, com.google.firebase.firestore.pipeline.AggregateOptions options); + method public com.google.firebase.firestore.Pipeline aggregate(com.google.firebase.firestore.pipeline.AliasedAggregate accumulator, com.google.firebase.firestore.pipeline.AliasedAggregate... additionalAccumulators); method public com.google.firebase.firestore.Pipeline distinct(com.google.firebase.firestore.pipeline.Selectable group, java.lang.Object... additionalGroups); method public com.google.firebase.firestore.Pipeline distinct(String groupField, java.lang.Object... additionalGroups); - method public com.google.android.gms.tasks.Task execute(); - method public com.google.android.gms.tasks.Task execute(com.google.firebase.firestore.pipeline.InternalOptions? options); + method public com.google.android.gms.tasks.Task execute(); + method public com.google.android.gms.tasks.Task execute(com.google.firebase.firestore.Pipeline.ExecuteOptions options); method public com.google.firebase.firestore.Pipeline findNearest(com.google.firebase.firestore.pipeline.Field vectorField, com.google.firebase.firestore.VectorValue vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); method public com.google.firebase.firestore.Pipeline findNearest(com.google.firebase.firestore.pipeline.Field vectorField, double[] vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public com.google.firebase.firestore.Pipeline findNearest(com.google.firebase.firestore.pipeline.FindNearestStage stage); + method public com.google.firebase.firestore.Pipeline findNearest(String vectorField, com.google.firebase.firestore.pipeline.Expression vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); + method public com.google.firebase.firestore.Pipeline findNearest(String vectorField, com.google.firebase.firestore.pipeline.Expression vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure, com.google.firebase.firestore.pipeline.FindNearestOptions options); method public com.google.firebase.firestore.Pipeline findNearest(String vectorField, com.google.firebase.firestore.VectorValue vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); method public com.google.firebase.firestore.Pipeline findNearest(String vectorField, double[] vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); method public com.google.firebase.firestore.Pipeline limit(int limit); @@ -438,8 +440,8 @@ package com.google.firebase.firestore { method public com.google.firebase.firestore.Pipeline rawStage(com.google.firebase.firestore.pipeline.RawStage rawStage); method public com.google.firebase.firestore.Pipeline removeFields(com.google.firebase.firestore.pipeline.Field field, com.google.firebase.firestore.pipeline.Field... additionalFields); method public com.google.firebase.firestore.Pipeline removeFields(String field, java.lang.String... additionalFields); - method public com.google.firebase.firestore.Pipeline replace(com.google.firebase.firestore.pipeline.Expr mapValue); - method public com.google.firebase.firestore.Pipeline replace(String field); + method public com.google.firebase.firestore.Pipeline replaceWith(com.google.firebase.firestore.pipeline.Expression mapValue); + method public com.google.firebase.firestore.Pipeline replaceWith(String field); method public com.google.firebase.firestore.Pipeline sample(com.google.firebase.firestore.pipeline.SampleStage sample); method public com.google.firebase.firestore.Pipeline sample(int documents); method public com.google.firebase.firestore.Pipeline select(com.google.firebase.firestore.pipeline.Selectable selection, java.lang.Object... additionalSelections); @@ -447,9 +449,31 @@ package com.google.firebase.firestore { method public com.google.firebase.firestore.Pipeline sort(com.google.firebase.firestore.pipeline.Ordering order, com.google.firebase.firestore.pipeline.Ordering... additionalOrders); method public com.google.firebase.firestore.Pipeline union(com.google.firebase.firestore.Pipeline other); method public com.google.firebase.firestore.Pipeline unnest(com.google.firebase.firestore.pipeline.Selectable arrayWithAlias); + method public com.google.firebase.firestore.Pipeline unnest(com.google.firebase.firestore.pipeline.Selectable arrayWithAlias, com.google.firebase.firestore.pipeline.UnnestOptions options); method public com.google.firebase.firestore.Pipeline unnest(com.google.firebase.firestore.pipeline.UnnestStage unnestStage); method public com.google.firebase.firestore.Pipeline unnest(String arrayField, String alias); - method public com.google.firebase.firestore.Pipeline where(com.google.firebase.firestore.pipeline.BooleanExpr condition); + method public com.google.firebase.firestore.Pipeline where(com.google.firebase.firestore.pipeline.BooleanExpression condition); + } + + public static final class Pipeline.ExecuteOptions extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public Pipeline.ExecuteOptions(); + method public com.google.firebase.firestore.Pipeline.ExecuteOptions withIndexMode(com.google.firebase.firestore.Pipeline.ExecuteOptions.IndexMode indexMode); + } + + public static final class Pipeline.ExecuteOptions.IndexMode { + field public static final com.google.firebase.firestore.Pipeline.ExecuteOptions.IndexMode.Companion Companion; + field public static final com.google.firebase.firestore.Pipeline.ExecuteOptions.IndexMode RECOMMENDED; + } + + public static final class Pipeline.ExecuteOptions.IndexMode.Companion { + } + + public static final class Pipeline.Snapshot implements java.lang.Iterable kotlin.jvm.internal.markers.KMappedMarker { + method public com.google.firebase.Timestamp getExecutionTime(); + method public java.util.List getResults(); + method public java.util.Iterator iterator(); + property public final com.google.firebase.Timestamp executionTime; + property public final java.util.List results; } public final class PipelineResult { @@ -491,14 +515,6 @@ package com.google.firebase.firestore { public static final class PipelineResultChange.Companion { } - public final class PipelineSnapshot implements java.lang.Iterable kotlin.jvm.internal.markers.KMappedMarker { - method public com.google.firebase.Timestamp getExecutionTime(); - method public java.util.List getResults(); - method public java.util.Iterator iterator(); - property public final com.google.firebase.Timestamp executionTime; - property public final java.util.List results; - } - public final class PipelineSnapshotMetadata { method public boolean component1(); method public boolean component2(); @@ -511,11 +527,12 @@ package com.google.firebase.firestore { public final class PipelineSource { method public com.google.firebase.firestore.Pipeline collection(com.google.firebase.firestore.CollectionReference ref); - method public com.google.firebase.firestore.Pipeline collection(com.google.firebase.firestore.pipeline.CollectionSource stage); + method public com.google.firebase.firestore.Pipeline collection(com.google.firebase.firestore.CollectionReference ref, com.google.firebase.firestore.pipeline.CollectionSourceOptions options); method public com.google.firebase.firestore.Pipeline collection(String path); method public com.google.firebase.firestore.Pipeline collectionGroup(String collectionId); - method public com.google.firebase.firestore.Pipeline convertFrom(com.google.firebase.firestore.AggregateQuery aggregateQuery); - method public com.google.firebase.firestore.Pipeline convertFrom(com.google.firebase.firestore.Query query); + method public com.google.firebase.firestore.Pipeline collectionGroup(String collectionId, com.google.firebase.firestore.pipeline.CollectionGroupOptions options); + method public com.google.firebase.firestore.Pipeline createFrom(com.google.firebase.firestore.AggregateQuery aggregateQuery); + method public com.google.firebase.firestore.Pipeline createFrom(com.google.firebase.firestore.Query query); method public com.google.firebase.firestore.Pipeline database(); method public com.google.firebase.firestore.Pipeline documents(com.google.firebase.firestore.DocumentReference... documents); method public com.google.firebase.firestore.Pipeline documents(java.lang.String... documents); @@ -603,13 +620,10 @@ package com.google.firebase.firestore { method public com.google.firebase.firestore.ListenerRegistration addSnapshotListener(java.util.concurrent.Executor executor, com.google.firebase.firestore.RealtimePipelineOptions options, com.google.firebase.firestore.EventListener listener); method public String canonicalId(); method public com.google.firebase.firestore.RealtimePipeline limit(int limit); - method public com.google.firebase.firestore.RealtimePipeline offset(int offset); - method public com.google.firebase.firestore.RealtimePipeline select(com.google.firebase.firestore.pipeline.Selectable selection, java.lang.Object... additionalSelections); - method public com.google.firebase.firestore.RealtimePipeline select(String fieldName, java.lang.Object... additionalSelections); method public kotlinx.coroutines.flow.Flow snapshots(); method public kotlinx.coroutines.flow.Flow snapshots(com.google.firebase.firestore.RealtimePipelineOptions options); method public com.google.firebase.firestore.RealtimePipeline sort(com.google.firebase.firestore.pipeline.Ordering order, com.google.firebase.firestore.pipeline.Ordering... additionalOrders); - method public com.google.firebase.firestore.RealtimePipeline where(com.google.firebase.firestore.pipeline.BooleanExpr condition); + method public com.google.firebase.firestore.RealtimePipeline where(com.google.firebase.firestore.pipeline.BooleanExpression condition); } public final class RealtimePipelineOptions { @@ -634,9 +648,7 @@ package com.google.firebase.firestore { public final class RealtimePipelineSource { method public com.google.firebase.firestore.RealtimePipeline collection(com.google.firebase.firestore.CollectionReference ref); - method public com.google.firebase.firestore.RealtimePipeline collection(com.google.firebase.firestore.pipeline.CollectionSource stage); method public com.google.firebase.firestore.RealtimePipeline collection(String path); - method public com.google.firebase.firestore.RealtimePipeline collectionGroup(com.google.firebase.firestore.pipeline.CollectionGroupSource stage); method public com.google.firebase.firestore.RealtimePipeline collectionGroup(String collectionId); method public com.google.firebase.firestore.RealtimePipeline convertFrom(com.google.firebase.firestore.Query query); } @@ -759,824 +771,845 @@ package com.google.firebase.firestore.ktx { package com.google.firebase.firestore.pipeline { public abstract class AbstractOptions> { + method protected final T adding(com.google.firebase.firestore.pipeline.AbstractOptions newOptions); method public final T with(String key, boolean value); + method protected final T with(String key, com.google.firebase.firestore.pipeline.AbstractOptions subSection); method public final T with(String key, com.google.firebase.firestore.pipeline.Field value); method protected final T with(String key, com.google.firebase.firestore.pipeline.InternalOptions value); method public final T with(String key, com.google.firebase.firestore.pipeline.RawOptions value); method public final T with(String key, double value); method protected final T with(String key, error.NonExistentClass value); method public final T with(String key, String value); + method protected final T with(String key, java.lang.String... values); method public final T with(String key, long value); } public final class AggregateFunction { - method public com.google.firebase.firestore.pipeline.AggregateWithAlias alias(String alias); - method public static com.google.firebase.firestore.pipeline.AggregateFunction avg(com.google.firebase.firestore.pipeline.Expr expression); - method public static com.google.firebase.firestore.pipeline.AggregateFunction avg(String fieldName); - method public static com.google.firebase.firestore.pipeline.AggregateFunction count(com.google.firebase.firestore.pipeline.Expr expression); + method public com.google.firebase.firestore.pipeline.AliasedAggregate alias(String alias); + method public static com.google.firebase.firestore.pipeline.AggregateFunction average(com.google.firebase.firestore.pipeline.Expression expression); + method public static com.google.firebase.firestore.pipeline.AggregateFunction average(String fieldName); + method public static com.google.firebase.firestore.pipeline.AggregateFunction count(com.google.firebase.firestore.pipeline.Expression expression); method public static com.google.firebase.firestore.pipeline.AggregateFunction count(String fieldName); method public static com.google.firebase.firestore.pipeline.AggregateFunction countAll(); - method public static com.google.firebase.firestore.pipeline.AggregateFunction countIf(com.google.firebase.firestore.pipeline.BooleanExpr condition); - method public static com.google.firebase.firestore.pipeline.AggregateFunction generic(String name, com.google.firebase.firestore.pipeline.Expr... expr); - method public static com.google.firebase.firestore.pipeline.AggregateFunction maximum(com.google.firebase.firestore.pipeline.Expr expression); + method public static com.google.firebase.firestore.pipeline.AggregateFunction countDistinct(com.google.firebase.firestore.pipeline.Expression expression); + method public static com.google.firebase.firestore.pipeline.AggregateFunction countDistinct(String fieldName); + method public static com.google.firebase.firestore.pipeline.AggregateFunction countIf(com.google.firebase.firestore.pipeline.BooleanExpression condition); + method public static com.google.firebase.firestore.pipeline.AggregateFunction generic(String name, com.google.firebase.firestore.pipeline.Expression... expr); + method public static com.google.firebase.firestore.pipeline.AggregateFunction maximum(com.google.firebase.firestore.pipeline.Expression expression); method public static com.google.firebase.firestore.pipeline.AggregateFunction maximum(String fieldName); - method public static com.google.firebase.firestore.pipeline.AggregateFunction minimum(com.google.firebase.firestore.pipeline.Expr expression); + method public static com.google.firebase.firestore.pipeline.AggregateFunction minimum(com.google.firebase.firestore.pipeline.Expression expression); method public static com.google.firebase.firestore.pipeline.AggregateFunction minimum(String fieldName); - method public static com.google.firebase.firestore.pipeline.AggregateFunction sum(com.google.firebase.firestore.pipeline.Expr expression); + method public static com.google.firebase.firestore.pipeline.AggregateFunction sum(com.google.firebase.firestore.pipeline.Expression expression); method public static com.google.firebase.firestore.pipeline.AggregateFunction sum(String fieldName); field public static final com.google.firebase.firestore.pipeline.AggregateFunction.Companion Companion; } public static final class AggregateFunction.Companion { - method public com.google.firebase.firestore.pipeline.AggregateFunction avg(com.google.firebase.firestore.pipeline.Expr expression); - method public com.google.firebase.firestore.pipeline.AggregateFunction avg(String fieldName); - method public com.google.firebase.firestore.pipeline.AggregateFunction count(com.google.firebase.firestore.pipeline.Expr expression); + method public com.google.firebase.firestore.pipeline.AggregateFunction average(com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.AggregateFunction average(String fieldName); + method public com.google.firebase.firestore.pipeline.AggregateFunction count(com.google.firebase.firestore.pipeline.Expression expression); method public com.google.firebase.firestore.pipeline.AggregateFunction count(String fieldName); method public com.google.firebase.firestore.pipeline.AggregateFunction countAll(); - method public com.google.firebase.firestore.pipeline.AggregateFunction countIf(com.google.firebase.firestore.pipeline.BooleanExpr condition); - method public com.google.firebase.firestore.pipeline.AggregateFunction generic(String name, com.google.firebase.firestore.pipeline.Expr... expr); - method public com.google.firebase.firestore.pipeline.AggregateFunction maximum(com.google.firebase.firestore.pipeline.Expr expression); + method public com.google.firebase.firestore.pipeline.AggregateFunction countDistinct(com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.AggregateFunction countDistinct(String fieldName); + method public com.google.firebase.firestore.pipeline.AggregateFunction countIf(com.google.firebase.firestore.pipeline.BooleanExpression condition); + method public com.google.firebase.firestore.pipeline.AggregateFunction generic(String name, com.google.firebase.firestore.pipeline.Expression... expr); + method public com.google.firebase.firestore.pipeline.AggregateFunction maximum(com.google.firebase.firestore.pipeline.Expression expression); method public com.google.firebase.firestore.pipeline.AggregateFunction maximum(String fieldName); - method public com.google.firebase.firestore.pipeline.AggregateFunction minimum(com.google.firebase.firestore.pipeline.Expr expression); + method public com.google.firebase.firestore.pipeline.AggregateFunction minimum(com.google.firebase.firestore.pipeline.Expression expression); method public com.google.firebase.firestore.pipeline.AggregateFunction minimum(String fieldName); - method public com.google.firebase.firestore.pipeline.AggregateFunction sum(com.google.firebase.firestore.pipeline.Expr expression); + method public com.google.firebase.firestore.pipeline.AggregateFunction sum(com.google.firebase.firestore.pipeline.Expression expression); method public com.google.firebase.firestore.pipeline.AggregateFunction sum(String fieldName); } + public final class AggregateHints extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public AggregateHints(); + method public com.google.firebase.firestore.pipeline.AggregateHints self(com.google.firebase.firestore.pipeline.InternalOptions options); + method public com.google.firebase.firestore.pipeline.AggregateHints withForceStreamableEnabled(); + } + + public final class AggregateOptions extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public AggregateOptions(); + method public com.google.firebase.firestore.pipeline.AggregateOptions self(com.google.firebase.firestore.pipeline.InternalOptions options); + method public com.google.firebase.firestore.pipeline.AggregateOptions withHints(com.google.firebase.firestore.pipeline.AggregateHints hints); + } + public final class AggregateStage extends com.google.firebase.firestore.pipeline.Stage { - method public static com.google.firebase.firestore.pipeline.AggregateStage withAccumulators(com.google.firebase.firestore.pipeline.AggregateWithAlias accumulator, com.google.firebase.firestore.pipeline.AggregateWithAlias... additionalAccumulators); + method public static com.google.firebase.firestore.pipeline.AggregateStage withAccumulators(com.google.firebase.firestore.pipeline.AliasedAggregate accumulator, com.google.firebase.firestore.pipeline.AliasedAggregate... additionalAccumulators); method public com.google.firebase.firestore.pipeline.AggregateStage withGroups(com.google.firebase.firestore.pipeline.Selectable group, java.lang.Object... additionalGroups); method public com.google.firebase.firestore.pipeline.AggregateStage withGroups(String groupField, java.lang.Object... additionalGroups); field public static final com.google.firebase.firestore.pipeline.AggregateStage.Companion Companion; } public static final class AggregateStage.Companion { - method public com.google.firebase.firestore.pipeline.AggregateStage withAccumulators(com.google.firebase.firestore.pipeline.AggregateWithAlias accumulator, com.google.firebase.firestore.pipeline.AggregateWithAlias... additionalAccumulators); + method public com.google.firebase.firestore.pipeline.AggregateStage withAccumulators(com.google.firebase.firestore.pipeline.AliasedAggregate accumulator, com.google.firebase.firestore.pipeline.AliasedAggregate... additionalAccumulators); + } + + public final class AliasedAggregate { } - public final class AggregateWithAlias { + public final class AliasedExpression extends com.google.firebase.firestore.pipeline.Selectable { + method public String canonicalId(); + method public String getAlias(); + method public com.google.firebase.firestore.pipeline.Expression getExpr(); + property public String alias; + property public com.google.firebase.firestore.pipeline.Expression expr; } - public class BooleanExpr extends com.google.firebase.firestore.pipeline.FunctionExpr { - method public final com.google.firebase.firestore.pipeline.Expr cond(com.google.firebase.firestore.pipeline.Expr thenExpr, com.google.firebase.firestore.pipeline.Expr elseExpr); - method public final com.google.firebase.firestore.pipeline.Expr cond(Object thenValue, Object elseValue); + public class BooleanExpression extends com.google.firebase.firestore.pipeline.FunctionExpression { + method public final com.google.firebase.firestore.pipeline.Expression conditional(com.google.firebase.firestore.pipeline.Expression thenExpr, com.google.firebase.firestore.pipeline.Expression elseExpr); + method public final com.google.firebase.firestore.pipeline.Expression conditional(Object thenValue, Object elseValue); method public final com.google.firebase.firestore.pipeline.AggregateFunction countIf(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr generic(String name, com.google.firebase.firestore.pipeline.Expr... expr); - method public final com.google.firebase.firestore.pipeline.BooleanExpr ifError(com.google.firebase.firestore.pipeline.BooleanExpr catchExpr); - method public final com.google.firebase.firestore.pipeline.BooleanExpr not(); - field public static final com.google.firebase.firestore.pipeline.BooleanExpr.Companion Companion; + method public static final com.google.firebase.firestore.pipeline.BooleanExpression generic(String name, com.google.firebase.firestore.pipeline.Expression... expr); + method public final com.google.firebase.firestore.pipeline.BooleanExpression ifError(com.google.firebase.firestore.pipeline.BooleanExpression catchExpr); + method public final com.google.firebase.firestore.pipeline.BooleanExpression not(); + field public static final com.google.firebase.firestore.pipeline.BooleanExpression.Companion Companion; + } + + public static final class BooleanExpression.Companion { + method public com.google.firebase.firestore.pipeline.BooleanExpression generic(String name, com.google.firebase.firestore.pipeline.Expression... expr); } - public static final class BooleanExpr.Companion { - method public com.google.firebase.firestore.pipeline.BooleanExpr generic(String name, com.google.firebase.firestore.pipeline.Expr... expr); + public final class CollectionGroupOptions extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public CollectionGroupOptions(); + method public com.google.firebase.firestore.pipeline.CollectionGroupOptions self(com.google.firebase.firestore.pipeline.InternalOptions options); + method public com.google.firebase.firestore.pipeline.CollectionGroupOptions withHints(com.google.firebase.firestore.pipeline.CollectionHints hints); } public final class CollectionGroupSource extends com.google.firebase.firestore.pipeline.Stage { ctor public CollectionGroupSource(String collectionId, com.google.firebase.firestore.pipeline.InternalOptions options); method public String canonicalId(); method public String getCollectionId(); - method public static com.google.firebase.firestore.pipeline.CollectionGroupSource of(String collectionId); - method public error.NonExistentClass withForceIndex(String value); property public final String collectionId; - field public static final com.google.firebase.firestore.pipeline.CollectionGroupSource.Companion Companion; } - public static final class CollectionGroupSource.Companion { - method public com.google.firebase.firestore.pipeline.CollectionGroupSource of(String collectionId); + public final class CollectionHints extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public CollectionHints(); + method public com.google.firebase.firestore.pipeline.CollectionHints self(com.google.firebase.firestore.pipeline.InternalOptions options); + method public com.google.firebase.firestore.pipeline.CollectionHints withForceIndex(String value); + method public com.google.firebase.firestore.pipeline.CollectionHints withIgnoreIndexFields(java.lang.String... values); } public final class CollectionSource extends com.google.firebase.firestore.pipeline.Stage { method public String canonicalId(); - method public error.NonExistentClass withForceIndex(String value); - field public static final com.google.firebase.firestore.pipeline.CollectionSource.Companion Companion; } - public static final class CollectionSource.Companion { + public final class CollectionSourceOptions extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public CollectionSourceOptions(); + method public com.google.firebase.firestore.pipeline.CollectionSourceOptions withHints(com.google.firebase.firestore.pipeline.CollectionHints hints); } - public abstract class Expr { - method public static final com.google.firebase.firestore.pipeline.Expr abs(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr abs(String numericField); - method public final com.google.firebase.firestore.pipeline.Expr add(com.google.firebase.firestore.pipeline.Expr second); - method public static final com.google.firebase.firestore.pipeline.Expr add(com.google.firebase.firestore.pipeline.Expr first, com.google.firebase.firestore.pipeline.Expr second); - method public static final com.google.firebase.firestore.pipeline.Expr add(com.google.firebase.firestore.pipeline.Expr first, Number second); - method public final com.google.firebase.firestore.pipeline.Expr add(Number second); - method public static final com.google.firebase.firestore.pipeline.Expr add(String numericFieldName, com.google.firebase.firestore.pipeline.Expr second); - method public static final com.google.firebase.firestore.pipeline.Expr add(String numericFieldName, Number second); + public abstract class Expression { + method public static final com.google.firebase.firestore.pipeline.Expression abs(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression abs(String numericField); + method public final com.google.firebase.firestore.pipeline.Expression add(com.google.firebase.firestore.pipeline.Expression second); + method public static final com.google.firebase.firestore.pipeline.Expression add(com.google.firebase.firestore.pipeline.Expression first, com.google.firebase.firestore.pipeline.Expression second); + method public static final com.google.firebase.firestore.pipeline.Expression add(com.google.firebase.firestore.pipeline.Expression first, Number second); + method public final com.google.firebase.firestore.pipeline.Expression add(Number second); + method public static final com.google.firebase.firestore.pipeline.Expression add(String numericFieldName, com.google.firebase.firestore.pipeline.Expression second); + method public static final com.google.firebase.firestore.pipeline.Expression add(String numericFieldName, Number second); method public com.google.firebase.firestore.pipeline.Selectable alias(String alias); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr and(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.BooleanExpr... conditions); - method public static final com.google.firebase.firestore.pipeline.Expr array(java.lang.Object?... elements); - method public static final com.google.firebase.firestore.pipeline.Expr array(java.util.List elements); - method public static final com.google.firebase.firestore.pipeline.Expr arrayConcat(com.google.firebase.firestore.pipeline.Expr firstArray, com.google.firebase.firestore.pipeline.Expr secondArray, java.lang.Object... otherArrays); - method public static final com.google.firebase.firestore.pipeline.Expr arrayConcat(com.google.firebase.firestore.pipeline.Expr firstArray, Object secondArray, java.lang.Object... otherArrays); - method public final com.google.firebase.firestore.pipeline.Expr arrayConcat(com.google.firebase.firestore.pipeline.Expr secondArray, java.lang.Object... otherArrays); - method public final com.google.firebase.firestore.pipeline.Expr arrayConcat(Object secondArray, java.lang.Object... otherArrays); - method public static final com.google.firebase.firestore.pipeline.Expr arrayConcat(String firstArrayField, com.google.firebase.firestore.pipeline.Expr secondArray, java.lang.Object... otherArrays); - method public static final com.google.firebase.firestore.pipeline.Expr arrayConcat(String firstArrayField, Object secondArray, java.lang.Object... otherArrays); - method public final com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(com.google.firebase.firestore.pipeline.Expr element); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr element); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(com.google.firebase.firestore.pipeline.Expr array, Object element); - method public final com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(Object element); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr element); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(String arrayFieldName, Object element); - method public final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(com.google.firebase.firestore.pipeline.Expr array, java.util.List values); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(String arrayFieldName, java.util.List values); - method public final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(java.util.List values); - method public final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(com.google.firebase.firestore.pipeline.Expr array, java.util.List values); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(String arrayFieldName, java.util.List values); - method public final com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(java.util.List values); - method public final com.google.firebase.firestore.pipeline.Expr arrayLength(); - method public static final com.google.firebase.firestore.pipeline.Expr arrayLength(com.google.firebase.firestore.pipeline.Expr array); - method public static final com.google.firebase.firestore.pipeline.Expr arrayLength(String arrayFieldName); - method public final com.google.firebase.firestore.pipeline.Expr arrayOffset(com.google.firebase.firestore.pipeline.Expr offset); - method public static final com.google.firebase.firestore.pipeline.Expr arrayOffset(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr offset); - method public static final com.google.firebase.firestore.pipeline.Expr arrayOffset(com.google.firebase.firestore.pipeline.Expr array, int offset); - method public final com.google.firebase.firestore.pipeline.Expr arrayOffset(int offset); - method public static final com.google.firebase.firestore.pipeline.Expr arrayOffset(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr offset); - method public static final com.google.firebase.firestore.pipeline.Expr arrayOffset(String arrayFieldName, int offset); - method public final com.google.firebase.firestore.pipeline.Expr arrayReverse(); - method public static final com.google.firebase.firestore.pipeline.Expr arrayReverse(com.google.firebase.firestore.pipeline.Expr array); - method public static final com.google.firebase.firestore.pipeline.Expr arrayReverse(String arrayFieldName); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression and(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.BooleanExpression... conditions); + method public static final com.google.firebase.firestore.pipeline.Expression array(java.lang.Object?... elements); + method public static final com.google.firebase.firestore.pipeline.Expression array(java.util.List elements); + method public static final com.google.firebase.firestore.pipeline.Expression arrayConcat(com.google.firebase.firestore.pipeline.Expression firstArray, com.google.firebase.firestore.pipeline.Expression secondArray, java.lang.Object... otherArrays); + method public static final com.google.firebase.firestore.pipeline.Expression arrayConcat(com.google.firebase.firestore.pipeline.Expression firstArray, Object secondArray, java.lang.Object... otherArrays); + method public final com.google.firebase.firestore.pipeline.Expression arrayConcat(com.google.firebase.firestore.pipeline.Expression secondArray, java.lang.Object... otherArrays); + method public final com.google.firebase.firestore.pipeline.Expression arrayConcat(Object secondArray, java.lang.Object... otherArrays); + method public static final com.google.firebase.firestore.pipeline.Expression arrayConcat(String firstArrayField, com.google.firebase.firestore.pipeline.Expression secondArray, java.lang.Object... otherArrays); + method public static final com.google.firebase.firestore.pipeline.Expression arrayConcat(String firstArrayField, Object secondArray, java.lang.Object... otherArrays); + method public final com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(com.google.firebase.firestore.pipeline.Expression element); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression element); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(com.google.firebase.firestore.pipeline.Expression array, Object element); + method public final com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(Object element); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression element); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(String arrayFieldName, Object element); + method public final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(com.google.firebase.firestore.pipeline.Expression array, java.util.List values); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(String arrayFieldName, java.util.List values); + method public final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(java.util.List values); + method public final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(com.google.firebase.firestore.pipeline.Expression array, java.util.List values); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(String arrayFieldName, java.util.List values); + method public final com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(java.util.List values); + method public final com.google.firebase.firestore.pipeline.Expression arrayGet(com.google.firebase.firestore.pipeline.Expression offset); + method public static final com.google.firebase.firestore.pipeline.Expression arrayGet(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression offset); + method public static final com.google.firebase.firestore.pipeline.Expression arrayGet(com.google.firebase.firestore.pipeline.Expression array, int offset); + method public final com.google.firebase.firestore.pipeline.Expression arrayGet(int offset); + method public static final com.google.firebase.firestore.pipeline.Expression arrayGet(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression offset); + method public static final com.google.firebase.firestore.pipeline.Expression arrayGet(String arrayFieldName, int offset); + method public final com.google.firebase.firestore.pipeline.Expression arrayLength(); + method public static final com.google.firebase.firestore.pipeline.Expression arrayLength(com.google.firebase.firestore.pipeline.Expression array); + method public static final com.google.firebase.firestore.pipeline.Expression arrayLength(String arrayFieldName); + method public final com.google.firebase.firestore.pipeline.Expression arrayReverse(); + method public static final com.google.firebase.firestore.pipeline.Expression arrayReverse(com.google.firebase.firestore.pipeline.Expression array); + method public static final com.google.firebase.firestore.pipeline.Expression arrayReverse(String arrayFieldName); method public final com.google.firebase.firestore.pipeline.Ordering ascending(); - method public final com.google.firebase.firestore.pipeline.AggregateFunction avg(); - method public final com.google.firebase.firestore.pipeline.Expr bitAnd(byte[] bitsOther); - method public final com.google.firebase.firestore.pipeline.Expr bitAnd(com.google.firebase.firestore.pipeline.Expr bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitAnd(com.google.firebase.firestore.pipeline.Expr bits, byte[] bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitAnd(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitAnd(String bitsFieldName, byte[] bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitAnd(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public final com.google.firebase.firestore.pipeline.Expr bitLeftShift(com.google.firebase.firestore.pipeline.Expr numberExpr); - method public static final com.google.firebase.firestore.pipeline.Expr bitLeftShift(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public static final com.google.firebase.firestore.pipeline.Expr bitLeftShift(com.google.firebase.firestore.pipeline.Expr bits, int number); - method public final com.google.firebase.firestore.pipeline.Expr bitLeftShift(int number); - method public static final com.google.firebase.firestore.pipeline.Expr bitLeftShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public static final com.google.firebase.firestore.pipeline.Expr bitLeftShift(String bitsFieldName, int number); - method public final com.google.firebase.firestore.pipeline.Expr bitNot(); - method public static final com.google.firebase.firestore.pipeline.Expr bitNot(com.google.firebase.firestore.pipeline.Expr bits); - method public static final com.google.firebase.firestore.pipeline.Expr bitNot(String bitsFieldName); - method public final com.google.firebase.firestore.pipeline.Expr bitOr(byte[] bitsOther); - method public final com.google.firebase.firestore.pipeline.Expr bitOr(com.google.firebase.firestore.pipeline.Expr bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitOr(com.google.firebase.firestore.pipeline.Expr bits, byte[] bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitOr(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitOr(String bitsFieldName, byte[] bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitOr(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public final com.google.firebase.firestore.pipeline.Expr bitRightShift(com.google.firebase.firestore.pipeline.Expr numberExpr); - method public static final com.google.firebase.firestore.pipeline.Expr bitRightShift(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public static final com.google.firebase.firestore.pipeline.Expr bitRightShift(com.google.firebase.firestore.pipeline.Expr bits, int number); - method public final com.google.firebase.firestore.pipeline.Expr bitRightShift(int number); - method public static final com.google.firebase.firestore.pipeline.Expr bitRightShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public static final com.google.firebase.firestore.pipeline.Expr bitRightShift(String bitsFieldName, int number); - method public final com.google.firebase.firestore.pipeline.Expr bitXor(byte[] bitsOther); - method public final com.google.firebase.firestore.pipeline.Expr bitXor(com.google.firebase.firestore.pipeline.Expr bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitXor(com.google.firebase.firestore.pipeline.Expr bits, byte[] bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitXor(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitXor(String bitsFieldName, byte[] bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr bitXor(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public static final com.google.firebase.firestore.pipeline.Expr blob(byte[] bytes); - method public final com.google.firebase.firestore.pipeline.Expr byteLength(); - method public static final com.google.firebase.firestore.pipeline.Expr byteLength(com.google.firebase.firestore.pipeline.Expr value); - method public static final com.google.firebase.firestore.pipeline.Expr byteLength(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr ceil(); - method public static final com.google.firebase.firestore.pipeline.Expr ceil(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr ceil(String numericField); - method public final com.google.firebase.firestore.pipeline.Expr charLength(); - method public static final com.google.firebase.firestore.pipeline.Expr charLength(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.Expr charLength(String fieldName); - method public static final com.google.firebase.firestore.pipeline.Expr cond(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.Expr thenExpr, com.google.firebase.firestore.pipeline.Expr elseExpr); - method public static final com.google.firebase.firestore.pipeline.Expr cond(com.google.firebase.firestore.pipeline.BooleanExpr condition, Object thenValue, Object elseValue); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr constant(boolean value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(byte[] value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.Blob value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.DocumentReference ref); - method public static final com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.GeoPoint value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.VectorValue value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.Timestamp value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(Number value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(String value); - method public static final com.google.firebase.firestore.pipeline.Expr constant(java.util.Date value); - method public final com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.pipeline.Expr vector); - method public static final com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.pipeline.Expr vector2); - method public static final com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.VectorValue vector2); - method public static final com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.pipeline.Expr vector1, double[] vector2); - method public final com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.VectorValue vector); - method public final com.google.firebase.firestore.pipeline.Expr cosineDistance(double[] vector); - method public static final com.google.firebase.firestore.pipeline.Expr cosineDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expr vector); - method public static final com.google.firebase.firestore.pipeline.Expr cosineDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); - method public static final com.google.firebase.firestore.pipeline.Expr cosineDistance(String vectorFieldName, double[] vector); + method public final com.google.firebase.firestore.pipeline.AggregateFunction average(); + method public final com.google.firebase.firestore.pipeline.Expression bitAnd(byte[] bitsOther); + method public final com.google.firebase.firestore.pipeline.Expression bitAnd(com.google.firebase.firestore.pipeline.Expression bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitAnd(com.google.firebase.firestore.pipeline.Expression bits, byte[] bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitAnd(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitAnd(String bitsFieldName, byte[] bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitAnd(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public final com.google.firebase.firestore.pipeline.Expression bitLeftShift(com.google.firebase.firestore.pipeline.Expression numberExpr); + method public static final com.google.firebase.firestore.pipeline.Expression bitLeftShift(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public static final com.google.firebase.firestore.pipeline.Expression bitLeftShift(com.google.firebase.firestore.pipeline.Expression bits, int number); + method public final com.google.firebase.firestore.pipeline.Expression bitLeftShift(int number); + method public static final com.google.firebase.firestore.pipeline.Expression bitLeftShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public static final com.google.firebase.firestore.pipeline.Expression bitLeftShift(String bitsFieldName, int number); + method public final com.google.firebase.firestore.pipeline.Expression bitNot(); + method public static final com.google.firebase.firestore.pipeline.Expression bitNot(com.google.firebase.firestore.pipeline.Expression bits); + method public static final com.google.firebase.firestore.pipeline.Expression bitNot(String bitsFieldName); + method public final com.google.firebase.firestore.pipeline.Expression bitOr(byte[] bitsOther); + method public final com.google.firebase.firestore.pipeline.Expression bitOr(com.google.firebase.firestore.pipeline.Expression bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitOr(com.google.firebase.firestore.pipeline.Expression bits, byte[] bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitOr(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitOr(String bitsFieldName, byte[] bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitOr(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public final com.google.firebase.firestore.pipeline.Expression bitRightShift(com.google.firebase.firestore.pipeline.Expression numberExpr); + method public static final com.google.firebase.firestore.pipeline.Expression bitRightShift(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public static final com.google.firebase.firestore.pipeline.Expression bitRightShift(com.google.firebase.firestore.pipeline.Expression bits, int number); + method public final com.google.firebase.firestore.pipeline.Expression bitRightShift(int number); + method public static final com.google.firebase.firestore.pipeline.Expression bitRightShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public static final com.google.firebase.firestore.pipeline.Expression bitRightShift(String bitsFieldName, int number); + method public final com.google.firebase.firestore.pipeline.Expression bitXor(byte[] bitsOther); + method public final com.google.firebase.firestore.pipeline.Expression bitXor(com.google.firebase.firestore.pipeline.Expression bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitXor(com.google.firebase.firestore.pipeline.Expression bits, byte[] bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitXor(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitXor(String bitsFieldName, byte[] bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression bitXor(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public static final com.google.firebase.firestore.pipeline.Expression blob(byte[] bytes); + method public final com.google.firebase.firestore.pipeline.Expression byteLength(); + method public static final com.google.firebase.firestore.pipeline.Expression byteLength(com.google.firebase.firestore.pipeline.Expression value); + method public static final com.google.firebase.firestore.pipeline.Expression byteLength(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression ceil(); + method public static final com.google.firebase.firestore.pipeline.Expression ceil(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression ceil(String numericField); + method public final com.google.firebase.firestore.pipeline.Expression charLength(); + method public static final com.google.firebase.firestore.pipeline.Expression charLength(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.Expression charLength(String fieldName); + method public static final com.google.firebase.firestore.pipeline.Expression conditional(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.Expression thenExpr, com.google.firebase.firestore.pipeline.Expression elseExpr); + method public static final com.google.firebase.firestore.pipeline.Expression conditional(com.google.firebase.firestore.pipeline.BooleanExpression condition, Object thenValue, Object elseValue); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression constant(boolean value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(byte[] value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.Blob value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.DocumentReference ref); + method public static final com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.GeoPoint value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.VectorValue value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.Timestamp value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(Number value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(String value); + method public static final com.google.firebase.firestore.pipeline.Expression constant(java.util.Date value); + method public final com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.pipeline.Expression vector); + method public static final com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.pipeline.Expression vector2); + method public static final com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.VectorValue vector2); + method public static final com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.pipeline.Expression vector1, double[] vector2); + method public final com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.VectorValue vector); + method public final com.google.firebase.firestore.pipeline.Expression cosineDistance(double[] vector); + method public static final com.google.firebase.firestore.pipeline.Expression cosineDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expression vector); + method public static final com.google.firebase.firestore.pipeline.Expression cosineDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); + method public static final com.google.firebase.firestore.pipeline.Expression cosineDistance(String vectorFieldName, double[] vector); method public final com.google.firebase.firestore.pipeline.AggregateFunction count(); method public final com.google.firebase.firestore.pipeline.Ordering descending(); - method public final com.google.firebase.firestore.pipeline.Expr divide(com.google.firebase.firestore.pipeline.Expr divisor); - method public static final com.google.firebase.firestore.pipeline.Expr divide(com.google.firebase.firestore.pipeline.Expr dividend, com.google.firebase.firestore.pipeline.Expr divisor); - method public static final com.google.firebase.firestore.pipeline.Expr divide(com.google.firebase.firestore.pipeline.Expr dividend, Number divisor); - method public final com.google.firebase.firestore.pipeline.Expr divide(Number divisor); - method public static final com.google.firebase.firestore.pipeline.Expr divide(String dividendFieldName, com.google.firebase.firestore.pipeline.Expr divisor); - method public static final com.google.firebase.firestore.pipeline.Expr divide(String dividendFieldName, Number divisor); - method public final com.google.firebase.firestore.pipeline.Expr documentId(); - method public static final com.google.firebase.firestore.pipeline.Expr documentId(com.google.firebase.firestore.DocumentReference docRef); - method public static final com.google.firebase.firestore.pipeline.Expr documentId(com.google.firebase.firestore.pipeline.Expr documentPath); - method public static final com.google.firebase.firestore.pipeline.Expr documentId(String documentPath); - method public final com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.pipeline.Expr vector); - method public static final com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.pipeline.Expr vector2); - method public static final com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.VectorValue vector2); - method public static final com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.pipeline.Expr vector1, double[] vector2); - method public final com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.VectorValue vector); - method public final com.google.firebase.firestore.pipeline.Expr dotProduct(double[] vector); - method public static final com.google.firebase.firestore.pipeline.Expr dotProduct(String vectorFieldName, com.google.firebase.firestore.pipeline.Expr vector); - method public static final com.google.firebase.firestore.pipeline.Expr dotProduct(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); - method public static final com.google.firebase.firestore.pipeline.Expr dotProduct(String vectorFieldName, double[] vector); - method public final com.google.firebase.firestore.pipeline.BooleanExpr endsWith(com.google.firebase.firestore.pipeline.Expr suffix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr endsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, com.google.firebase.firestore.pipeline.Expr suffix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr endsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, String suffix); - method public final com.google.firebase.firestore.pipeline.BooleanExpr endsWith(String suffix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr endsWith(String fieldName, com.google.firebase.firestore.pipeline.Expr suffix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr endsWith(String fieldName, String suffix); - method public final com.google.firebase.firestore.pipeline.BooleanExpr eq(com.google.firebase.firestore.pipeline.Expr other); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eq(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eq(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public final com.google.firebase.firestore.pipeline.BooleanExpr eq(Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eq(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eq(String fieldName, Object value); - method public final com.google.firebase.firestore.pipeline.BooleanExpr eqAny(com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eqAny(com.google.firebase.firestore.pipeline.Expr expression, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eqAny(com.google.firebase.firestore.pipeline.Expr expression, java.util.List values); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eqAny(String fieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr eqAny(String fieldName, java.util.List values); - method public final com.google.firebase.firestore.pipeline.BooleanExpr eqAny(java.util.List values); - method public final com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.pipeline.Expr vector); - method public static final com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.pipeline.Expr vector2); - method public static final com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.VectorValue vector2); - method public static final com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.pipeline.Expr vector1, double[] vector2); - method public final com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.VectorValue vector); - method public final com.google.firebase.firestore.pipeline.Expr euclideanDistance(double[] vector); - method public static final com.google.firebase.firestore.pipeline.Expr euclideanDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expr vector); - method public static final com.google.firebase.firestore.pipeline.Expr euclideanDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); - method public static final com.google.firebase.firestore.pipeline.Expr euclideanDistance(String vectorFieldName, double[] vector); - method public final com.google.firebase.firestore.pipeline.BooleanExpr exists(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr exists(com.google.firebase.firestore.pipeline.Expr value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr exists(String fieldName); - method public static final com.google.firebase.firestore.pipeline.Expr exp(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr exp(String numericField); + method public final com.google.firebase.firestore.pipeline.Expression divide(com.google.firebase.firestore.pipeline.Expression divisor); + method public static final com.google.firebase.firestore.pipeline.Expression divide(com.google.firebase.firestore.pipeline.Expression dividend, com.google.firebase.firestore.pipeline.Expression divisor); + method public static final com.google.firebase.firestore.pipeline.Expression divide(com.google.firebase.firestore.pipeline.Expression dividend, Number divisor); + method public final com.google.firebase.firestore.pipeline.Expression divide(Number divisor); + method public static final com.google.firebase.firestore.pipeline.Expression divide(String dividendFieldName, com.google.firebase.firestore.pipeline.Expression divisor); + method public static final com.google.firebase.firestore.pipeline.Expression divide(String dividendFieldName, Number divisor); + method public final com.google.firebase.firestore.pipeline.Expression documentId(); + method public static final com.google.firebase.firestore.pipeline.Expression documentId(com.google.firebase.firestore.DocumentReference docRef); + method public static final com.google.firebase.firestore.pipeline.Expression documentId(com.google.firebase.firestore.pipeline.Expression documentPath); + method public static final com.google.firebase.firestore.pipeline.Expression documentId(String documentPath); + method public final com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.pipeline.Expression vector); + method public static final com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.pipeline.Expression vector2); + method public static final com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.VectorValue vector2); + method public static final com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.pipeline.Expression vector1, double[] vector2); + method public final com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.VectorValue vector); + method public final com.google.firebase.firestore.pipeline.Expression dotProduct(double[] vector); + method public static final com.google.firebase.firestore.pipeline.Expression dotProduct(String vectorFieldName, com.google.firebase.firestore.pipeline.Expression vector); + method public static final com.google.firebase.firestore.pipeline.Expression dotProduct(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); + method public static final com.google.firebase.firestore.pipeline.Expression dotProduct(String vectorFieldName, double[] vector); + method public final com.google.firebase.firestore.pipeline.BooleanExpression endsWith(com.google.firebase.firestore.pipeline.Expression suffix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression endsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, com.google.firebase.firestore.pipeline.Expression suffix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression endsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, String suffix); + method public final com.google.firebase.firestore.pipeline.BooleanExpression endsWith(String suffix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression endsWith(String fieldName, com.google.firebase.firestore.pipeline.Expression suffix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression endsWith(String fieldName, String suffix); + method public final com.google.firebase.firestore.pipeline.BooleanExpression equal(com.google.firebase.firestore.pipeline.Expression other); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equal(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equal(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public final com.google.firebase.firestore.pipeline.BooleanExpression equal(Object value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equal(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equal(String fieldName, Object value); + method public final com.google.firebase.firestore.pipeline.BooleanExpression equalAny(com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equalAny(com.google.firebase.firestore.pipeline.Expression expression, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equalAny(com.google.firebase.firestore.pipeline.Expression expression, java.util.List values); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equalAny(String fieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression equalAny(String fieldName, java.util.List values); + method public final com.google.firebase.firestore.pipeline.BooleanExpression equalAny(java.util.List values); + method public final com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.pipeline.Expression vector); + method public static final com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.pipeline.Expression vector2); + method public static final com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.VectorValue vector2); + method public static final com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.pipeline.Expression vector1, double[] vector2); + method public final com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.VectorValue vector); + method public final com.google.firebase.firestore.pipeline.Expression euclideanDistance(double[] vector); + method public static final com.google.firebase.firestore.pipeline.Expression euclideanDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expression vector); + method public static final com.google.firebase.firestore.pipeline.Expression euclideanDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); + method public static final com.google.firebase.firestore.pipeline.Expression euclideanDistance(String vectorFieldName, double[] vector); + method public final com.google.firebase.firestore.pipeline.BooleanExpression exists(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression exists(com.google.firebase.firestore.pipeline.Expression value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression exists(String fieldName); + method public static final com.google.firebase.firestore.pipeline.Expression exp(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression exp(String numericField); method public static final com.google.firebase.firestore.pipeline.Field field(com.google.firebase.firestore.FieldPath fieldPath); method public static final com.google.firebase.firestore.pipeline.Field field(String name); - method public final com.google.firebase.firestore.pipeline.Expr floor(); - method public static final com.google.firebase.firestore.pipeline.Expr floor(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr floor(String numericField); - method public static final com.google.firebase.firestore.pipeline.Expr generic(String name, com.google.firebase.firestore.pipeline.Expr... expr); - method public final com.google.firebase.firestore.pipeline.BooleanExpr gt(com.google.firebase.firestore.pipeline.Expr other); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gt(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gt(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public final com.google.firebase.firestore.pipeline.BooleanExpr gt(Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gt(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gt(String fieldName, Object value); - method public final com.google.firebase.firestore.pipeline.BooleanExpr gte(com.google.firebase.firestore.pipeline.Expr other); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gte(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gte(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public final com.google.firebase.firestore.pipeline.BooleanExpr gte(Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gte(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr gte(String fieldName, Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr ifError(com.google.firebase.firestore.pipeline.BooleanExpr tryExpr, com.google.firebase.firestore.pipeline.BooleanExpr catchExpr); - method public final com.google.firebase.firestore.pipeline.Expr ifError(com.google.firebase.firestore.pipeline.Expr catchExpr); - method public static final com.google.firebase.firestore.pipeline.Expr ifError(com.google.firebase.firestore.pipeline.Expr tryExpr, com.google.firebase.firestore.pipeline.Expr catchExpr); - method public static final com.google.firebase.firestore.pipeline.Expr ifError(com.google.firebase.firestore.pipeline.Expr tryExpr, Object catchValue); - method public final com.google.firebase.firestore.pipeline.Expr ifError(Object catchValue); - method public final com.google.firebase.firestore.pipeline.BooleanExpr isAbsent(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isAbsent(com.google.firebase.firestore.pipeline.Expr value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isAbsent(String fieldName); - method public final com.google.firebase.firestore.pipeline.BooleanExpr isError(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isError(com.google.firebase.firestore.pipeline.Expr expr); - method public final com.google.firebase.firestore.pipeline.BooleanExpr isNan(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNan(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNan(String fieldName); - method public final com.google.firebase.firestore.pipeline.BooleanExpr isNotNan(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNotNan(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNotNan(String fieldName); - method public final com.google.firebase.firestore.pipeline.BooleanExpr isNotNull(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNotNull(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNotNull(String fieldName); - method public final com.google.firebase.firestore.pipeline.BooleanExpr isNull(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNull(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr isNull(String fieldName); - method public final com.google.firebase.firestore.pipeline.BooleanExpr like(com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr like(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr like(com.google.firebase.firestore.pipeline.Expr stringExpression, String pattern); - method public final com.google.firebase.firestore.pipeline.BooleanExpr like(String pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr like(String fieldName, com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr like(String fieldName, String pattern); - method public static final com.google.firebase.firestore.pipeline.Expr ln(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr ln(String numericField); - method public static final com.google.firebase.firestore.pipeline.Expr log(com.google.firebase.firestore.pipeline.Expr numericExpr, com.google.firebase.firestore.pipeline.Expr base); - method public static final com.google.firebase.firestore.pipeline.Expr log(com.google.firebase.firestore.pipeline.Expr numericExpr, Number base); - method public static final com.google.firebase.firestore.pipeline.Expr log(String numericField, com.google.firebase.firestore.pipeline.Expr base); - method public static final com.google.firebase.firestore.pipeline.Expr log(String numericField, Number base); - method public static final com.google.firebase.firestore.pipeline.Expr log10(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr log10(String numericField); - method public static final com.google.firebase.firestore.pipeline.Expr logicalMaximum(com.google.firebase.firestore.pipeline.Expr expr, java.lang.Object... others); - method public final com.google.firebase.firestore.pipeline.Expr logicalMaximum(com.google.firebase.firestore.pipeline.Expr... others); - method public final com.google.firebase.firestore.pipeline.Expr logicalMaximum(java.lang.Object... others); - method public static final com.google.firebase.firestore.pipeline.Expr logicalMaximum(String fieldName, java.lang.Object... others); - method public static final com.google.firebase.firestore.pipeline.Expr logicalMinimum(com.google.firebase.firestore.pipeline.Expr expr, java.lang.Object... others); - method public final com.google.firebase.firestore.pipeline.Expr logicalMinimum(com.google.firebase.firestore.pipeline.Expr... others); - method public final com.google.firebase.firestore.pipeline.Expr logicalMinimum(java.lang.Object... others); - method public static final com.google.firebase.firestore.pipeline.Expr logicalMinimum(String fieldName, java.lang.Object... others); - method public final com.google.firebase.firestore.pipeline.BooleanExpr lt(com.google.firebase.firestore.pipeline.Expr other); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lt(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lt(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public final com.google.firebase.firestore.pipeline.BooleanExpr lt(Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lt(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lt(String fieldName, Object value); - method public final com.google.firebase.firestore.pipeline.BooleanExpr lte(com.google.firebase.firestore.pipeline.Expr other); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lte(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lte(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public final com.google.firebase.firestore.pipeline.BooleanExpr lte(Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lte(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr lte(String fieldName, Object value); - method public static final com.google.firebase.firestore.pipeline.Expr map(java.util.Map elements); - method public final com.google.firebase.firestore.pipeline.Expr mapGet(com.google.firebase.firestore.pipeline.Expr keyExpression); - method public static final com.google.firebase.firestore.pipeline.Expr mapGet(com.google.firebase.firestore.pipeline.Expr mapExpression, com.google.firebase.firestore.pipeline.Expr keyExpression); - method public static final com.google.firebase.firestore.pipeline.Expr mapGet(com.google.firebase.firestore.pipeline.Expr mapExpression, String key); - method public final com.google.firebase.firestore.pipeline.Expr mapGet(String key); - method public static final com.google.firebase.firestore.pipeline.Expr mapGet(String fieldName, com.google.firebase.firestore.pipeline.Expr keyExpression); - method public static final com.google.firebase.firestore.pipeline.Expr mapGet(String fieldName, String key); - method public static final com.google.firebase.firestore.pipeline.Expr mapMerge(com.google.firebase.firestore.pipeline.Expr firstMap, com.google.firebase.firestore.pipeline.Expr secondMap, com.google.firebase.firestore.pipeline.Expr... otherMaps); - method public final com.google.firebase.firestore.pipeline.Expr mapMerge(com.google.firebase.firestore.pipeline.Expr mapExpr, com.google.firebase.firestore.pipeline.Expr... otherMaps); - method public static final com.google.firebase.firestore.pipeline.Expr mapMerge(String firstMapFieldName, com.google.firebase.firestore.pipeline.Expr secondMap, com.google.firebase.firestore.pipeline.Expr... otherMaps); - method public final com.google.firebase.firestore.pipeline.Expr mapRemove(com.google.firebase.firestore.pipeline.Expr keyExpression); - method public static final com.google.firebase.firestore.pipeline.Expr mapRemove(com.google.firebase.firestore.pipeline.Expr mapExpr, com.google.firebase.firestore.pipeline.Expr key); - method public static final com.google.firebase.firestore.pipeline.Expr mapRemove(com.google.firebase.firestore.pipeline.Expr mapExpr, String key); - method public final com.google.firebase.firestore.pipeline.Expr mapRemove(String key); - method public static final com.google.firebase.firestore.pipeline.Expr mapRemove(String mapField, com.google.firebase.firestore.pipeline.Expr key); - method public static final com.google.firebase.firestore.pipeline.Expr mapRemove(String mapField, String key); + method public final com.google.firebase.firestore.pipeline.Expression floor(); + method public static final com.google.firebase.firestore.pipeline.Expression floor(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression floor(String numericField); + method public static final com.google.firebase.firestore.pipeline.Expression generic(String name, com.google.firebase.firestore.pipeline.Expression... expr); + method public final com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(com.google.firebase.firestore.pipeline.Expression other); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public final com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(Object value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(String fieldName, Object value); + method public final com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(com.google.firebase.firestore.pipeline.Expression other); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public final com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(Object value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(String fieldName, Object value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression ifError(com.google.firebase.firestore.pipeline.BooleanExpression tryExpr, com.google.firebase.firestore.pipeline.BooleanExpression catchExpr); + method public final com.google.firebase.firestore.pipeline.Expression ifError(com.google.firebase.firestore.pipeline.Expression catchExpr); + method public static final com.google.firebase.firestore.pipeline.Expression ifError(com.google.firebase.firestore.pipeline.Expression tryExpr, com.google.firebase.firestore.pipeline.Expression catchExpr); + method public static final com.google.firebase.firestore.pipeline.Expression ifError(com.google.firebase.firestore.pipeline.Expression tryExpr, Object catchValue); + method public final com.google.firebase.firestore.pipeline.Expression ifError(Object catchValue); + method public final com.google.firebase.firestore.pipeline.BooleanExpression isAbsent(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isAbsent(com.google.firebase.firestore.pipeline.Expression value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isAbsent(String fieldName); + method public final com.google.firebase.firestore.pipeline.BooleanExpression isError(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isError(com.google.firebase.firestore.pipeline.Expression expr); + method public final com.google.firebase.firestore.pipeline.BooleanExpression isNan(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNan(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNan(String fieldName); + method public final com.google.firebase.firestore.pipeline.BooleanExpression isNotNan(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNotNan(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNotNan(String fieldName); + method public final com.google.firebase.firestore.pipeline.BooleanExpression isNotNull(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNotNull(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNotNull(String fieldName); + method public final com.google.firebase.firestore.pipeline.BooleanExpression isNull(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNull(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression isNull(String fieldName); + method public final com.google.firebase.firestore.pipeline.BooleanExpression lessThan(com.google.firebase.firestore.pipeline.Expression other); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThan(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThan(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public final com.google.firebase.firestore.pipeline.BooleanExpression lessThan(Object value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThan(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThan(String fieldName, Object value); + method public final com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(com.google.firebase.firestore.pipeline.Expression other); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public final com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(Object value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(String fieldName, Object value); + method public final com.google.firebase.firestore.pipeline.BooleanExpression like(com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression like(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression like(com.google.firebase.firestore.pipeline.Expression stringExpression, String pattern); + method public final com.google.firebase.firestore.pipeline.BooleanExpression like(String pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression like(String fieldName, com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression like(String fieldName, String pattern); + method public static final com.google.firebase.firestore.pipeline.Expression ln(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression ln(String numericField); + method public static final com.google.firebase.firestore.pipeline.Expression log(com.google.firebase.firestore.pipeline.Expression numericExpr, com.google.firebase.firestore.pipeline.Expression base); + method public static final com.google.firebase.firestore.pipeline.Expression log(com.google.firebase.firestore.pipeline.Expression numericExpr, Number base); + method public static final com.google.firebase.firestore.pipeline.Expression log(String numericField, com.google.firebase.firestore.pipeline.Expression base); + method public static final com.google.firebase.firestore.pipeline.Expression log(String numericField, Number base); + method public static final com.google.firebase.firestore.pipeline.Expression log10(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression log10(String numericField); + method public static final com.google.firebase.firestore.pipeline.Expression logicalMaximum(com.google.firebase.firestore.pipeline.Expression expr, java.lang.Object... others); + method public final com.google.firebase.firestore.pipeline.Expression logicalMaximum(com.google.firebase.firestore.pipeline.Expression... others); + method public final com.google.firebase.firestore.pipeline.Expression logicalMaximum(java.lang.Object... others); + method public static final com.google.firebase.firestore.pipeline.Expression logicalMaximum(String fieldName, java.lang.Object... others); + method public static final com.google.firebase.firestore.pipeline.Expression logicalMinimum(com.google.firebase.firestore.pipeline.Expression expr, java.lang.Object... others); + method public final com.google.firebase.firestore.pipeline.Expression logicalMinimum(com.google.firebase.firestore.pipeline.Expression... others); + method public final com.google.firebase.firestore.pipeline.Expression logicalMinimum(java.lang.Object... others); + method public static final com.google.firebase.firestore.pipeline.Expression logicalMinimum(String fieldName, java.lang.Object... others); + method public static final com.google.firebase.firestore.pipeline.Expression map(java.util.Map elements); + method public final com.google.firebase.firestore.pipeline.Expression mapGet(com.google.firebase.firestore.pipeline.Expression keyExpression); + method public static final com.google.firebase.firestore.pipeline.Expression mapGet(com.google.firebase.firestore.pipeline.Expression mapExpression, com.google.firebase.firestore.pipeline.Expression keyExpression); + method public static final com.google.firebase.firestore.pipeline.Expression mapGet(com.google.firebase.firestore.pipeline.Expression mapExpression, String key); + method public final com.google.firebase.firestore.pipeline.Expression mapGet(String key); + method public static final com.google.firebase.firestore.pipeline.Expression mapGet(String fieldName, com.google.firebase.firestore.pipeline.Expression keyExpression); + method public static final com.google.firebase.firestore.pipeline.Expression mapGet(String fieldName, String key); + method public static final com.google.firebase.firestore.pipeline.Expression mapMerge(com.google.firebase.firestore.pipeline.Expression firstMap, com.google.firebase.firestore.pipeline.Expression secondMap, com.google.firebase.firestore.pipeline.Expression... otherMaps); + method public final com.google.firebase.firestore.pipeline.Expression mapMerge(com.google.firebase.firestore.pipeline.Expression mapExpr, com.google.firebase.firestore.pipeline.Expression... otherMaps); + method public static final com.google.firebase.firestore.pipeline.Expression mapMerge(String firstMapFieldName, com.google.firebase.firestore.pipeline.Expression secondMap, com.google.firebase.firestore.pipeline.Expression... otherMaps); + method public final com.google.firebase.firestore.pipeline.Expression mapRemove(com.google.firebase.firestore.pipeline.Expression keyExpression); + method public static final com.google.firebase.firestore.pipeline.Expression mapRemove(com.google.firebase.firestore.pipeline.Expression mapExpr, com.google.firebase.firestore.pipeline.Expression key); + method public static final com.google.firebase.firestore.pipeline.Expression mapRemove(com.google.firebase.firestore.pipeline.Expression mapExpr, String key); + method public final com.google.firebase.firestore.pipeline.Expression mapRemove(String key); + method public static final com.google.firebase.firestore.pipeline.Expression mapRemove(String mapField, com.google.firebase.firestore.pipeline.Expression key); + method public static final com.google.firebase.firestore.pipeline.Expression mapRemove(String mapField, String key); method public final com.google.firebase.firestore.pipeline.AggregateFunction maximum(); method public final com.google.firebase.firestore.pipeline.AggregateFunction minimum(); - method public final com.google.firebase.firestore.pipeline.Expr mod(com.google.firebase.firestore.pipeline.Expr divisor); - method public static final com.google.firebase.firestore.pipeline.Expr mod(com.google.firebase.firestore.pipeline.Expr dividend, com.google.firebase.firestore.pipeline.Expr divisor); - method public static final com.google.firebase.firestore.pipeline.Expr mod(com.google.firebase.firestore.pipeline.Expr dividend, Number divisor); - method public final com.google.firebase.firestore.pipeline.Expr mod(Number divisor); - method public static final com.google.firebase.firestore.pipeline.Expr mod(String dividendFieldName, com.google.firebase.firestore.pipeline.Expr divisor); - method public static final com.google.firebase.firestore.pipeline.Expr mod(String dividendFieldName, Number divisor); - method public final com.google.firebase.firestore.pipeline.Expr multiply(com.google.firebase.firestore.pipeline.Expr second); - method public static final com.google.firebase.firestore.pipeline.Expr multiply(com.google.firebase.firestore.pipeline.Expr first, com.google.firebase.firestore.pipeline.Expr second); - method public static final com.google.firebase.firestore.pipeline.Expr multiply(com.google.firebase.firestore.pipeline.Expr first, Number second); - method public final com.google.firebase.firestore.pipeline.Expr multiply(Number second); - method public static final com.google.firebase.firestore.pipeline.Expr multiply(String numericFieldName, com.google.firebase.firestore.pipeline.Expr second); - method public static final com.google.firebase.firestore.pipeline.Expr multiply(String numericFieldName, Number second); - method public final com.google.firebase.firestore.pipeline.BooleanExpr neq(com.google.firebase.firestore.pipeline.Expr other); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr neq(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr neq(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public final com.google.firebase.firestore.pipeline.BooleanExpr neq(Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr neq(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr neq(String fieldName, Object value); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr not(com.google.firebase.firestore.pipeline.BooleanExpr condition); - method public final com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(com.google.firebase.firestore.pipeline.Expr expression, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(com.google.firebase.firestore.pipeline.Expr expression, java.util.List values); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(String fieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(String fieldName, java.util.List values); - method public final com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(java.util.List values); - method public static final com.google.firebase.firestore.pipeline.Expr nullValue(); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr or(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.BooleanExpr... conditions); - method public final com.google.firebase.firestore.pipeline.Expr pow(com.google.firebase.firestore.pipeline.Expr exponent); - method public static final com.google.firebase.firestore.pipeline.Expr pow(com.google.firebase.firestore.pipeline.Expr numericExpr, com.google.firebase.firestore.pipeline.Expr exponent); - method public static final com.google.firebase.firestore.pipeline.Expr pow(com.google.firebase.firestore.pipeline.Expr numericExpr, Number exponent); - method public final com.google.firebase.firestore.pipeline.Expr pow(Number exponent); - method public static final com.google.firebase.firestore.pipeline.Expr pow(String numericField, com.google.firebase.firestore.pipeline.Expr exponent); - method public static final com.google.firebase.firestore.pipeline.Expr pow(String numericField, Number exponent); - method public static final com.google.firebase.firestore.pipeline.Expr rand(); - method public final com.google.firebase.firestore.pipeline.BooleanExpr regexContains(com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexContains(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexContains(com.google.firebase.firestore.pipeline.Expr stringExpression, String pattern); - method public final com.google.firebase.firestore.pipeline.BooleanExpr regexContains(String pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexContains(String fieldName, com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexContains(String fieldName, String pattern); - method public final com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(com.google.firebase.firestore.pipeline.Expr stringExpression, String pattern); - method public final com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(String pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(String fieldName, com.google.firebase.firestore.pipeline.Expr pattern); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(String fieldName, String pattern); - method public final com.google.firebase.firestore.pipeline.Expr replaceAll(com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceAll(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceAll(com.google.firebase.firestore.pipeline.Expr stringExpression, String find, String replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceAll(String fieldName, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public final com.google.firebase.firestore.pipeline.Expr replaceAll(String find, String replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceAll(String fieldName, String find, String replace); - method public final com.google.firebase.firestore.pipeline.Expr replaceFirst(com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceFirst(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceFirst(com.google.firebase.firestore.pipeline.Expr stringExpression, String find, String replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceFirst(String fieldName, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public final com.google.firebase.firestore.pipeline.Expr replaceFirst(String find, String replace); - method public static final com.google.firebase.firestore.pipeline.Expr replaceFirst(String fieldName, String find, String replace); - method public final com.google.firebase.firestore.pipeline.Expr reverse(); - method public static final com.google.firebase.firestore.pipeline.Expr reverse(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public static final com.google.firebase.firestore.pipeline.Expr reverse(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr round(); - method public static final com.google.firebase.firestore.pipeline.Expr round(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr round(String numericField); - method public final com.google.firebase.firestore.pipeline.Expr roundToPrecision(com.google.firebase.firestore.pipeline.Expr decimalPlace); - method public static final com.google.firebase.firestore.pipeline.Expr roundToPrecision(com.google.firebase.firestore.pipeline.Expr numericExpr, com.google.firebase.firestore.pipeline.Expr decimalPlace); - method public static final com.google.firebase.firestore.pipeline.Expr roundToPrecision(com.google.firebase.firestore.pipeline.Expr numericExpr, int decimalPlace); - method public final com.google.firebase.firestore.pipeline.Expr roundToPrecision(int decimalPlace); - method public static final com.google.firebase.firestore.pipeline.Expr roundToPrecision(String numericField, com.google.firebase.firestore.pipeline.Expr decimalPlace); - method public static final com.google.firebase.firestore.pipeline.Expr roundToPrecision(String numericField, int decimalPlace); - method public final com.google.firebase.firestore.pipeline.Expr sqrt(); - method public static final com.google.firebase.firestore.pipeline.Expr sqrt(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public static final com.google.firebase.firestore.pipeline.Expr sqrt(String numericField); - method public final com.google.firebase.firestore.pipeline.BooleanExpr startsWith(com.google.firebase.firestore.pipeline.Expr prefix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr startsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, com.google.firebase.firestore.pipeline.Expr prefix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr startsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, String prefix); - method public final com.google.firebase.firestore.pipeline.BooleanExpr startsWith(String prefix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr startsWith(String fieldName, com.google.firebase.firestore.pipeline.Expr prefix); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr startsWith(String fieldName, String prefix); - method public static final com.google.firebase.firestore.pipeline.Expr strConcat(com.google.firebase.firestore.pipeline.Expr firstString, com.google.firebase.firestore.pipeline.Expr... otherStrings); - method public static final com.google.firebase.firestore.pipeline.Expr strConcat(com.google.firebase.firestore.pipeline.Expr firstString, java.lang.Object... otherStrings); - method public final com.google.firebase.firestore.pipeline.Expr strConcat(com.google.firebase.firestore.pipeline.Expr... stringExpressions); - method public final com.google.firebase.firestore.pipeline.Expr strConcat(java.lang.Object... strings); - method public static final com.google.firebase.firestore.pipeline.Expr strConcat(String fieldName, com.google.firebase.firestore.pipeline.Expr... otherStrings); - method public static final com.google.firebase.firestore.pipeline.Expr strConcat(String fieldName, java.lang.Object... otherStrings); - method public final com.google.firebase.firestore.pipeline.Expr strConcat(java.lang.String... strings); - method public final com.google.firebase.firestore.pipeline.BooleanExpr strContains(com.google.firebase.firestore.pipeline.Expr substring); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr strContains(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr substring); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr strContains(com.google.firebase.firestore.pipeline.Expr stringExpression, String substring); - method public final com.google.firebase.firestore.pipeline.BooleanExpr strContains(String substring); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr strContains(String fieldName, com.google.firebase.firestore.pipeline.Expr substring); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr strContains(String fieldName, String substring); - method public final com.google.firebase.firestore.pipeline.Expr substr(com.google.firebase.firestore.pipeline.Expr start, com.google.firebase.firestore.pipeline.Expr length); - method public static final com.google.firebase.firestore.pipeline.Expr substr(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr index, com.google.firebase.firestore.pipeline.Expr length); - method public final com.google.firebase.firestore.pipeline.Expr substr(int start, int length); - method public static final com.google.firebase.firestore.pipeline.Expr substr(String fieldName, int index, int length); - method public final com.google.firebase.firestore.pipeline.Expr subtract(com.google.firebase.firestore.pipeline.Expr subtrahend); - method public static final com.google.firebase.firestore.pipeline.Expr subtract(com.google.firebase.firestore.pipeline.Expr minuend, com.google.firebase.firestore.pipeline.Expr subtrahend); - method public static final com.google.firebase.firestore.pipeline.Expr subtract(com.google.firebase.firestore.pipeline.Expr minuend, Number subtrahend); - method public final com.google.firebase.firestore.pipeline.Expr subtract(Number subtrahend); - method public static final com.google.firebase.firestore.pipeline.Expr subtract(String numericFieldName, com.google.firebase.firestore.pipeline.Expr subtrahend); - method public static final com.google.firebase.firestore.pipeline.Expr subtract(String numericFieldName, Number subtrahend); + method public final com.google.firebase.firestore.pipeline.Expression mod(com.google.firebase.firestore.pipeline.Expression divisor); + method public static final com.google.firebase.firestore.pipeline.Expression mod(com.google.firebase.firestore.pipeline.Expression dividend, com.google.firebase.firestore.pipeline.Expression divisor); + method public static final com.google.firebase.firestore.pipeline.Expression mod(com.google.firebase.firestore.pipeline.Expression dividend, Number divisor); + method public final com.google.firebase.firestore.pipeline.Expression mod(Number divisor); + method public static final com.google.firebase.firestore.pipeline.Expression mod(String dividendFieldName, com.google.firebase.firestore.pipeline.Expression divisor); + method public static final com.google.firebase.firestore.pipeline.Expression mod(String dividendFieldName, Number divisor); + method public final com.google.firebase.firestore.pipeline.Expression multiply(com.google.firebase.firestore.pipeline.Expression second); + method public static final com.google.firebase.firestore.pipeline.Expression multiply(com.google.firebase.firestore.pipeline.Expression first, com.google.firebase.firestore.pipeline.Expression second); + method public static final com.google.firebase.firestore.pipeline.Expression multiply(com.google.firebase.firestore.pipeline.Expression first, Number second); + method public final com.google.firebase.firestore.pipeline.Expression multiply(Number second); + method public static final com.google.firebase.firestore.pipeline.Expression multiply(String numericFieldName, com.google.firebase.firestore.pipeline.Expression second); + method public static final com.google.firebase.firestore.pipeline.Expression multiply(String numericFieldName, Number second); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression not(com.google.firebase.firestore.pipeline.BooleanExpression condition); + method public final com.google.firebase.firestore.pipeline.BooleanExpression notEqual(com.google.firebase.firestore.pipeline.Expression other); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqual(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqual(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public final com.google.firebase.firestore.pipeline.BooleanExpression notEqual(Object value); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqual(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqual(String fieldName, Object value); + method public final com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(com.google.firebase.firestore.pipeline.Expression expression, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(com.google.firebase.firestore.pipeline.Expression expression, java.util.List values); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(String fieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(String fieldName, java.util.List values); + method public final com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(java.util.List values); + method public static final com.google.firebase.firestore.pipeline.Expression nullValue(); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression or(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.BooleanExpression... conditions); + method public final com.google.firebase.firestore.pipeline.Expression pow(com.google.firebase.firestore.pipeline.Expression exponent); + method public static final com.google.firebase.firestore.pipeline.Expression pow(com.google.firebase.firestore.pipeline.Expression numericExpr, com.google.firebase.firestore.pipeline.Expression exponent); + method public static final com.google.firebase.firestore.pipeline.Expression pow(com.google.firebase.firestore.pipeline.Expression numericExpr, Number exponent); + method public final com.google.firebase.firestore.pipeline.Expression pow(Number exponent); + method public static final com.google.firebase.firestore.pipeline.Expression pow(String numericField, com.google.firebase.firestore.pipeline.Expression exponent); + method public static final com.google.firebase.firestore.pipeline.Expression pow(String numericField, Number exponent); + method public static final com.google.firebase.firestore.pipeline.Expression rand(); + method public final com.google.firebase.firestore.pipeline.BooleanExpression regexContains(com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexContains(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexContains(com.google.firebase.firestore.pipeline.Expression stringExpression, String pattern); + method public final com.google.firebase.firestore.pipeline.BooleanExpression regexContains(String pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexContains(String fieldName, com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexContains(String fieldName, String pattern); + method public final com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(com.google.firebase.firestore.pipeline.Expression stringExpression, String pattern); + method public final com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(String pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(String fieldName, com.google.firebase.firestore.pipeline.Expression pattern); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(String fieldName, String pattern); + method public final com.google.firebase.firestore.pipeline.Expression replaceAll(com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceAll(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceAll(com.google.firebase.firestore.pipeline.Expression stringExpression, String find, String replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceAll(String fieldName, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public final com.google.firebase.firestore.pipeline.Expression replaceAll(String find, String replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceAll(String fieldName, String find, String replace); + method public final com.google.firebase.firestore.pipeline.Expression replaceFirst(com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceFirst(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceFirst(com.google.firebase.firestore.pipeline.Expression stringExpression, String find, String replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceFirst(String fieldName, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public final com.google.firebase.firestore.pipeline.Expression replaceFirst(String find, String replace); + method public static final com.google.firebase.firestore.pipeline.Expression replaceFirst(String fieldName, String find, String replace); + method public final com.google.firebase.firestore.pipeline.Expression reverse(); + method public static final com.google.firebase.firestore.pipeline.Expression reverse(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public static final com.google.firebase.firestore.pipeline.Expression reverse(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression round(); + method public static final com.google.firebase.firestore.pipeline.Expression round(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression round(String numericField); + method public final com.google.firebase.firestore.pipeline.Expression roundToPrecision(com.google.firebase.firestore.pipeline.Expression decimalPlace); + method public static final com.google.firebase.firestore.pipeline.Expression roundToPrecision(com.google.firebase.firestore.pipeline.Expression numericExpr, com.google.firebase.firestore.pipeline.Expression decimalPlace); + method public static final com.google.firebase.firestore.pipeline.Expression roundToPrecision(com.google.firebase.firestore.pipeline.Expression numericExpr, int decimalPlace); + method public final com.google.firebase.firestore.pipeline.Expression roundToPrecision(int decimalPlace); + method public static final com.google.firebase.firestore.pipeline.Expression roundToPrecision(String numericField, com.google.firebase.firestore.pipeline.Expression decimalPlace); + method public static final com.google.firebase.firestore.pipeline.Expression roundToPrecision(String numericField, int decimalPlace); + method public final com.google.firebase.firestore.pipeline.Expression sqrt(); + method public static final com.google.firebase.firestore.pipeline.Expression sqrt(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public static final com.google.firebase.firestore.pipeline.Expression sqrt(String numericField); + method public final com.google.firebase.firestore.pipeline.BooleanExpression startsWith(com.google.firebase.firestore.pipeline.Expression prefix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression startsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, com.google.firebase.firestore.pipeline.Expression prefix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression startsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, String prefix); + method public final com.google.firebase.firestore.pipeline.BooleanExpression startsWith(String prefix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression startsWith(String fieldName, com.google.firebase.firestore.pipeline.Expression prefix); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression startsWith(String fieldName, String prefix); + method public static final com.google.firebase.firestore.pipeline.Expression stringConcat(com.google.firebase.firestore.pipeline.Expression firstString, com.google.firebase.firestore.pipeline.Expression... otherStrings); + method public static final com.google.firebase.firestore.pipeline.Expression stringConcat(com.google.firebase.firestore.pipeline.Expression firstString, java.lang.Object... otherStrings); + method public final com.google.firebase.firestore.pipeline.Expression stringConcat(com.google.firebase.firestore.pipeline.Expression... stringExpressions); + method public final com.google.firebase.firestore.pipeline.Expression stringConcat(java.lang.Object... strings); + method public static final com.google.firebase.firestore.pipeline.Expression stringConcat(String fieldName, com.google.firebase.firestore.pipeline.Expression... otherStrings); + method public static final com.google.firebase.firestore.pipeline.Expression stringConcat(String fieldName, java.lang.Object... otherStrings); + method public final com.google.firebase.firestore.pipeline.Expression stringConcat(java.lang.String... strings); + method public final com.google.firebase.firestore.pipeline.BooleanExpression stringContains(com.google.firebase.firestore.pipeline.Expression substring); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression stringContains(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression substring); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression stringContains(com.google.firebase.firestore.pipeline.Expression stringExpression, String substring); + method public final com.google.firebase.firestore.pipeline.BooleanExpression stringContains(String substring); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression stringContains(String fieldName, com.google.firebase.firestore.pipeline.Expression substring); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression stringContains(String fieldName, String substring); + method public final com.google.firebase.firestore.pipeline.Expression substring(com.google.firebase.firestore.pipeline.Expression start, com.google.firebase.firestore.pipeline.Expression length); + method public static final com.google.firebase.firestore.pipeline.Expression substring(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression index, com.google.firebase.firestore.pipeline.Expression length); + method public final com.google.firebase.firestore.pipeline.Expression substring(int start, int length); + method public static final com.google.firebase.firestore.pipeline.Expression substring(String fieldName, int index, int length); + method public final com.google.firebase.firestore.pipeline.Expression subtract(com.google.firebase.firestore.pipeline.Expression subtrahend); + method public static final com.google.firebase.firestore.pipeline.Expression subtract(com.google.firebase.firestore.pipeline.Expression minuend, com.google.firebase.firestore.pipeline.Expression subtrahend); + method public static final com.google.firebase.firestore.pipeline.Expression subtract(com.google.firebase.firestore.pipeline.Expression minuend, Number subtrahend); + method public final com.google.firebase.firestore.pipeline.Expression subtract(Number subtrahend); + method public static final com.google.firebase.firestore.pipeline.Expression subtract(String numericFieldName, com.google.firebase.firestore.pipeline.Expression subtrahend); + method public static final com.google.firebase.firestore.pipeline.Expression subtract(String numericFieldName, Number subtrahend); method public final com.google.firebase.firestore.pipeline.AggregateFunction sum(); - method public final com.google.firebase.firestore.pipeline.Expr timestampAdd(com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampAdd(com.google.firebase.firestore.pipeline.Expr timestamp, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampAdd(com.google.firebase.firestore.pipeline.Expr timestamp, String unit, long amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampAdd(String fieldName, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampAdd(String fieldName, String unit, long amount); - method public final com.google.firebase.firestore.pipeline.Expr timestampAdd(String unit, long amount); - method public final com.google.firebase.firestore.pipeline.Expr timestampSub(com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampSub(com.google.firebase.firestore.pipeline.Expr timestamp, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampSub(com.google.firebase.firestore.pipeline.Expr timestamp, String unit, long amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampSub(String fieldName, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public static final com.google.firebase.firestore.pipeline.Expr timestampSub(String fieldName, String unit, long amount); - method public final com.google.firebase.firestore.pipeline.Expr timestampSub(String unit, long amount); - method public final com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(); - method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(); - method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(); - method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr toLower(); - method public static final com.google.firebase.firestore.pipeline.Expr toLower(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public static final com.google.firebase.firestore.pipeline.Expr toLower(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr toUpper(); - method public static final com.google.firebase.firestore.pipeline.Expr toUpper(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public static final com.google.firebase.firestore.pipeline.Expr toUpper(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr trim(); - method public static final com.google.firebase.firestore.pipeline.Expr trim(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public static final com.google.firebase.firestore.pipeline.Expr trim(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(); - method public static final com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(); - method public static final com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(String fieldName); - method public final com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(); - method public static final com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(com.google.firebase.firestore.pipeline.Expr expr); - method public static final com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(String fieldName); - method public static final com.google.firebase.firestore.pipeline.Expr vector(com.google.firebase.firestore.VectorValue vector); - method public static final com.google.firebase.firestore.pipeline.Expr vector(double[] vector); - method public final com.google.firebase.firestore.pipeline.Expr vectorLength(); - method public static final com.google.firebase.firestore.pipeline.Expr vectorLength(com.google.firebase.firestore.pipeline.Expr vectorExpression); - method public static final com.google.firebase.firestore.pipeline.Expr vectorLength(String fieldName); - method public static final com.google.firebase.firestore.pipeline.BooleanExpr xor(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.BooleanExpr... conditions); - field public static final com.google.firebase.firestore.pipeline.Expr.Companion Companion; - } - - public static final class Expr.Companion { - method public com.google.firebase.firestore.pipeline.Expr abs(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr abs(String numericField); - method public com.google.firebase.firestore.pipeline.Expr add(com.google.firebase.firestore.pipeline.Expr first, com.google.firebase.firestore.pipeline.Expr second); - method public com.google.firebase.firestore.pipeline.Expr add(com.google.firebase.firestore.pipeline.Expr first, Number second); - method public com.google.firebase.firestore.pipeline.Expr add(String numericFieldName, com.google.firebase.firestore.pipeline.Expr second); - method public com.google.firebase.firestore.pipeline.Expr add(String numericFieldName, Number second); - method public com.google.firebase.firestore.pipeline.BooleanExpr and(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.BooleanExpr... conditions); - method public com.google.firebase.firestore.pipeline.Expr array(java.lang.Object?... elements); - method public com.google.firebase.firestore.pipeline.Expr array(java.util.List elements); - method public com.google.firebase.firestore.pipeline.Expr arrayConcat(com.google.firebase.firestore.pipeline.Expr firstArray, com.google.firebase.firestore.pipeline.Expr secondArray, java.lang.Object... otherArrays); - method public com.google.firebase.firestore.pipeline.Expr arrayConcat(com.google.firebase.firestore.pipeline.Expr firstArray, Object secondArray, java.lang.Object... otherArrays); - method public com.google.firebase.firestore.pipeline.Expr arrayConcat(String firstArrayField, com.google.firebase.firestore.pipeline.Expr secondArray, java.lang.Object... otherArrays); - method public com.google.firebase.firestore.pipeline.Expr arrayConcat(String firstArrayField, Object secondArray, java.lang.Object... otherArrays); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr element); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(com.google.firebase.firestore.pipeline.Expr array, Object element); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr element); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContains(String arrayFieldName, Object element); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(com.google.firebase.firestore.pipeline.Expr array, java.util.List values); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAll(String arrayFieldName, java.util.List values); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(com.google.firebase.firestore.pipeline.Expr array, java.util.List values); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr arrayContainsAny(String arrayFieldName, java.util.List values); - method public com.google.firebase.firestore.pipeline.Expr arrayLength(com.google.firebase.firestore.pipeline.Expr array); - method public com.google.firebase.firestore.pipeline.Expr arrayLength(String arrayFieldName); - method public com.google.firebase.firestore.pipeline.Expr arrayOffset(com.google.firebase.firestore.pipeline.Expr array, com.google.firebase.firestore.pipeline.Expr offset); - method public com.google.firebase.firestore.pipeline.Expr arrayOffset(com.google.firebase.firestore.pipeline.Expr array, int offset); - method public com.google.firebase.firestore.pipeline.Expr arrayOffset(String arrayFieldName, com.google.firebase.firestore.pipeline.Expr offset); - method public com.google.firebase.firestore.pipeline.Expr arrayOffset(String arrayFieldName, int offset); - method public com.google.firebase.firestore.pipeline.Expr arrayReverse(com.google.firebase.firestore.pipeline.Expr array); - method public com.google.firebase.firestore.pipeline.Expr arrayReverse(String arrayFieldName); - method public com.google.firebase.firestore.pipeline.Expr bitAnd(com.google.firebase.firestore.pipeline.Expr bits, byte[] bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitAnd(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitAnd(String bitsFieldName, byte[] bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitAnd(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitLeftShift(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public com.google.firebase.firestore.pipeline.Expr bitLeftShift(com.google.firebase.firestore.pipeline.Expr bits, int number); - method public com.google.firebase.firestore.pipeline.Expr bitLeftShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public com.google.firebase.firestore.pipeline.Expr bitLeftShift(String bitsFieldName, int number); - method public com.google.firebase.firestore.pipeline.Expr bitNot(com.google.firebase.firestore.pipeline.Expr bits); - method public com.google.firebase.firestore.pipeline.Expr bitNot(String bitsFieldName); - method public com.google.firebase.firestore.pipeline.Expr bitOr(com.google.firebase.firestore.pipeline.Expr bits, byte[] bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitOr(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitOr(String bitsFieldName, byte[] bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitOr(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitRightShift(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public com.google.firebase.firestore.pipeline.Expr bitRightShift(com.google.firebase.firestore.pipeline.Expr bits, int number); - method public com.google.firebase.firestore.pipeline.Expr bitRightShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr numberExpr); - method public com.google.firebase.firestore.pipeline.Expr bitRightShift(String bitsFieldName, int number); - method public com.google.firebase.firestore.pipeline.Expr bitXor(com.google.firebase.firestore.pipeline.Expr bits, byte[] bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitXor(com.google.firebase.firestore.pipeline.Expr bits, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitXor(String bitsFieldName, byte[] bitsOther); - method public com.google.firebase.firestore.pipeline.Expr bitXor(String bitsFieldName, com.google.firebase.firestore.pipeline.Expr bitsOther); - method public com.google.firebase.firestore.pipeline.Expr blob(byte[] bytes); - method public com.google.firebase.firestore.pipeline.Expr byteLength(com.google.firebase.firestore.pipeline.Expr value); - method public com.google.firebase.firestore.pipeline.Expr byteLength(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr ceil(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr ceil(String numericField); - method public com.google.firebase.firestore.pipeline.Expr charLength(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.Expr charLength(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr cond(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.Expr thenExpr, com.google.firebase.firestore.pipeline.Expr elseExpr); - method public com.google.firebase.firestore.pipeline.Expr cond(com.google.firebase.firestore.pipeline.BooleanExpr condition, Object thenValue, Object elseValue); - method public com.google.firebase.firestore.pipeline.BooleanExpr constant(boolean value); - method public com.google.firebase.firestore.pipeline.Expr constant(byte[] value); - method public com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.Blob value); - method public com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.DocumentReference ref); - method public com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.GeoPoint value); - method public com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.firestore.VectorValue value); - method public com.google.firebase.firestore.pipeline.Expr constant(com.google.firebase.Timestamp value); - method public com.google.firebase.firestore.pipeline.Expr constant(Number value); - method public com.google.firebase.firestore.pipeline.Expr constant(String value); - method public com.google.firebase.firestore.pipeline.Expr constant(java.util.Date value); - method public com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.pipeline.Expr vector2); - method public com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.VectorValue vector2); - method public com.google.firebase.firestore.pipeline.Expr cosineDistance(com.google.firebase.firestore.pipeline.Expr vector1, double[] vector2); - method public com.google.firebase.firestore.pipeline.Expr cosineDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expr vector); - method public com.google.firebase.firestore.pipeline.Expr cosineDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); - method public com.google.firebase.firestore.pipeline.Expr cosineDistance(String vectorFieldName, double[] vector); - method public com.google.firebase.firestore.pipeline.Expr divide(com.google.firebase.firestore.pipeline.Expr dividend, com.google.firebase.firestore.pipeline.Expr divisor); - method public com.google.firebase.firestore.pipeline.Expr divide(com.google.firebase.firestore.pipeline.Expr dividend, Number divisor); - method public com.google.firebase.firestore.pipeline.Expr divide(String dividendFieldName, com.google.firebase.firestore.pipeline.Expr divisor); - method public com.google.firebase.firestore.pipeline.Expr divide(String dividendFieldName, Number divisor); - method public com.google.firebase.firestore.pipeline.Expr documentId(com.google.firebase.firestore.DocumentReference docRef); - method public com.google.firebase.firestore.pipeline.Expr documentId(com.google.firebase.firestore.pipeline.Expr documentPath); - method public com.google.firebase.firestore.pipeline.Expr documentId(String documentPath); - method public com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.pipeline.Expr vector2); - method public com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.VectorValue vector2); - method public com.google.firebase.firestore.pipeline.Expr dotProduct(com.google.firebase.firestore.pipeline.Expr vector1, double[] vector2); - method public com.google.firebase.firestore.pipeline.Expr dotProduct(String vectorFieldName, com.google.firebase.firestore.pipeline.Expr vector); - method public com.google.firebase.firestore.pipeline.Expr dotProduct(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); - method public com.google.firebase.firestore.pipeline.Expr dotProduct(String vectorFieldName, double[] vector); - method public com.google.firebase.firestore.pipeline.BooleanExpr endsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, com.google.firebase.firestore.pipeline.Expr suffix); - method public com.google.firebase.firestore.pipeline.BooleanExpr endsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, String suffix); - method public com.google.firebase.firestore.pipeline.BooleanExpr endsWith(String fieldName, com.google.firebase.firestore.pipeline.Expr suffix); - method public com.google.firebase.firestore.pipeline.BooleanExpr endsWith(String fieldName, String suffix); - method public com.google.firebase.firestore.pipeline.BooleanExpr eq(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public com.google.firebase.firestore.pipeline.BooleanExpr eq(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public com.google.firebase.firestore.pipeline.BooleanExpr eq(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public com.google.firebase.firestore.pipeline.BooleanExpr eq(String fieldName, Object value); - method public com.google.firebase.firestore.pipeline.BooleanExpr eqAny(com.google.firebase.firestore.pipeline.Expr expression, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr eqAny(com.google.firebase.firestore.pipeline.Expr expression, java.util.List values); - method public com.google.firebase.firestore.pipeline.BooleanExpr eqAny(String fieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr eqAny(String fieldName, java.util.List values); - method public com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.pipeline.Expr vector2); - method public com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.pipeline.Expr vector1, com.google.firebase.firestore.VectorValue vector2); - method public com.google.firebase.firestore.pipeline.Expr euclideanDistance(com.google.firebase.firestore.pipeline.Expr vector1, double[] vector2); - method public com.google.firebase.firestore.pipeline.Expr euclideanDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expr vector); - method public com.google.firebase.firestore.pipeline.Expr euclideanDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); - method public com.google.firebase.firestore.pipeline.Expr euclideanDistance(String vectorFieldName, double[] vector); - method public com.google.firebase.firestore.pipeline.BooleanExpr exists(com.google.firebase.firestore.pipeline.Expr value); - method public com.google.firebase.firestore.pipeline.BooleanExpr exists(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr exp(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr exp(String numericField); + method public final com.google.firebase.firestore.pipeline.Expression timestampAdd(com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampAdd(com.google.firebase.firestore.pipeline.Expression timestamp, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampAdd(com.google.firebase.firestore.pipeline.Expression timestamp, String unit, long amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampAdd(String fieldName, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampAdd(String fieldName, String unit, long amount); + method public final com.google.firebase.firestore.pipeline.Expression timestampAdd(String unit, long amount); + method public final com.google.firebase.firestore.pipeline.Expression timestampSubtract(com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampSubtract(com.google.firebase.firestore.pipeline.Expression timestamp, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampSubtract(com.google.firebase.firestore.pipeline.Expression timestamp, String unit, long amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampSubtract(String fieldName, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public static final com.google.firebase.firestore.pipeline.Expression timestampSubtract(String fieldName, String unit, long amount); + method public final com.google.firebase.firestore.pipeline.Expression timestampSubtract(String unit, long amount); + method public final com.google.firebase.firestore.pipeline.Expression timestampToUnixMicros(); + method public static final com.google.firebase.firestore.pipeline.Expression timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.Expression timestampToUnixMicros(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression timestampToUnixMillis(); + method public static final com.google.firebase.firestore.pipeline.Expression timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.Expression timestampToUnixMillis(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression timestampToUnixSeconds(); + method public static final com.google.firebase.firestore.pipeline.Expression timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.Expression timestampToUnixSeconds(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression toLower(); + method public static final com.google.firebase.firestore.pipeline.Expression toLower(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public static final com.google.firebase.firestore.pipeline.Expression toLower(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression toUpper(); + method public static final com.google.firebase.firestore.pipeline.Expression toUpper(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public static final com.google.firebase.firestore.pipeline.Expression toUpper(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression trim(); + method public static final com.google.firebase.firestore.pipeline.Expression trim(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public static final com.google.firebase.firestore.pipeline.Expression trim(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression unixMicrosToTimestamp(); + method public static final com.google.firebase.firestore.pipeline.Expression unixMicrosToTimestamp(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.Expression unixMicrosToTimestamp(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression unixMillisToTimestamp(); + method public static final com.google.firebase.firestore.pipeline.Expression unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.Expression unixMillisToTimestamp(String fieldName); + method public final com.google.firebase.firestore.pipeline.Expression unixSecondsToTimestamp(); + method public static final com.google.firebase.firestore.pipeline.Expression unixSecondsToTimestamp(com.google.firebase.firestore.pipeline.Expression expr); + method public static final com.google.firebase.firestore.pipeline.Expression unixSecondsToTimestamp(String fieldName); + method public static final com.google.firebase.firestore.pipeline.Expression vector(com.google.firebase.firestore.VectorValue vector); + method public static final com.google.firebase.firestore.pipeline.Expression vector(double[] vector); + method public final com.google.firebase.firestore.pipeline.Expression vectorLength(); + method public static final com.google.firebase.firestore.pipeline.Expression vectorLength(com.google.firebase.firestore.pipeline.Expression vectorExpression); + method public static final com.google.firebase.firestore.pipeline.Expression vectorLength(String fieldName); + method public static final com.google.firebase.firestore.pipeline.BooleanExpression xor(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.BooleanExpression... conditions); + field public static final com.google.firebase.firestore.pipeline.Expression.Companion Companion; + } + + public static final class Expression.Companion { + method public com.google.firebase.firestore.pipeline.Expression abs(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression abs(String numericField); + method public com.google.firebase.firestore.pipeline.Expression add(com.google.firebase.firestore.pipeline.Expression first, com.google.firebase.firestore.pipeline.Expression second); + method public com.google.firebase.firestore.pipeline.Expression add(com.google.firebase.firestore.pipeline.Expression first, Number second); + method public com.google.firebase.firestore.pipeline.Expression add(String numericFieldName, com.google.firebase.firestore.pipeline.Expression second); + method public com.google.firebase.firestore.pipeline.Expression add(String numericFieldName, Number second); + method public com.google.firebase.firestore.pipeline.BooleanExpression and(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.BooleanExpression... conditions); + method public com.google.firebase.firestore.pipeline.Expression array(java.lang.Object?... elements); + method public com.google.firebase.firestore.pipeline.Expression array(java.util.List elements); + method public com.google.firebase.firestore.pipeline.Expression arrayConcat(com.google.firebase.firestore.pipeline.Expression firstArray, com.google.firebase.firestore.pipeline.Expression secondArray, java.lang.Object... otherArrays); + method public com.google.firebase.firestore.pipeline.Expression arrayConcat(com.google.firebase.firestore.pipeline.Expression firstArray, Object secondArray, java.lang.Object... otherArrays); + method public com.google.firebase.firestore.pipeline.Expression arrayConcat(String firstArrayField, com.google.firebase.firestore.pipeline.Expression secondArray, java.lang.Object... otherArrays); + method public com.google.firebase.firestore.pipeline.Expression arrayConcat(String firstArrayField, Object secondArray, java.lang.Object... otherArrays); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression element); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(com.google.firebase.firestore.pipeline.Expression array, Object element); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression element); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContains(String arrayFieldName, Object element); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(com.google.firebase.firestore.pipeline.Expression array, java.util.List values); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAll(String arrayFieldName, java.util.List values); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(com.google.firebase.firestore.pipeline.Expression array, java.util.List values); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression arrayContainsAny(String arrayFieldName, java.util.List values); + method public com.google.firebase.firestore.pipeline.Expression arrayGet(com.google.firebase.firestore.pipeline.Expression array, com.google.firebase.firestore.pipeline.Expression offset); + method public com.google.firebase.firestore.pipeline.Expression arrayGet(com.google.firebase.firestore.pipeline.Expression array, int offset); + method public com.google.firebase.firestore.pipeline.Expression arrayGet(String arrayFieldName, com.google.firebase.firestore.pipeline.Expression offset); + method public com.google.firebase.firestore.pipeline.Expression arrayGet(String arrayFieldName, int offset); + method public com.google.firebase.firestore.pipeline.Expression arrayLength(com.google.firebase.firestore.pipeline.Expression array); + method public com.google.firebase.firestore.pipeline.Expression arrayLength(String arrayFieldName); + method public com.google.firebase.firestore.pipeline.Expression arrayReverse(com.google.firebase.firestore.pipeline.Expression array); + method public com.google.firebase.firestore.pipeline.Expression arrayReverse(String arrayFieldName); + method public com.google.firebase.firestore.pipeline.Expression bitAnd(com.google.firebase.firestore.pipeline.Expression bits, byte[] bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitAnd(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitAnd(String bitsFieldName, byte[] bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitAnd(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitLeftShift(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public com.google.firebase.firestore.pipeline.Expression bitLeftShift(com.google.firebase.firestore.pipeline.Expression bits, int number); + method public com.google.firebase.firestore.pipeline.Expression bitLeftShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public com.google.firebase.firestore.pipeline.Expression bitLeftShift(String bitsFieldName, int number); + method public com.google.firebase.firestore.pipeline.Expression bitNot(com.google.firebase.firestore.pipeline.Expression bits); + method public com.google.firebase.firestore.pipeline.Expression bitNot(String bitsFieldName); + method public com.google.firebase.firestore.pipeline.Expression bitOr(com.google.firebase.firestore.pipeline.Expression bits, byte[] bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitOr(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitOr(String bitsFieldName, byte[] bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitOr(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitRightShift(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public com.google.firebase.firestore.pipeline.Expression bitRightShift(com.google.firebase.firestore.pipeline.Expression bits, int number); + method public com.google.firebase.firestore.pipeline.Expression bitRightShift(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression numberExpr); + method public com.google.firebase.firestore.pipeline.Expression bitRightShift(String bitsFieldName, int number); + method public com.google.firebase.firestore.pipeline.Expression bitXor(com.google.firebase.firestore.pipeline.Expression bits, byte[] bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitXor(com.google.firebase.firestore.pipeline.Expression bits, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitXor(String bitsFieldName, byte[] bitsOther); + method public com.google.firebase.firestore.pipeline.Expression bitXor(String bitsFieldName, com.google.firebase.firestore.pipeline.Expression bitsOther); + method public com.google.firebase.firestore.pipeline.Expression blob(byte[] bytes); + method public com.google.firebase.firestore.pipeline.Expression byteLength(com.google.firebase.firestore.pipeline.Expression value); + method public com.google.firebase.firestore.pipeline.Expression byteLength(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression ceil(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression ceil(String numericField); + method public com.google.firebase.firestore.pipeline.Expression charLength(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.Expression charLength(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression conditional(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.Expression thenExpr, com.google.firebase.firestore.pipeline.Expression elseExpr); + method public com.google.firebase.firestore.pipeline.Expression conditional(com.google.firebase.firestore.pipeline.BooleanExpression condition, Object thenValue, Object elseValue); + method public com.google.firebase.firestore.pipeline.BooleanExpression constant(boolean value); + method public com.google.firebase.firestore.pipeline.Expression constant(byte[] value); + method public com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.Blob value); + method public com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.DocumentReference ref); + method public com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.GeoPoint value); + method public com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.firestore.VectorValue value); + method public com.google.firebase.firestore.pipeline.Expression constant(com.google.firebase.Timestamp value); + method public com.google.firebase.firestore.pipeline.Expression constant(Number value); + method public com.google.firebase.firestore.pipeline.Expression constant(String value); + method public com.google.firebase.firestore.pipeline.Expression constant(java.util.Date value); + method public com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.pipeline.Expression vector2); + method public com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.VectorValue vector2); + method public com.google.firebase.firestore.pipeline.Expression cosineDistance(com.google.firebase.firestore.pipeline.Expression vector1, double[] vector2); + method public com.google.firebase.firestore.pipeline.Expression cosineDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expression vector); + method public com.google.firebase.firestore.pipeline.Expression cosineDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); + method public com.google.firebase.firestore.pipeline.Expression cosineDistance(String vectorFieldName, double[] vector); + method public com.google.firebase.firestore.pipeline.Expression divide(com.google.firebase.firestore.pipeline.Expression dividend, com.google.firebase.firestore.pipeline.Expression divisor); + method public com.google.firebase.firestore.pipeline.Expression divide(com.google.firebase.firestore.pipeline.Expression dividend, Number divisor); + method public com.google.firebase.firestore.pipeline.Expression divide(String dividendFieldName, com.google.firebase.firestore.pipeline.Expression divisor); + method public com.google.firebase.firestore.pipeline.Expression divide(String dividendFieldName, Number divisor); + method public com.google.firebase.firestore.pipeline.Expression documentId(com.google.firebase.firestore.DocumentReference docRef); + method public com.google.firebase.firestore.pipeline.Expression documentId(com.google.firebase.firestore.pipeline.Expression documentPath); + method public com.google.firebase.firestore.pipeline.Expression documentId(String documentPath); + method public com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.pipeline.Expression vector2); + method public com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.VectorValue vector2); + method public com.google.firebase.firestore.pipeline.Expression dotProduct(com.google.firebase.firestore.pipeline.Expression vector1, double[] vector2); + method public com.google.firebase.firestore.pipeline.Expression dotProduct(String vectorFieldName, com.google.firebase.firestore.pipeline.Expression vector); + method public com.google.firebase.firestore.pipeline.Expression dotProduct(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); + method public com.google.firebase.firestore.pipeline.Expression dotProduct(String vectorFieldName, double[] vector); + method public com.google.firebase.firestore.pipeline.BooleanExpression endsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, com.google.firebase.firestore.pipeline.Expression suffix); + method public com.google.firebase.firestore.pipeline.BooleanExpression endsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, String suffix); + method public com.google.firebase.firestore.pipeline.BooleanExpression endsWith(String fieldName, com.google.firebase.firestore.pipeline.Expression suffix); + method public com.google.firebase.firestore.pipeline.BooleanExpression endsWith(String fieldName, String suffix); + method public com.google.firebase.firestore.pipeline.BooleanExpression equal(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public com.google.firebase.firestore.pipeline.BooleanExpression equal(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public com.google.firebase.firestore.pipeline.BooleanExpression equal(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.BooleanExpression equal(String fieldName, Object value); + method public com.google.firebase.firestore.pipeline.BooleanExpression equalAny(com.google.firebase.firestore.pipeline.Expression expression, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression equalAny(com.google.firebase.firestore.pipeline.Expression expression, java.util.List values); + method public com.google.firebase.firestore.pipeline.BooleanExpression equalAny(String fieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression equalAny(String fieldName, java.util.List values); + method public com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.pipeline.Expression vector2); + method public com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.pipeline.Expression vector1, com.google.firebase.firestore.VectorValue vector2); + method public com.google.firebase.firestore.pipeline.Expression euclideanDistance(com.google.firebase.firestore.pipeline.Expression vector1, double[] vector2); + method public com.google.firebase.firestore.pipeline.Expression euclideanDistance(String vectorFieldName, com.google.firebase.firestore.pipeline.Expression vector); + method public com.google.firebase.firestore.pipeline.Expression euclideanDistance(String vectorFieldName, com.google.firebase.firestore.VectorValue vector); + method public com.google.firebase.firestore.pipeline.Expression euclideanDistance(String vectorFieldName, double[] vector); + method public com.google.firebase.firestore.pipeline.BooleanExpression exists(com.google.firebase.firestore.pipeline.Expression value); + method public com.google.firebase.firestore.pipeline.BooleanExpression exists(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression exp(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression exp(String numericField); method public com.google.firebase.firestore.pipeline.Field field(com.google.firebase.firestore.FieldPath fieldPath); method public com.google.firebase.firestore.pipeline.Field field(String name); - method public com.google.firebase.firestore.pipeline.Expr floor(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr floor(String numericField); - method public com.google.firebase.firestore.pipeline.Expr generic(String name, com.google.firebase.firestore.pipeline.Expr... expr); - method public com.google.firebase.firestore.pipeline.BooleanExpr gt(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public com.google.firebase.firestore.pipeline.BooleanExpr gt(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public com.google.firebase.firestore.pipeline.BooleanExpr gt(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public com.google.firebase.firestore.pipeline.BooleanExpr gt(String fieldName, Object value); - method public com.google.firebase.firestore.pipeline.BooleanExpr gte(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public com.google.firebase.firestore.pipeline.BooleanExpr gte(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public com.google.firebase.firestore.pipeline.BooleanExpr gte(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public com.google.firebase.firestore.pipeline.BooleanExpr gte(String fieldName, Object value); - method public com.google.firebase.firestore.pipeline.BooleanExpr ifError(com.google.firebase.firestore.pipeline.BooleanExpr tryExpr, com.google.firebase.firestore.pipeline.BooleanExpr catchExpr); - method public com.google.firebase.firestore.pipeline.Expr ifError(com.google.firebase.firestore.pipeline.Expr tryExpr, com.google.firebase.firestore.pipeline.Expr catchExpr); - method public com.google.firebase.firestore.pipeline.Expr ifError(com.google.firebase.firestore.pipeline.Expr tryExpr, Object catchValue); - method public com.google.firebase.firestore.pipeline.BooleanExpr isAbsent(com.google.firebase.firestore.pipeline.Expr value); - method public com.google.firebase.firestore.pipeline.BooleanExpr isAbsent(String fieldName); - method public com.google.firebase.firestore.pipeline.BooleanExpr isError(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNan(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNan(String fieldName); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNotNan(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNotNan(String fieldName); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNotNull(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNotNull(String fieldName); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNull(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.BooleanExpr isNull(String fieldName); - method public com.google.firebase.firestore.pipeline.BooleanExpr like(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr like(com.google.firebase.firestore.pipeline.Expr stringExpression, String pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr like(String fieldName, com.google.firebase.firestore.pipeline.Expr pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr like(String fieldName, String pattern); - method public com.google.firebase.firestore.pipeline.Expr ln(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr ln(String numericField); - method public com.google.firebase.firestore.pipeline.Expr log(com.google.firebase.firestore.pipeline.Expr numericExpr, com.google.firebase.firestore.pipeline.Expr base); - method public com.google.firebase.firestore.pipeline.Expr log(com.google.firebase.firestore.pipeline.Expr numericExpr, Number base); - method public com.google.firebase.firestore.pipeline.Expr log(String numericField, com.google.firebase.firestore.pipeline.Expr base); - method public com.google.firebase.firestore.pipeline.Expr log(String numericField, Number base); - method public com.google.firebase.firestore.pipeline.Expr log10(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr log10(String numericField); - method public com.google.firebase.firestore.pipeline.Expr logicalMaximum(com.google.firebase.firestore.pipeline.Expr expr, java.lang.Object... others); - method public com.google.firebase.firestore.pipeline.Expr logicalMaximum(String fieldName, java.lang.Object... others); - method public com.google.firebase.firestore.pipeline.Expr logicalMinimum(com.google.firebase.firestore.pipeline.Expr expr, java.lang.Object... others); - method public com.google.firebase.firestore.pipeline.Expr logicalMinimum(String fieldName, java.lang.Object... others); - method public com.google.firebase.firestore.pipeline.BooleanExpr lt(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public com.google.firebase.firestore.pipeline.BooleanExpr lt(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public com.google.firebase.firestore.pipeline.BooleanExpr lt(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public com.google.firebase.firestore.pipeline.BooleanExpr lt(String fieldName, Object value); - method public com.google.firebase.firestore.pipeline.BooleanExpr lte(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public com.google.firebase.firestore.pipeline.BooleanExpr lte(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public com.google.firebase.firestore.pipeline.BooleanExpr lte(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public com.google.firebase.firestore.pipeline.BooleanExpr lte(String fieldName, Object value); - method public com.google.firebase.firestore.pipeline.Expr map(java.util.Map elements); - method public com.google.firebase.firestore.pipeline.Expr mapGet(com.google.firebase.firestore.pipeline.Expr mapExpression, com.google.firebase.firestore.pipeline.Expr keyExpression); - method public com.google.firebase.firestore.pipeline.Expr mapGet(com.google.firebase.firestore.pipeline.Expr mapExpression, String key); - method public com.google.firebase.firestore.pipeline.Expr mapGet(String fieldName, com.google.firebase.firestore.pipeline.Expr keyExpression); - method public com.google.firebase.firestore.pipeline.Expr mapGet(String fieldName, String key); - method public com.google.firebase.firestore.pipeline.Expr mapMerge(com.google.firebase.firestore.pipeline.Expr firstMap, com.google.firebase.firestore.pipeline.Expr secondMap, com.google.firebase.firestore.pipeline.Expr... otherMaps); - method public com.google.firebase.firestore.pipeline.Expr mapMerge(String firstMapFieldName, com.google.firebase.firestore.pipeline.Expr secondMap, com.google.firebase.firestore.pipeline.Expr... otherMaps); - method public com.google.firebase.firestore.pipeline.Expr mapRemove(com.google.firebase.firestore.pipeline.Expr mapExpr, com.google.firebase.firestore.pipeline.Expr key); - method public com.google.firebase.firestore.pipeline.Expr mapRemove(com.google.firebase.firestore.pipeline.Expr mapExpr, String key); - method public com.google.firebase.firestore.pipeline.Expr mapRemove(String mapField, com.google.firebase.firestore.pipeline.Expr key); - method public com.google.firebase.firestore.pipeline.Expr mapRemove(String mapField, String key); - method public com.google.firebase.firestore.pipeline.Expr mod(com.google.firebase.firestore.pipeline.Expr dividend, com.google.firebase.firestore.pipeline.Expr divisor); - method public com.google.firebase.firestore.pipeline.Expr mod(com.google.firebase.firestore.pipeline.Expr dividend, Number divisor); - method public com.google.firebase.firestore.pipeline.Expr mod(String dividendFieldName, com.google.firebase.firestore.pipeline.Expr divisor); - method public com.google.firebase.firestore.pipeline.Expr mod(String dividendFieldName, Number divisor); - method public com.google.firebase.firestore.pipeline.Expr multiply(com.google.firebase.firestore.pipeline.Expr first, com.google.firebase.firestore.pipeline.Expr second); - method public com.google.firebase.firestore.pipeline.Expr multiply(com.google.firebase.firestore.pipeline.Expr first, Number second); - method public com.google.firebase.firestore.pipeline.Expr multiply(String numericFieldName, com.google.firebase.firestore.pipeline.Expr second); - method public com.google.firebase.firestore.pipeline.Expr multiply(String numericFieldName, Number second); - method public com.google.firebase.firestore.pipeline.BooleanExpr neq(com.google.firebase.firestore.pipeline.Expr left, com.google.firebase.firestore.pipeline.Expr right); - method public com.google.firebase.firestore.pipeline.BooleanExpr neq(com.google.firebase.firestore.pipeline.Expr left, Object right); - method public com.google.firebase.firestore.pipeline.BooleanExpr neq(String fieldName, com.google.firebase.firestore.pipeline.Expr expression); - method public com.google.firebase.firestore.pipeline.BooleanExpr neq(String fieldName, Object value); - method public com.google.firebase.firestore.pipeline.BooleanExpr not(com.google.firebase.firestore.pipeline.BooleanExpr condition); - method public com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(com.google.firebase.firestore.pipeline.Expr expression, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(com.google.firebase.firestore.pipeline.Expr expression, java.util.List values); - method public com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(String fieldName, com.google.firebase.firestore.pipeline.Expr arrayExpression); - method public com.google.firebase.firestore.pipeline.BooleanExpr notEqAny(String fieldName, java.util.List values); - method public com.google.firebase.firestore.pipeline.Expr nullValue(); - method public com.google.firebase.firestore.pipeline.BooleanExpr or(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.BooleanExpr... conditions); - method public com.google.firebase.firestore.pipeline.Expr pow(com.google.firebase.firestore.pipeline.Expr numericExpr, com.google.firebase.firestore.pipeline.Expr exponent); - method public com.google.firebase.firestore.pipeline.Expr pow(com.google.firebase.firestore.pipeline.Expr numericExpr, Number exponent); - method public com.google.firebase.firestore.pipeline.Expr pow(String numericField, com.google.firebase.firestore.pipeline.Expr exponent); - method public com.google.firebase.firestore.pipeline.Expr pow(String numericField, Number exponent); - method public com.google.firebase.firestore.pipeline.Expr rand(); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexContains(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexContains(com.google.firebase.firestore.pipeline.Expr stringExpression, String pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexContains(String fieldName, com.google.firebase.firestore.pipeline.Expr pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexContains(String fieldName, String pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(com.google.firebase.firestore.pipeline.Expr stringExpression, String pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(String fieldName, com.google.firebase.firestore.pipeline.Expr pattern); - method public com.google.firebase.firestore.pipeline.BooleanExpr regexMatch(String fieldName, String pattern); - method public com.google.firebase.firestore.pipeline.Expr replaceAll(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public com.google.firebase.firestore.pipeline.Expr replaceAll(com.google.firebase.firestore.pipeline.Expr stringExpression, String find, String replace); - method public com.google.firebase.firestore.pipeline.Expr replaceAll(String fieldName, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public com.google.firebase.firestore.pipeline.Expr replaceAll(String fieldName, String find, String replace); - method public com.google.firebase.firestore.pipeline.Expr replaceFirst(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public com.google.firebase.firestore.pipeline.Expr replaceFirst(com.google.firebase.firestore.pipeline.Expr stringExpression, String find, String replace); - method public com.google.firebase.firestore.pipeline.Expr replaceFirst(String fieldName, com.google.firebase.firestore.pipeline.Expr find, com.google.firebase.firestore.pipeline.Expr replace); - method public com.google.firebase.firestore.pipeline.Expr replaceFirst(String fieldName, String find, String replace); - method public com.google.firebase.firestore.pipeline.Expr reverse(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public com.google.firebase.firestore.pipeline.Expr reverse(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr round(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr round(String numericField); - method public com.google.firebase.firestore.pipeline.Expr roundToPrecision(com.google.firebase.firestore.pipeline.Expr numericExpr, com.google.firebase.firestore.pipeline.Expr decimalPlace); - method public com.google.firebase.firestore.pipeline.Expr roundToPrecision(com.google.firebase.firestore.pipeline.Expr numericExpr, int decimalPlace); - method public com.google.firebase.firestore.pipeline.Expr roundToPrecision(String numericField, com.google.firebase.firestore.pipeline.Expr decimalPlace); - method public com.google.firebase.firestore.pipeline.Expr roundToPrecision(String numericField, int decimalPlace); - method public com.google.firebase.firestore.pipeline.Expr sqrt(com.google.firebase.firestore.pipeline.Expr numericExpr); - method public com.google.firebase.firestore.pipeline.Expr sqrt(String numericField); - method public com.google.firebase.firestore.pipeline.BooleanExpr startsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, com.google.firebase.firestore.pipeline.Expr prefix); - method public com.google.firebase.firestore.pipeline.BooleanExpr startsWith(com.google.firebase.firestore.pipeline.Expr stringExpr, String prefix); - method public com.google.firebase.firestore.pipeline.BooleanExpr startsWith(String fieldName, com.google.firebase.firestore.pipeline.Expr prefix); - method public com.google.firebase.firestore.pipeline.BooleanExpr startsWith(String fieldName, String prefix); - method public com.google.firebase.firestore.pipeline.Expr strConcat(com.google.firebase.firestore.pipeline.Expr firstString, com.google.firebase.firestore.pipeline.Expr... otherStrings); - method public com.google.firebase.firestore.pipeline.Expr strConcat(com.google.firebase.firestore.pipeline.Expr firstString, java.lang.Object... otherStrings); - method public com.google.firebase.firestore.pipeline.Expr strConcat(String fieldName, com.google.firebase.firestore.pipeline.Expr... otherStrings); - method public com.google.firebase.firestore.pipeline.Expr strConcat(String fieldName, java.lang.Object... otherStrings); - method public com.google.firebase.firestore.pipeline.BooleanExpr strContains(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr substring); - method public com.google.firebase.firestore.pipeline.BooleanExpr strContains(com.google.firebase.firestore.pipeline.Expr stringExpression, String substring); - method public com.google.firebase.firestore.pipeline.BooleanExpr strContains(String fieldName, com.google.firebase.firestore.pipeline.Expr substring); - method public com.google.firebase.firestore.pipeline.BooleanExpr strContains(String fieldName, String substring); - method public com.google.firebase.firestore.pipeline.Expr substr(com.google.firebase.firestore.pipeline.Expr stringExpression, com.google.firebase.firestore.pipeline.Expr index, com.google.firebase.firestore.pipeline.Expr length); - method public com.google.firebase.firestore.pipeline.Expr substr(String fieldName, int index, int length); - method public com.google.firebase.firestore.pipeline.Expr subtract(com.google.firebase.firestore.pipeline.Expr minuend, com.google.firebase.firestore.pipeline.Expr subtrahend); - method public com.google.firebase.firestore.pipeline.Expr subtract(com.google.firebase.firestore.pipeline.Expr minuend, Number subtrahend); - method public com.google.firebase.firestore.pipeline.Expr subtract(String numericFieldName, com.google.firebase.firestore.pipeline.Expr subtrahend); - method public com.google.firebase.firestore.pipeline.Expr subtract(String numericFieldName, Number subtrahend); - method public com.google.firebase.firestore.pipeline.Expr timestampAdd(com.google.firebase.firestore.pipeline.Expr timestamp, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public com.google.firebase.firestore.pipeline.Expr timestampAdd(com.google.firebase.firestore.pipeline.Expr timestamp, String unit, long amount); - method public com.google.firebase.firestore.pipeline.Expr timestampAdd(String fieldName, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public com.google.firebase.firestore.pipeline.Expr timestampAdd(String fieldName, String unit, long amount); - method public com.google.firebase.firestore.pipeline.Expr timestampSub(com.google.firebase.firestore.pipeline.Expr timestamp, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public com.google.firebase.firestore.pipeline.Expr timestampSub(com.google.firebase.firestore.pipeline.Expr timestamp, String unit, long amount); - method public com.google.firebase.firestore.pipeline.Expr timestampSub(String fieldName, com.google.firebase.firestore.pipeline.Expr unit, com.google.firebase.firestore.pipeline.Expr amount); - method public com.google.firebase.firestore.pipeline.Expr timestampSub(String fieldName, String unit, long amount); - method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMicros(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.Expr timestampToUnixMillis(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.Expr timestampToUnixSeconds(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr toLower(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public com.google.firebase.firestore.pipeline.Expr toLower(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr toUpper(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public com.google.firebase.firestore.pipeline.Expr toUpper(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr trim(com.google.firebase.firestore.pipeline.Expr stringExpression); - method public com.google.firebase.firestore.pipeline.Expr trim(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.Expr unixMicrosToTimestamp(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.Expr unixMillisToTimestamp(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(com.google.firebase.firestore.pipeline.Expr expr); - method public com.google.firebase.firestore.pipeline.Expr unixSecondsToTimestamp(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr vector(com.google.firebase.firestore.VectorValue vector); - method public com.google.firebase.firestore.pipeline.Expr vector(double[] vector); - method public com.google.firebase.firestore.pipeline.Expr vectorLength(com.google.firebase.firestore.pipeline.Expr vectorExpression); - method public com.google.firebase.firestore.pipeline.Expr vectorLength(String fieldName); - method public com.google.firebase.firestore.pipeline.BooleanExpr xor(com.google.firebase.firestore.pipeline.BooleanExpr condition, com.google.firebase.firestore.pipeline.BooleanExpr... conditions); - } - - public final class ExprWithAlias extends com.google.firebase.firestore.pipeline.Selectable { - method public String canonicalId(); - method public String getAlias(); - method public com.google.firebase.firestore.pipeline.Expr getExpr(); - property public String alias; - property public com.google.firebase.firestore.pipeline.Expr expr; + method public com.google.firebase.firestore.pipeline.Expression floor(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression floor(String numericField); + method public com.google.firebase.firestore.pipeline.Expression generic(String name, com.google.firebase.firestore.pipeline.Expression... expr); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThan(String fieldName, Object value); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.BooleanExpression greaterThanOrEqual(String fieldName, Object value); + method public com.google.firebase.firestore.pipeline.BooleanExpression ifError(com.google.firebase.firestore.pipeline.BooleanExpression tryExpr, com.google.firebase.firestore.pipeline.BooleanExpression catchExpr); + method public com.google.firebase.firestore.pipeline.Expression ifError(com.google.firebase.firestore.pipeline.Expression tryExpr, com.google.firebase.firestore.pipeline.Expression catchExpr); + method public com.google.firebase.firestore.pipeline.Expression ifError(com.google.firebase.firestore.pipeline.Expression tryExpr, Object catchValue); + method public com.google.firebase.firestore.pipeline.BooleanExpression isAbsent(com.google.firebase.firestore.pipeline.Expression value); + method public com.google.firebase.firestore.pipeline.BooleanExpression isAbsent(String fieldName); + method public com.google.firebase.firestore.pipeline.BooleanExpression isError(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNan(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNan(String fieldName); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNotNan(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNotNan(String fieldName); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNotNull(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNotNull(String fieldName); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNull(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.BooleanExpression isNull(String fieldName); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThan(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThan(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThan(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThan(String fieldName, Object value); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.BooleanExpression lessThanOrEqual(String fieldName, Object value); + method public com.google.firebase.firestore.pipeline.BooleanExpression like(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression like(com.google.firebase.firestore.pipeline.Expression stringExpression, String pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression like(String fieldName, com.google.firebase.firestore.pipeline.Expression pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression like(String fieldName, String pattern); + method public com.google.firebase.firestore.pipeline.Expression ln(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression ln(String numericField); + method public com.google.firebase.firestore.pipeline.Expression log(com.google.firebase.firestore.pipeline.Expression numericExpr, com.google.firebase.firestore.pipeline.Expression base); + method public com.google.firebase.firestore.pipeline.Expression log(com.google.firebase.firestore.pipeline.Expression numericExpr, Number base); + method public com.google.firebase.firestore.pipeline.Expression log(String numericField, com.google.firebase.firestore.pipeline.Expression base); + method public com.google.firebase.firestore.pipeline.Expression log(String numericField, Number base); + method public com.google.firebase.firestore.pipeline.Expression log10(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression log10(String numericField); + method public com.google.firebase.firestore.pipeline.Expression logicalMaximum(com.google.firebase.firestore.pipeline.Expression expr, java.lang.Object... others); + method public com.google.firebase.firestore.pipeline.Expression logicalMaximum(String fieldName, java.lang.Object... others); + method public com.google.firebase.firestore.pipeline.Expression logicalMinimum(com.google.firebase.firestore.pipeline.Expression expr, java.lang.Object... others); + method public com.google.firebase.firestore.pipeline.Expression logicalMinimum(String fieldName, java.lang.Object... others); + method public com.google.firebase.firestore.pipeline.Expression map(java.util.Map elements); + method public com.google.firebase.firestore.pipeline.Expression mapGet(com.google.firebase.firestore.pipeline.Expression mapExpression, com.google.firebase.firestore.pipeline.Expression keyExpression); + method public com.google.firebase.firestore.pipeline.Expression mapGet(com.google.firebase.firestore.pipeline.Expression mapExpression, String key); + method public com.google.firebase.firestore.pipeline.Expression mapGet(String fieldName, com.google.firebase.firestore.pipeline.Expression keyExpression); + method public com.google.firebase.firestore.pipeline.Expression mapGet(String fieldName, String key); + method public com.google.firebase.firestore.pipeline.Expression mapMerge(com.google.firebase.firestore.pipeline.Expression firstMap, com.google.firebase.firestore.pipeline.Expression secondMap, com.google.firebase.firestore.pipeline.Expression... otherMaps); + method public com.google.firebase.firestore.pipeline.Expression mapMerge(String firstMapFieldName, com.google.firebase.firestore.pipeline.Expression secondMap, com.google.firebase.firestore.pipeline.Expression... otherMaps); + method public com.google.firebase.firestore.pipeline.Expression mapRemove(com.google.firebase.firestore.pipeline.Expression mapExpr, com.google.firebase.firestore.pipeline.Expression key); + method public com.google.firebase.firestore.pipeline.Expression mapRemove(com.google.firebase.firestore.pipeline.Expression mapExpr, String key); + method public com.google.firebase.firestore.pipeline.Expression mapRemove(String mapField, com.google.firebase.firestore.pipeline.Expression key); + method public com.google.firebase.firestore.pipeline.Expression mapRemove(String mapField, String key); + method public com.google.firebase.firestore.pipeline.Expression mod(com.google.firebase.firestore.pipeline.Expression dividend, com.google.firebase.firestore.pipeline.Expression divisor); + method public com.google.firebase.firestore.pipeline.Expression mod(com.google.firebase.firestore.pipeline.Expression dividend, Number divisor); + method public com.google.firebase.firestore.pipeline.Expression mod(String dividendFieldName, com.google.firebase.firestore.pipeline.Expression divisor); + method public com.google.firebase.firestore.pipeline.Expression mod(String dividendFieldName, Number divisor); + method public com.google.firebase.firestore.pipeline.Expression multiply(com.google.firebase.firestore.pipeline.Expression first, com.google.firebase.firestore.pipeline.Expression second); + method public com.google.firebase.firestore.pipeline.Expression multiply(com.google.firebase.firestore.pipeline.Expression first, Number second); + method public com.google.firebase.firestore.pipeline.Expression multiply(String numericFieldName, com.google.firebase.firestore.pipeline.Expression second); + method public com.google.firebase.firestore.pipeline.Expression multiply(String numericFieldName, Number second); + method public com.google.firebase.firestore.pipeline.BooleanExpression not(com.google.firebase.firestore.pipeline.BooleanExpression condition); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqual(com.google.firebase.firestore.pipeline.Expression left, com.google.firebase.firestore.pipeline.Expression right); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqual(com.google.firebase.firestore.pipeline.Expression left, Object right); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqual(String fieldName, com.google.firebase.firestore.pipeline.Expression expression); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqual(String fieldName, Object value); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(com.google.firebase.firestore.pipeline.Expression expression, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(com.google.firebase.firestore.pipeline.Expression expression, java.util.List values); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(String fieldName, com.google.firebase.firestore.pipeline.Expression arrayExpression); + method public com.google.firebase.firestore.pipeline.BooleanExpression notEqualAny(String fieldName, java.util.List values); + method public com.google.firebase.firestore.pipeline.Expression nullValue(); + method public com.google.firebase.firestore.pipeline.BooleanExpression or(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.BooleanExpression... conditions); + method public com.google.firebase.firestore.pipeline.Expression pow(com.google.firebase.firestore.pipeline.Expression numericExpr, com.google.firebase.firestore.pipeline.Expression exponent); + method public com.google.firebase.firestore.pipeline.Expression pow(com.google.firebase.firestore.pipeline.Expression numericExpr, Number exponent); + method public com.google.firebase.firestore.pipeline.Expression pow(String numericField, com.google.firebase.firestore.pipeline.Expression exponent); + method public com.google.firebase.firestore.pipeline.Expression pow(String numericField, Number exponent); + method public com.google.firebase.firestore.pipeline.Expression rand(); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexContains(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexContains(com.google.firebase.firestore.pipeline.Expression stringExpression, String pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexContains(String fieldName, com.google.firebase.firestore.pipeline.Expression pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexContains(String fieldName, String pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(com.google.firebase.firestore.pipeline.Expression stringExpression, String pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(String fieldName, com.google.firebase.firestore.pipeline.Expression pattern); + method public com.google.firebase.firestore.pipeline.BooleanExpression regexMatch(String fieldName, String pattern); + method public com.google.firebase.firestore.pipeline.Expression replaceAll(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public com.google.firebase.firestore.pipeline.Expression replaceAll(com.google.firebase.firestore.pipeline.Expression stringExpression, String find, String replace); + method public com.google.firebase.firestore.pipeline.Expression replaceAll(String fieldName, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public com.google.firebase.firestore.pipeline.Expression replaceAll(String fieldName, String find, String replace); + method public com.google.firebase.firestore.pipeline.Expression replaceFirst(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public com.google.firebase.firestore.pipeline.Expression replaceFirst(com.google.firebase.firestore.pipeline.Expression stringExpression, String find, String replace); + method public com.google.firebase.firestore.pipeline.Expression replaceFirst(String fieldName, com.google.firebase.firestore.pipeline.Expression find, com.google.firebase.firestore.pipeline.Expression replace); + method public com.google.firebase.firestore.pipeline.Expression replaceFirst(String fieldName, String find, String replace); + method public com.google.firebase.firestore.pipeline.Expression reverse(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public com.google.firebase.firestore.pipeline.Expression reverse(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression round(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression round(String numericField); + method public com.google.firebase.firestore.pipeline.Expression roundToPrecision(com.google.firebase.firestore.pipeline.Expression numericExpr, com.google.firebase.firestore.pipeline.Expression decimalPlace); + method public com.google.firebase.firestore.pipeline.Expression roundToPrecision(com.google.firebase.firestore.pipeline.Expression numericExpr, int decimalPlace); + method public com.google.firebase.firestore.pipeline.Expression roundToPrecision(String numericField, com.google.firebase.firestore.pipeline.Expression decimalPlace); + method public com.google.firebase.firestore.pipeline.Expression roundToPrecision(String numericField, int decimalPlace); + method public com.google.firebase.firestore.pipeline.Expression sqrt(com.google.firebase.firestore.pipeline.Expression numericExpr); + method public com.google.firebase.firestore.pipeline.Expression sqrt(String numericField); + method public com.google.firebase.firestore.pipeline.BooleanExpression startsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, com.google.firebase.firestore.pipeline.Expression prefix); + method public com.google.firebase.firestore.pipeline.BooleanExpression startsWith(com.google.firebase.firestore.pipeline.Expression stringExpr, String prefix); + method public com.google.firebase.firestore.pipeline.BooleanExpression startsWith(String fieldName, com.google.firebase.firestore.pipeline.Expression prefix); + method public com.google.firebase.firestore.pipeline.BooleanExpression startsWith(String fieldName, String prefix); + method public com.google.firebase.firestore.pipeline.Expression stringConcat(com.google.firebase.firestore.pipeline.Expression firstString, com.google.firebase.firestore.pipeline.Expression... otherStrings); + method public com.google.firebase.firestore.pipeline.Expression stringConcat(com.google.firebase.firestore.pipeline.Expression firstString, java.lang.Object... otherStrings); + method public com.google.firebase.firestore.pipeline.Expression stringConcat(String fieldName, com.google.firebase.firestore.pipeline.Expression... otherStrings); + method public com.google.firebase.firestore.pipeline.Expression stringConcat(String fieldName, java.lang.Object... otherStrings); + method public com.google.firebase.firestore.pipeline.BooleanExpression stringContains(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression substring); + method public com.google.firebase.firestore.pipeline.BooleanExpression stringContains(com.google.firebase.firestore.pipeline.Expression stringExpression, String substring); + method public com.google.firebase.firestore.pipeline.BooleanExpression stringContains(String fieldName, com.google.firebase.firestore.pipeline.Expression substring); + method public com.google.firebase.firestore.pipeline.BooleanExpression stringContains(String fieldName, String substring); + method public com.google.firebase.firestore.pipeline.Expression substring(com.google.firebase.firestore.pipeline.Expression stringExpression, com.google.firebase.firestore.pipeline.Expression index, com.google.firebase.firestore.pipeline.Expression length); + method public com.google.firebase.firestore.pipeline.Expression substring(String fieldName, int index, int length); + method public com.google.firebase.firestore.pipeline.Expression subtract(com.google.firebase.firestore.pipeline.Expression minuend, com.google.firebase.firestore.pipeline.Expression subtrahend); + method public com.google.firebase.firestore.pipeline.Expression subtract(com.google.firebase.firestore.pipeline.Expression minuend, Number subtrahend); + method public com.google.firebase.firestore.pipeline.Expression subtract(String numericFieldName, com.google.firebase.firestore.pipeline.Expression subtrahend); + method public com.google.firebase.firestore.pipeline.Expression subtract(String numericFieldName, Number subtrahend); + method public com.google.firebase.firestore.pipeline.Expression timestampAdd(com.google.firebase.firestore.pipeline.Expression timestamp, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public com.google.firebase.firestore.pipeline.Expression timestampAdd(com.google.firebase.firestore.pipeline.Expression timestamp, String unit, long amount); + method public com.google.firebase.firestore.pipeline.Expression timestampAdd(String fieldName, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public com.google.firebase.firestore.pipeline.Expression timestampAdd(String fieldName, String unit, long amount); + method public com.google.firebase.firestore.pipeline.Expression timestampSubtract(com.google.firebase.firestore.pipeline.Expression timestamp, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public com.google.firebase.firestore.pipeline.Expression timestampSubtract(com.google.firebase.firestore.pipeline.Expression timestamp, String unit, long amount); + method public com.google.firebase.firestore.pipeline.Expression timestampSubtract(String fieldName, com.google.firebase.firestore.pipeline.Expression unit, com.google.firebase.firestore.pipeline.Expression amount); + method public com.google.firebase.firestore.pipeline.Expression timestampSubtract(String fieldName, String unit, long amount); + method public com.google.firebase.firestore.pipeline.Expression timestampToUnixMicros(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.Expression timestampToUnixMicros(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression timestampToUnixMillis(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.Expression timestampToUnixMillis(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression timestampToUnixSeconds(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.Expression timestampToUnixSeconds(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression toLower(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public com.google.firebase.firestore.pipeline.Expression toLower(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression toUpper(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public com.google.firebase.firestore.pipeline.Expression toUpper(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression trim(com.google.firebase.firestore.pipeline.Expression stringExpression); + method public com.google.firebase.firestore.pipeline.Expression trim(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression unixMicrosToTimestamp(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.Expression unixMicrosToTimestamp(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression unixMillisToTimestamp(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.Expression unixMillisToTimestamp(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression unixSecondsToTimestamp(com.google.firebase.firestore.pipeline.Expression expr); + method public com.google.firebase.firestore.pipeline.Expression unixSecondsToTimestamp(String fieldName); + method public com.google.firebase.firestore.pipeline.Expression vector(com.google.firebase.firestore.VectorValue vector); + method public com.google.firebase.firestore.pipeline.Expression vector(double[] vector); + method public com.google.firebase.firestore.pipeline.Expression vectorLength(com.google.firebase.firestore.pipeline.Expression vectorExpression); + method public com.google.firebase.firestore.pipeline.Expression vectorLength(String fieldName); + method public com.google.firebase.firestore.pipeline.BooleanExpression xor(com.google.firebase.firestore.pipeline.BooleanExpression condition, com.google.firebase.firestore.pipeline.BooleanExpression... conditions); } public final class Field extends com.google.firebase.firestore.pipeline.Selectable { method public String canonicalId(); field public static final com.google.firebase.firestore.pipeline.Field.Companion Companion; - field public static final com.google.firebase.firestore.pipeline.Field DOCUMENT_ID; } public static final class Field.Companion { } + public final class FindNearestOptions extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public FindNearestOptions(); + method public com.google.firebase.firestore.pipeline.FindNearestOptions self(com.google.firebase.firestore.pipeline.InternalOptions options); + method public com.google.firebase.firestore.pipeline.FindNearestOptions withDistanceField(com.google.firebase.firestore.pipeline.Field distanceField); + method public com.google.firebase.firestore.pipeline.FindNearestOptions? withDistanceField(String? distanceField); + method public com.google.firebase.firestore.pipeline.FindNearestOptions withLimit(long limit); + } + public final class FindNearestStage extends com.google.firebase.firestore.pipeline.Stage { - method public static com.google.firebase.firestore.pipeline.FindNearestStage of(com.google.firebase.firestore.pipeline.Field vectorField, com.google.firebase.firestore.VectorValue vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public static com.google.firebase.firestore.pipeline.FindNearestStage of(com.google.firebase.firestore.pipeline.Field vectorField, double[] vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public static com.google.firebase.firestore.pipeline.FindNearestStage of(String vectorField, com.google.firebase.firestore.VectorValue vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public static com.google.firebase.firestore.pipeline.FindNearestStage of(String vectorField, double[] vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public com.google.firebase.firestore.pipeline.FindNearestStage withDistanceField(com.google.firebase.firestore.pipeline.Field distanceField); - method public com.google.firebase.firestore.pipeline.FindNearestStage withDistanceField(String distanceField); - method public com.google.firebase.firestore.pipeline.FindNearestStage withLimit(long limit); field public static final com.google.firebase.firestore.pipeline.FindNearestStage.Companion Companion; } public static final class FindNearestStage.Companion { - method public com.google.firebase.firestore.pipeline.FindNearestStage of(com.google.firebase.firestore.pipeline.Field vectorField, com.google.firebase.firestore.VectorValue vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public com.google.firebase.firestore.pipeline.FindNearestStage of(com.google.firebase.firestore.pipeline.Field vectorField, double[] vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public com.google.firebase.firestore.pipeline.FindNearestStage of(String vectorField, com.google.firebase.firestore.VectorValue vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); - method public com.google.firebase.firestore.pipeline.FindNearestStage of(String vectorField, double[] vectorValue, com.google.firebase.firestore.pipeline.FindNearestStage.DistanceMeasure distanceMeasure); } public static final class FindNearestStage.DistanceMeasure { @@ -1589,7 +1622,7 @@ package com.google.firebase.firestore.pipeline { public static final class FindNearestStage.DistanceMeasure.Companion { } - public class FunctionExpr extends com.google.firebase.firestore.pipeline.Expr { + public class FunctionExpression extends com.google.firebase.firestore.pipeline.Expression { method public String canonicalId(); } @@ -1603,31 +1636,27 @@ package com.google.firebase.firestore.pipeline { } public final class Ordering { - method public static com.google.firebase.firestore.pipeline.Ordering ascending(com.google.firebase.firestore.pipeline.Expr expr); + method public static com.google.firebase.firestore.pipeline.Ordering ascending(com.google.firebase.firestore.pipeline.Expression expr); method public static com.google.firebase.firestore.pipeline.Ordering ascending(String fieldName); method public String canonicalId(); - method public static com.google.firebase.firestore.pipeline.Ordering descending(com.google.firebase.firestore.pipeline.Expr expr); + method public static com.google.firebase.firestore.pipeline.Ordering descending(com.google.firebase.firestore.pipeline.Expression expr); method public static com.google.firebase.firestore.pipeline.Ordering descending(String fieldName); - method public com.google.firebase.firestore.pipeline.Expr getExpr(); + method public com.google.firebase.firestore.pipeline.Expression getExpr(); method public com.google.firebase.firestore.pipeline.Ordering reverse(); - property public final com.google.firebase.firestore.pipeline.Expr expr; + property public final com.google.firebase.firestore.pipeline.Expression expr; field public static final com.google.firebase.firestore.pipeline.Ordering.Companion Companion; } public static final class Ordering.Companion { - method public com.google.firebase.firestore.pipeline.Ordering ascending(com.google.firebase.firestore.pipeline.Expr expr); + method public com.google.firebase.firestore.pipeline.Ordering ascending(com.google.firebase.firestore.pipeline.Expression expr); method public com.google.firebase.firestore.pipeline.Ordering ascending(String fieldName); - method public com.google.firebase.firestore.pipeline.Ordering descending(com.google.firebase.firestore.pipeline.Expr expr); + method public com.google.firebase.firestore.pipeline.Ordering descending(com.google.firebase.firestore.pipeline.Expression expr); method public com.google.firebase.firestore.pipeline.Ordering descending(String fieldName); } public final class PipelineOptions extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public PipelineOptions(); method public com.google.firebase.firestore.pipeline.PipelineOptions withIndexMode(com.google.firebase.firestore.pipeline.PipelineOptions.IndexMode indexMode); - field public static final com.google.firebase.firestore.pipeline.PipelineOptions.Companion Companion; - field public static final com.google.firebase.firestore.pipeline.PipelineOptions DEFAULT; - } - - public static final class PipelineOptions.Companion { } public static final class PipelineOptions.IndexMode { @@ -1681,7 +1710,7 @@ package com.google.firebase.firestore.pipeline { property public final error.NonExistentClass PERCENT; } - public abstract class Selectable extends com.google.firebase.firestore.pipeline.Expr { + public abstract class Selectable extends com.google.firebase.firestore.pipeline.Expression { ctor public Selectable(); } @@ -1694,6 +1723,12 @@ package com.google.firebase.firestore.pipeline { method public final T withOption(String key, long value); } + public final class UnnestOptions extends com.google.firebase.firestore.pipeline.AbstractOptions { + ctor public UnnestOptions(); + method public com.google.firebase.firestore.pipeline.UnnestOptions self(com.google.firebase.firestore.pipeline.InternalOptions options); + method public com.google.firebase.firestore.pipeline.UnnestOptions withIndexField(String indexField); + } + public final class UnnestStage extends com.google.firebase.firestore.pipeline.Stage { method public static com.google.firebase.firestore.pipeline.UnnestStage withField(com.google.firebase.firestore.pipeline.Selectable arrayWithAlias); method public static com.google.firebase.firestore.pipeline.UnnestStage withField(String arrayField, String alias); diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/PipelineTest.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/PipelineTest.java index 0aa94dccae2..1ce2fceaf41 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/PipelineTest.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/PipelineTest.java @@ -15,32 +15,37 @@ package com.google.firebase.firestore; import static com.google.common.truth.Truth.assertThat; -import static com.google.firebase.firestore.pipeline.AggregateFunction.avg; -import static com.google.firebase.firestore.pipeline.Expr.add; -import static com.google.firebase.firestore.pipeline.Expr.and; -import static com.google.firebase.firestore.pipeline.Expr.array; -import static com.google.firebase.firestore.pipeline.Expr.arrayContains; -import static com.google.firebase.firestore.pipeline.Expr.arrayContainsAny; -import static com.google.firebase.firestore.pipeline.Expr.constant; -import static com.google.firebase.firestore.pipeline.Expr.cosineDistance; -import static com.google.firebase.firestore.pipeline.Expr.endsWith; -import static com.google.firebase.firestore.pipeline.Expr.eq; -import static com.google.firebase.firestore.pipeline.Expr.euclideanDistance; -import static com.google.firebase.firestore.pipeline.Expr.field; -import static com.google.firebase.firestore.pipeline.Expr.gt; -import static com.google.firebase.firestore.pipeline.Expr.logicalMaximum; -import static com.google.firebase.firestore.pipeline.Expr.logicalMinimum; -import static com.google.firebase.firestore.pipeline.Expr.lt; -import static com.google.firebase.firestore.pipeline.Expr.lte; -import static com.google.firebase.firestore.pipeline.Expr.map; -import static com.google.firebase.firestore.pipeline.Expr.mapGet; -import static com.google.firebase.firestore.pipeline.Expr.neq; -import static com.google.firebase.firestore.pipeline.Expr.not; -import static com.google.firebase.firestore.pipeline.Expr.or; -import static com.google.firebase.firestore.pipeline.Expr.startsWith; -import static com.google.firebase.firestore.pipeline.Expr.strConcat; -import static com.google.firebase.firestore.pipeline.Expr.subtract; -import static com.google.firebase.firestore.pipeline.Expr.vector; +import static com.google.firebase.firestore.pipeline.Expression.add; +import static com.google.firebase.firestore.pipeline.Expression.and; +import static com.google.firebase.firestore.pipeline.Expression.array; +import static com.google.firebase.firestore.pipeline.Expression.arrayContains; +import static com.google.firebase.firestore.pipeline.Expression.arrayContainsAny; +import static com.google.firebase.firestore.pipeline.Expression.collectionId; +import static com.google.firebase.firestore.pipeline.Expression.concat; +import static com.google.firebase.firestore.pipeline.Expression.constant; +import static com.google.firebase.firestore.pipeline.Expression.cosineDistance; +import static com.google.firebase.firestore.pipeline.Expression.currentTimestamp; +import static com.google.firebase.firestore.pipeline.Expression.documentId; +import static com.google.firebase.firestore.pipeline.Expression.endsWith; +import static com.google.firebase.firestore.pipeline.Expression.equal; +import static com.google.firebase.firestore.pipeline.Expression.error; +import static com.google.firebase.firestore.pipeline.Expression.euclideanDistance; +import static com.google.firebase.firestore.pipeline.Expression.field; +import static com.google.firebase.firestore.pipeline.Expression.greaterThan; +import static com.google.firebase.firestore.pipeline.Expression.join; +import static com.google.firebase.firestore.pipeline.Expression.length; +import static com.google.firebase.firestore.pipeline.Expression.lessThan; +import static com.google.firebase.firestore.pipeline.Expression.logicalMaximum; +import static com.google.firebase.firestore.pipeline.Expression.logicalMinimum; +import static com.google.firebase.firestore.pipeline.Expression.map; +import static com.google.firebase.firestore.pipeline.Expression.mapGet; +import static com.google.firebase.firestore.pipeline.Expression.not; +import static com.google.firebase.firestore.pipeline.Expression.notEqual; +import static com.google.firebase.firestore.pipeline.Expression.or; +import static com.google.firebase.firestore.pipeline.Expression.startsWith; +import static com.google.firebase.firestore.pipeline.Expression.stringConcat; +import static com.google.firebase.firestore.pipeline.Expression.subtract; +import static com.google.firebase.firestore.pipeline.Expression.vector; import static com.google.firebase.firestore.pipeline.Ordering.ascending; import static com.google.firebase.firestore.pipeline.Ordering.descending; import static com.google.firebase.firestore.testutil.IntegrationTestUtil.isRunningAgainstEmulator; @@ -61,16 +66,16 @@ import com.google.firebase.firestore.pipeline.AggregateStage; import com.google.firebase.firestore.pipeline.CollectionHints; import com.google.firebase.firestore.pipeline.CollectionSourceOptions; -import com.google.firebase.firestore.pipeline.Expr; +import com.google.firebase.firestore.pipeline.Expression; import com.google.firebase.firestore.pipeline.Field; import com.google.firebase.firestore.pipeline.FindNearestOptions; import com.google.firebase.firestore.pipeline.FindNearestStage; -import com.google.firebase.firestore.pipeline.PipelineOptions; import com.google.firebase.firestore.pipeline.RawStage; import com.google.firebase.firestore.pipeline.UnnestOptions; import com.google.firebase.firestore.testutil.IntegrationTestUtil; import java.util.Collections; import java.util.Date; +import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; @@ -172,6 +177,7 @@ public void tearDown() { entry("published", 1954), entry("rating", 4.7), entry("tags", ImmutableList.of("adventure", "magic", "epic")), + entry("sales", ImmutableList.of(100, 200, 50)), entry( "embedding", FieldValue.vector( @@ -277,20 +283,21 @@ public void setup() { @Test public void emptyResults() { - Task execute = + Task execute = firestore.pipeline().collection(randomCol.getPath()).limit(0).execute(); assertThat(waitFor(execute).getResults()).isEmpty(); } @Test public void fullResults() { - Task execute = firestore.pipeline().collection(randomCol.getPath()).execute(); + Task execute = + firestore.pipeline().collection(randomCol.getPath()).execute(); assertThat(waitFor(execute).getResults()).hasSize(11); } @Test public void aggregateResultsCountAll() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -304,14 +311,14 @@ public void aggregateResultsCountAll() { @Test @Ignore("Not supported yet") public void aggregateResultsMany() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("genre", "Science Fiction")) + .where(equal("genre", "Science Fiction")) .aggregate( AggregateFunction.countAll().alias("count"), - avg("rating").alias("avgRating"), + AggregateFunction.average("rating").alias("avgRating"), field("rating").maximum().alias("maxRating")) .execute(); assertThat(waitFor(execute).getResults()) @@ -322,15 +329,16 @@ public void aggregateResultsMany() { @Test public void groupAndAccumulateResults() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(lt(field("published"), 1984)) + .where(Expression.lessThan(field("published"), 1984)) .aggregate( - AggregateStage.withAccumulators(avg("rating").alias("avgRating")) + AggregateStage.withAccumulators( + AggregateFunction.average("rating").alias("avgRating")) .withGroups("genre")) - .where(gt("avgRating", 4.3)) + .where(greaterThan("avgRating", 4.3)) .sort(field("avgRating").descending()) .execute(); assertThat(waitFor(execute).getResults()) @@ -343,17 +351,19 @@ public void groupAndAccumulateResults() { @Test public void groupAndAccumulateResultsGeneric() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .rawStage(RawStage.ofName("where").withArguments(lt(field("published"), 1984))) + .rawStage( + RawStage.ofName("where") + .withArguments(Expression.lessThan(field("published"), 1984))) .rawStage( RawStage.ofName("aggregate") .withArguments( - ImmutableMap.of("avgRating", avg("rating")), + ImmutableMap.of("avgRating", AggregateFunction.average("rating")), ImmutableMap.of("genre", field("genre")))) - .rawStage(RawStage.ofName("where").withArguments(gt("avgRating", 4.3))) + .rawStage(RawStage.ofName("where").withArguments(greaterThan("avgRating", 4.3))) .rawStage(RawStage.ofName("sort").withArguments(field("avgRating").descending())) .execute(); assertThat(waitFor(execute).getResults()) @@ -366,7 +376,7 @@ public void groupAndAccumulateResultsGeneric() { @Test public void minAndMaxAccumulations() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -384,7 +394,7 @@ public void minAndMaxAccumulations() { @Test public void canSelectFields() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -417,11 +427,11 @@ public void canSelectFields() { @Test public void whereWithAnd() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(and(gt("rating", 4.5), eq("genre", "Science Fiction"))) + .where(and(greaterThan("rating", 4.5), equal("genre", "Science Fiction"))) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(ID_CORRESPONDENCE) @@ -430,11 +440,11 @@ public void whereWithAnd() { @Test public void whereWithOr() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(or(eq("genre", "Romance"), eq("genre", "Dystopian"))) + .where(or(equal("genre", "Romance"), equal("genre", "Dystopian"))) .select("title") .sort(field("title").ascending()) .execute(); @@ -448,7 +458,7 @@ public void whereWithOr() { @Test public void offsetAndLimits() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -468,7 +478,7 @@ public void offsetAndLimits() { @Test public void arrayContainsWorks() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -482,7 +492,7 @@ public void arrayContainsWorks() { @Test public void arrayContainsAnyWorks() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -499,7 +509,7 @@ public void arrayContainsAnyWorks() { @Test public void arrayContainsAllWorks() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -513,12 +523,12 @@ public void arrayContainsAllWorks() { @Test public void arrayLengthWorks() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .select(field("tags").arrayLength().alias("tagsCount")) - .where(eq("tagsCount", 3)) + .where(equal("tagsCount", 3)) .execute(); assertThat(waitFor(execute).getResults()).hasSize(10); } @@ -526,11 +536,11 @@ public void arrayLengthWorks() { @Test @Ignore("Not supported yet") public void arrayConcatWorks() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Hitchhiker's Guide to the Galaxy")) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) .select( field("tags") .arrayConcat(ImmutableList.of("newTag1", "newTag2")) @@ -545,14 +555,85 @@ public void arrayConcatWorks() { ImmutableList.of("comedy", "space", "adventure", "newTag1", "newTag2"))); } + @Test + public void arraySumWorks() { + Task execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Lord of the Rings")) + .select(Expression.arraySum("sales").alias("totalSales")) + .limit(1) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("totalSales", 350)); + } + + @Test + public void testConcat() { + // String concat + Task execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(concat(field("author"), " ", field("title")).alias("author_title")) + .execute(); + Map result = waitFor(execute).getResults().get(0).getData(); + assertThat(result.get("author_title")) + .isEqualTo("Douglas Adams The Hitchhiker's Guide to the Galaxy"); + + // Array concat + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(concat(field("tags"), ImmutableList.of("newTag")).alias("new_tags")) + .execute(); + result = waitFor(execute).getResults().get(0).getData(); + assertThat((List) result.get("new_tags")) + .containsExactly("comedy", "space", "adventure", "newTag") + .inOrder(); + + // Blob concat + byte[] bytes1 = new byte[] {1, 2}; + byte[] bytes2 = new byte[] {3, 4}; + byte[] expected = new byte[] {1, 2, 3, 4}; + execute = + firestore + .pipeline() + .collection(randomCol) + .limit(1) + .select( + concat(constant(Blob.fromBytes(bytes1)), Blob.fromBytes(bytes2)) + .alias("concatenated_blob")) + .execute(); + result = waitFor(execute).getResults().get(0).getData(); + assertThat(((Blob) result.get("concatenated_blob")).toBytes()).isEqualTo(expected); + + // Mismatched types should result in null. + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(concat(field("title"), field("tags")).alias("mismatched")) + .execute(); + result = waitFor(execute).getResults().get(0).getData(); + assertThat(result.get("mismatched")).isNull(); + } + @Test public void testStrConcat() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .sort(ascending(Field.DOCUMENT_ID)) - .select(strConcat(field("author"), constant(" - "), field("title")).alias("bookInfo")) + .select( + stringConcat(field("author"), constant(" - "), field("title")).alias("bookInfo")) .limit(1) .execute(); assertThat(waitFor(execute).getResults()) @@ -563,7 +644,7 @@ public void testStrConcat() { @Test public void testStartsWith() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -582,7 +663,7 @@ public void testStartsWith() { @Test public void testEndsWith() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -599,12 +680,12 @@ public void testEndsWith() { @Test public void testLength() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .select(field("title").charLength().alias("titleLength"), field("title")) - .where(gt("titleLength", 20)) + .where(greaterThan("titleLength", 20)) .sort(field("title").ascending()) .execute(); assertThat(waitFor(execute).getResults()) @@ -616,9 +697,100 @@ public void testLength() { ImmutableMap.of("titleLength", 21, "title", "To Kill a Mockingbird")); } + @Test + public void canComputeTheLengthOfStringValue() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .limit(1) + .select(field("title").length().alias("titleLength")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("titleLength", 36)); + } + + @Test + public void canComputeTheLengthOfStringValueWithTheTopLevelFunction() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .limit(1) + .select(length("title").alias("titleLength")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("titleLength", 36)); + } + + @Test + public void canComputeTheLengthOfArrayValue() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .limit(1) + .select(field("tags").length().alias("tagsLength")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("tagsLength", 3)); + } + + @Test + public void canComputeTheLengthOfArrayValueWithTheTopLevelFunction() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .limit(1) + .select(length("tags").alias("tagsLength")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("tagsLength", 3)); + } + + @Test + public void canComputeTheLengthOfMapValue() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .limit(1) + .select(field("awards").length().alias("awardsLength")) + .execute(); + // The "awards" map for this book is {"hugo": true, "nebula": false}, which has a length of 2. + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("awardsLength", 2)); + } + + @Test + public void canComputeTheLengthOfVectorValue() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .limit(1) + .select(field("embedding").length().alias("embeddingLength")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("embeddingLength", 10)); + } + @Test public void testToLowercase() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -633,7 +805,7 @@ public void testToLowercase() { @Test public void testToUppercase() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -649,11 +821,11 @@ public void testToUppercase() { @Test @Ignore("Not supported yet") public void testTrim() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .addFields(strConcat(" ", field("title"), " ").alias("spacedTitle")) + .addFields(Expression.stringConcat(" ", field("title"), " ").alias("spacedTitle")) .select(field("spacedTitle").trim().alias("trimmedTitle")) .limit(1) .execute(); @@ -671,11 +843,11 @@ public void testTrim() { public void testLike() { assumeFalse("Regexes are not supported against the emulator.", isRunningAgainstEmulator()); - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(Expr.like("title", "%Guide%")) + .where(Expression.like("title", "%Guide%")) .select("title") .execute(); assertThat(waitFor(execute).getResults()) @@ -683,15 +855,51 @@ public void testLike() { .containsExactly(ImmutableMap.of("title", "The Hitchhiker's Guide to the Galaxy")); } + @Test + public void testJoin() { + // Test join with a constant delimiter + Task execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(join("tags", ", ").alias("joined_tags")) + .execute(); + Map result = waitFor(execute).getResults().get(0).getData(); + assertThat(result.get("joined_tags")).isEqualTo("comedy, space, adventure"); + + // Test join with an expression delimiter + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(join(field("tags"), constant(" | ")).alias("joined_tags")) + .execute(); + result = waitFor(execute).getResults().get(0).getData(); + assertThat(result.get("joined_tags")).isEqualTo("comedy | space | adventure"); + + // Test extension method + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(field("tags").join(" - ").alias("joined_tags")) + .execute(); + result = waitFor(execute).getResults().get(0).getData(); + assertThat(result.get("joined_tags")).isEqualTo("comedy - space - adventure"); + } + @Test public void testRegexContains() { assumeFalse("Regexes are not supported against the emulator.", isRunningAgainstEmulator()); - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(Expr.regexContains("title", "(?i)(the|of)")) + .where(Expression.regexContains("title", "(?i)(the|of)")) .execute(); assertThat(waitFor(execute).getResults()).hasSize(5); } @@ -700,18 +908,18 @@ public void testRegexContains() { public void testRegexMatches() { assumeFalse("Regexes are not supported against the emulator.", isRunningAgainstEmulator()); - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(Expr.regexContains("title", ".*(?i)(the|of).*")) + .where(Expression.regexContains("title", ".*(?i)(the|of).*")) .execute(); assertThat(waitFor(execute).getResults()).hasSize(5); } @Test public void testArithmeticOperations() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -735,12 +943,15 @@ public void testArithmeticOperations() { @Test public void testComparisonOperators() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .where( - and(gt("rating", 4.2), lte(field("rating"), 4.5), neq("genre", "Science Function"))) + and( + greaterThan("rating", 4.2), + Expression.lessThanOrEqual(field("rating"), 4.5), + notEqual("genre", "Science Function"))) .select("rating", "title") .sort(field("title").ascending()) .execute(); @@ -754,14 +965,14 @@ public void testComparisonOperators() { @Test public void testLogicalOperators() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .where( or( - and(gt("rating", 4.5), eq("genre", "Science Fiction")), - lt(field("published"), 1900))) + and(greaterThan("rating", 4.5), equal("genre", "Science Fiction")), + Expression.lessThan(field("published"), 1900))) .select("title") .sort(field("title").ascending()) .execute(); @@ -775,14 +986,14 @@ public void testLogicalOperators() { @Test public void testChecks() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .where(not(field("rating").isNan())) .select( field("rating").isNull().alias("ratingIsNull"), - field("rating").eq(Expr.nullValue()).alias("ratingEqNull"), + field("rating").equal(Expression.nullValue()).alias("ratingEqNull"), not(field("rating").isNan()).alias("ratingIsNotNan")) .limit(1) .execute(); @@ -797,11 +1008,11 @@ public void testChecks() { @Test public void testLogicalMax() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(field("author").eq("Douglas Adams")) + .where(field("author").equal("Douglas Adams")) .select( field("rating").logicalMaximum(4.5).alias("max_rating"), logicalMaximum(field("published"), 1900).alias("max_published")) @@ -813,11 +1024,11 @@ public void testLogicalMax() { @Test public void testLogicalMin() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(field("author").eq("Douglas Adams")) + .where(field("author").equal("Douglas Adams")) .select( field("rating").logicalMinimum(4.5).alias("min_rating"), logicalMinimum(field("published"), 1900).alias("min_published")) @@ -830,13 +1041,13 @@ public void testLogicalMin() { @Test public void testMapGet() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .sort(field("title").descending()) .select(field("awards").mapGet("hugo").alias("hugoAward"), field("title")) - .where(eq("hugoAward", true)) + .where(equal("hugoAward", true)) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(DATA_CORRESPONDENCE) @@ -849,13 +1060,14 @@ public void testMapGet() { public void testDistanceFunctions() { double[] sourceVector = {0.1, 0.1}; double[] targetVector = {0.5, 0.8}; - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .select( cosineDistance(vector(sourceVector), targetVector).alias("cosineDistance"), - Expr.dotProduct(vector(sourceVector), targetVector).alias("dotProductDistance"), + Expression.dotProduct(vector(sourceVector), targetVector) + .alias("dotProductDistance"), euclideanDistance(vector(sourceVector), targetVector).alias("euclideanDistance")) .limit(1) .execute(); @@ -870,11 +1082,11 @@ public void testDistanceFunctions() { @Test public void testNestedFields() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("awards.hugo", true)) + .where(equal("awards.hugo", true)) .select("title", "awards.hugo") .sort(field("title").descending()) .execute(); @@ -887,11 +1099,11 @@ public void testNestedFields() { @Test public void testMapGetWithFieldNameIncludingNotation() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("awards.hugo", true)) + .where(equal("awards.hugo", true)) .sort(field("title").descending()) .select( "title", @@ -902,22 +1114,17 @@ public void testMapGetWithFieldNameIncludingNotation() { .comparingElementsUsing(DATA_CORRESPONDENCE) .containsExactly( mapOfEntries( - entry("title", "The Hitchhiker's Guide to the Galaxy"), - entry("nestedField.level.`1`", null), - entry("nested", true)), - mapOfEntries( - entry("title", "Dune"), - entry("nestedField.level.`1`", null), - entry("nested", null))); + entry("title", "The Hitchhiker's Guide to the Galaxy"), entry("nested", true)), + mapOfEntries(entry("title", "Dune"))); } @Test public void testListEquals() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("tags", ImmutableList.of("philosophy", "crime", "redemption"))) + .where(equal("tags", ImmutableList.of("philosophy", "crime", "redemption"))) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(ID_CORRESPONDENCE) @@ -926,11 +1133,11 @@ public void testListEquals() { @Test public void testMapEquals() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("awards", ImmutableMap.of("nobel", true, "nebula", false))) + .where(equal("awards", ImmutableMap.of("nobel", true, "nebula", false))) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(ID_CORRESPONDENCE) @@ -966,7 +1173,7 @@ public void testAllDataTypes() { new Timestamp(refDate), refBytes); - Task execute = + Task execute = firestore .pipeline() .collection(randomCol.getPath()) @@ -975,7 +1182,7 @@ public void testAllDataTypes() { constant(1L).alias("number"), constant("a string").alias("string"), constant(true).alias("boolean"), - Expr.nullValue().alias("null"), + Expression.nullValue().alias("null"), constant(refTimestamp).alias("timestamp"), constant(refDate).alias("date"), constant(refGeoPoint).alias("geoPoint"), @@ -1004,7 +1211,7 @@ public void testAllDataTypes() { @Test public void testResultMetadata() { Pipeline pipeline = firestore.pipeline().collection(randomCol.getPath()); - PipelineSnapshot snapshot = waitFor(pipeline.execute()); + Pipeline.Snapshot snapshot = waitFor(pipeline.execute()); assertThat(snapshot.getExecutionTime()).isNotNull(); for (PipelineResult result : snapshot.getResults()) { @@ -1014,7 +1221,7 @@ public void testResultMetadata() { waitFor(randomCol.document("book1").update("rating", 5.0)); snapshot = - waitFor(pipeline.where(eq("title", "The Hitchhiker's Guide to the Galaxy")).execute()); + waitFor(pipeline.where(equal("title", "The Hitchhiker's Guide to the Galaxy")).execute()); for (PipelineResult result : snapshot.getResults()) { assertThat(result.getCreateTime().compareTo(result.getUpdateTime())).isLessThan(0); } @@ -1024,9 +1231,9 @@ public void testResultMetadata() { public void testResultIsEqual() { Pipeline pipeline = firestore.pipeline().collection(randomCol.getPath()).sort(field("title").ascending()); - PipelineSnapshot snapshot1 = waitFor(pipeline.limit(1).execute()); - PipelineSnapshot snapshot2 = waitFor(pipeline.limit(1).execute()); - PipelineSnapshot snapshot3 = waitFor(pipeline.offset(1).limit(1).execute()); + Pipeline.Snapshot snapshot1 = waitFor(pipeline.limit(1).execute()); + Pipeline.Snapshot snapshot2 = waitFor(pipeline.limit(1).execute()); + Pipeline.Snapshot snapshot3 = waitFor(pipeline.offset(1).limit(1).execute()); assertThat(snapshot1.getResults()).hasSize(1); assertThat(snapshot2.getResults()).hasSize(1); @@ -1042,7 +1249,7 @@ public void testAggregateResultMetadata() { .pipeline() .collection(randomCol) .aggregate(AggregateFunction.countAll().alias("count")); - PipelineSnapshot snapshot = waitFor(pipeline.execute()); + Pipeline.Snapshot snapshot = waitFor(pipeline.execute()); assertThat(snapshot.getResults()).hasSize(1); assertThat(snapshot.getExecutionTime()).isNotNull(); @@ -1058,16 +1265,16 @@ public void testAggregateResultMetadata() { @Test public void addAndRemoveFields() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(field("author").neq("Timestamp Author")) + .where(field("author").notEqual("Timestamp Author")) .addFields( - strConcat(field("author"), "_", field("title")).alias("author_title"), - strConcat(field("title"), "_", field("author")).alias("title_author")) + Expression.stringConcat(field("author"), "_", field("title")).alias("author_title"), + Expression.stringConcat(field("title"), "_", field("author")).alias("title_author")) .removeFields("title_author", "tags", "awards", "rating", "title", "embedding") - .removeFields("published", "genre", "nestedField") + .removeFields("published", "genre", "nestedField", "sales") .sort(field("author_title").ascending()) .execute(); @@ -1107,11 +1314,11 @@ public void addAndRemoveFields() { @Test public void testDistinct() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(lt("published", 1900)) + .where(lessThan("published", 1900)) .distinct(field("genre").toLower().alias("lower_genre")) .sort(field("lower_genre").descending()) .execute(); @@ -1124,11 +1331,11 @@ public void testDistinct() { @Test public void testReplaceWith() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Hitchhiker's Guide to the Galaxy")) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) .replaceWith("awards") .execute(); assertThat(waitFor(execute).getResults()) @@ -1139,11 +1346,14 @@ public void testReplaceWith() { firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Hitchhiker's Guide to the Galaxy")) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) .replaceWith( - Expr.map( + Expression.map( ImmutableMap.of( - "foo", "bar", "baz", Expr.map(ImmutableMap.of("title", field("title")))))) + "foo", + "bar", + "baz", + Expression.map(ImmutableMap.of("title", field("title")))))) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(DATA_CORRESPONDENCE) @@ -1155,13 +1365,14 @@ public void testReplaceWith() { @Test public void testSampleLimit() { - Task execute = firestore.pipeline().collection(randomCol).sample(3).execute(); + Task execute = + firestore.pipeline().collection(randomCol).sample(3).execute(); assertThat(waitFor(execute).getResults()).hasSize(3); } @Test public void testUnion() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -1172,11 +1383,11 @@ public void testUnion() { @Test public void testUnnest() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Hitchhiker's Guide to the Galaxy")) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) .unnest("tags", "tag") .execute(); assertThat(waitFor(execute).getResults()).hasSize(3); @@ -1195,7 +1406,7 @@ public void testPaginationWithStartAfter() { Pipeline pipeline = firestore.pipeline().collection(paginationCollection).sort(ascending("order")).limit(2); - PipelineSnapshot snapshot = waitFor(pipeline.execute()); + Pipeline.Snapshot snapshot = waitFor(pipeline.execute()); assertThat(snapshot.getResults()) .comparingElementsUsing(DATA_CORRESPONDENCE) .containsExactly(ImmutableMap.of("order", 1), ImmutableMap.of("order", 2)); @@ -1210,7 +1421,7 @@ public void testPaginationWithStartAfter() { @Test public void testFindNearest() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -1234,7 +1445,7 @@ public void testFindNearest() { @Test public void testMoreAggregates() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) @@ -1251,11 +1462,13 @@ public void testMoreAggregates() { @Test public void testCountIfAggregate() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .aggregate(AggregateFunction.countIf(gt(field("rating"), 4.3)).alias("count")) + .aggregate( + AggregateFunction.countIf(Expression.greaterThan(field("rating"), 4.3)) + .alias("count")) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(DATA_CORRESPONDENCE) @@ -1264,12 +1477,12 @@ public void testCountIfAggregate() { @Test public void testStringFunctions() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .select(field("title").strReverse().alias("reversed_title"), field("author")) - .where(field("author").eq("Douglas Adams")) + .select(field("title").stringReverse().alias("reversed_title"), field("author")) + .where(field("author").equal("Douglas Adams")) .execute(); assertThat(waitFor(execute).getResults().get(0).getData().get("reversed_title")) .isEqualTo("yxalaG eht ot ediuG s'rekihhctiH ehT"); @@ -1280,8 +1493,8 @@ public void testStringFunctions() { .collection(randomCol) .select( field("author"), - field("title").strConcat("_银河系漫", "游指南").byteLength().alias("title_byte_length")) - .where(field("author").eq("Douglas Adams")) + field("title").stringConcat("_银河系漫", "游指南").byteLength().alias("title_byte_length")) + .where(field("author").equal("Douglas Adams")) .execute(); assertThat(waitFor(execute).getResults().get(0).getData().get("title_byte_length")) .isEqualTo(58); @@ -1289,11 +1502,11 @@ public void testStringFunctions() { @Test public void testStrContains() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(Expr.strContains(field("title"), "'s")) + .where(Expression.stringContains(field("title"), "'s")) .select("title") .sort(field("title").ascending()) .execute(); @@ -1306,14 +1519,14 @@ public void testStrContains() { @Test public void testSubstring() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Lord of the Rings")) + .where(equal("title", "The Lord of the Rings")) .select( - Expr.substr(field("title"), constant(9), constant(2)).alias("of"), - Expr.substr("title", 16, 5).alias("Rings")) + Expression.substring(field("title"), constant(9), constant(2)).alias("of"), + Expression.substring("title", 16, 5).alias("Rings")) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(DATA_CORRESPONDENCE) @@ -1322,16 +1535,16 @@ public void testSubstring() { @Test public void testLogicalAndComparisonOperators() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .where( - Expr.xor( - eq("genre", "Romance"), - eq("genre", "Dystopian"), - eq("genre", "Fantasy"), - eq("published", 1949))) + Expression.xor( + equal("genre", "Romance"), + equal("genre", "Dystopian"), + equal("genre", "Fantasy"), + equal("published", 1949))) .select("title") .sort(field("title").ascending()) .execute(); @@ -1346,7 +1559,7 @@ public void testLogicalAndComparisonOperators() { firestore .pipeline() .collection(randomCol) - .where(Expr.eqAny("genre", ImmutableList.of("Romance", "Dystopian"))) + .where(Expression.equalAny("genre", ImmutableList.of("Romance", "Dystopian"))) .select("title") .sort(descending("title")) .execute(); @@ -1361,7 +1574,7 @@ public void testLogicalAndComparisonOperators() { firestore .pipeline() .collection(randomCol) - .where(Expr.notEqAny("genre", ImmutableList.of("Romance", "Dystopian"))) + .where(Expression.notEqualAny("genre", ImmutableList.of("Romance", "Dystopian"))) .select("genre") .distinct("genre") .sort(ascending("genre")) @@ -1379,13 +1592,15 @@ public void testLogicalAndComparisonOperators() { @Test public void testCondExpression() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(field("title").neq("Timestamp Book")) + .where(field("title").notEqual("Timestamp Book")) .select( - Expr.cond(gt(field("published"), 1980), "Modern", "Classic").alias("era"), + Expression.conditional( + Expression.greaterThan(field("published"), 1980), "Modern", "Classic") + .alias("era"), field("title"), field("published")) .sort(field("published").ascending()) @@ -1406,14 +1621,15 @@ public void testCondExpression() { @Test public void testDataManipulationExpressions() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("title", "Timestamp Book")) + .where(equal("title", "Timestamp Book")) .select( - Expr.timestampAdd(field("timestamp"), "day", 1).alias("timestamp_plus_day"), - Expr.timestampSub(field("timestamp"), "hour", 1).alias("timestamp_minus_hour")) + Expression.timestampAdd(field("timestamp"), "day", 1).alias("timestamp_plus_day"), + Expression.timestampSubtract(field("timestamp"), "hour", 1) + .alias("timestamp_minus_hour")) .execute(); List results = waitFor(execute).getResults(); assertThat(results).hasSize(1); @@ -1429,11 +1645,11 @@ public void testDataManipulationExpressions() { firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Hitchhiker's Guide to the Galaxy")) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) .select( - Expr.arrayGet("tags", 1).alias("second_tag"), + Expression.arrayGet("tags", 1).alias("second_tag"), field("awards") - .mapMerge(Expr.map(ImmutableMap.of("new_award", true))) + .mapMerge(Expression.map(ImmutableMap.of("new_award", true))) .alias("merged_awards")) .execute(); assertThat(waitFor(execute).getResults()) @@ -1449,10 +1665,10 @@ public void testDataManipulationExpressions() { firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Hitchhiker's Guide to the Galaxy")) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) .select( - Expr.arrayReverse("tags").alias("reversed_tags"), - Expr.mapRemove(field("awards"), "nebula").alias("removed_awards")) + Expression.arrayReverse("tags").alias("reversed_tags"), + Expression.mapRemove(field("awards"), "nebula").alias("removed_awards")) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(DATA_CORRESPONDENCE) @@ -1464,17 +1680,17 @@ public void testDataManipulationExpressions() { @Test public void testMathExpressions() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Hitchhiker's Guide to the Galaxy")) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) .select( - Expr.ceil(field("rating")).alias("ceil_rating"), - Expr.floor(field("rating")).alias("floor_rating"), - Expr.pow(field("rating"), 2).alias("pow_rating"), - Expr.round(field("rating")).alias("round_rating"), - Expr.sqrt(field("rating")).alias("sqrt_rating"), + Expression.ceil(field("rating")).alias("ceil_rating"), + Expression.floor(field("rating")).alias("floor_rating"), + Expression.pow(field("rating"), 2).alias("pow_rating"), + Expression.round(field("rating")).alias("round_rating"), + Expression.sqrt(field("rating")).alias("sqrt_rating"), field("published").mod(10).alias("mod_published")) .execute(); Map result = waitFor(execute).getResults().get(0).getData(); @@ -1488,35 +1704,39 @@ public void testMathExpressions() { @Test public void testAdvancedMathExpressions() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) - .where(eq("title", "The Lord of the Rings")) + .where(equal("title", "The Lord of the Rings")) .select( - Expr.exp(field("rating")).alias("exp_rating"), - Expr.ln(field("rating")).alias("ln_rating"), - Expr.log(field("rating"), 10).alias("log_rating")) + Expression.exp(field("rating")).alias("exp_rating"), + Expression.ln(field("rating")).alias("ln_rating"), + Expression.log(field("rating"), 10).alias("log_rating"), + field("rating").log10().alias("log10_rating")) .execute(); Map result = waitFor(execute).getResults().get(0).getData(); assertThat((Double) result.get("exp_rating")).isWithin(0.00001).of(109.94717); assertThat((Double) result.get("ln_rating")).isWithin(0.00001).of(1.54756); assertThat((Double) result.get("log_rating")).isWithin(0.00001).of(0.67209); + assertThat((Double) result.get("log10_rating")).isWithin(0.00001).of(0.67209); } @Test public void testTimestampConversions() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .limit(1) .select( - Expr.unixSecondsToTimestamp(constant(1741380235L)).alias("unixSecondsToTimestamp"), - Expr.unixMillisToTimestamp(constant(1741380235123L)).alias("unixMillisToTimestamp"), - Expr.timestampToUnixSeconds(constant(new Timestamp(1741380235L, 123456789))) + Expression.unixSecondsToTimestamp(constant(1741380235L)) + .alias("unixSecondsToTimestamp"), + Expression.unixMillisToTimestamp(constant(1741380235123L)) + .alias("unixMillisToTimestamp"), + Expression.timestampToUnixSeconds(constant(new Timestamp(1741380235L, 123456789))) .alias("timestampToUnixSeconds"), - Expr.timestampToUnixMillis(constant(new Timestamp(1741380235L, 123456789))) + Expression.timestampToUnixMillis(constant(new Timestamp(1741380235L, 123456789))) .alias("timestampToUnixMillis")) .execute(); Map result = waitFor(execute).getResults().get(0).getData(); @@ -1528,41 +1748,98 @@ public void testTimestampConversions() { } @Test - public void testRand() { - Task execute = + public void testCurrentTimestamp() { + Task execute = firestore .pipeline() - .collection(randomCol) - .limit(10) - .select(Expr.rand().alias("result")) + .collection(randomCol.getPath()) + .limit(1) + .select(currentTimestamp().alias("now")) .execute(); List results = waitFor(execute).getResults(); - assertThat(results).hasSize(10); - for (PipelineResult result : results) { - Double randVal = (Double) result.getData().get("result"); - assertThat(randVal).isAtLeast(0.0); - assertThat(randVal).isLessThan(1.0); - } + assertThat(results).hasSize(1); + Object nowValue = results.get(0).getData().get("now"); + assertThat(nowValue).isInstanceOf(Timestamp.class); + Timestamp nowTimestamp = (Timestamp) nowValue; + // Check that the timestamp is recent (e.g., within the last 5 seconds) + long diff = new Date().getTime() - nowTimestamp.toDate().getTime(); + assertThat(diff).isAtMost(5000L); } @Test public void testVectorLength() { - Task execute = + Task execute = firestore .pipeline() .collection(randomCol) .limit(1) .select( - Expr.vectorLength(Expr.vector(new double[] {1.0, 2.0, 3.0})).alias("vectorLength")) + Expression.vectorLength(Expression.vector(new double[] {1.0, 2.0, 3.0})) + .alias("vectorLength")) .execute(); assertThat(waitFor(execute).getResults()) .comparingElementsUsing(DATA_CORRESPONDENCE) .containsExactly(ImmutableMap.of("vectorLength", 3)); } + @Test + public void canGetTheCollectionIdFromAPath() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .limit(1) + .select(field("__name__").collectionId().alias("collectionId")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("collectionId", randomCol.getId())); + } + + @Test + public void canGetTheCollectionIdFromAPathWithTheTopLevelFunction() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .limit(1) + .select(collectionId("__name__").alias("collectionId")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("collectionId", randomCol.getId())); + } + + @Test + public void testSupportsDocumentId() { + Task execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .sort(field("rating").descending()) + .limit(1) + .select(documentId(field("__name__")).alias("docId")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("docId", "book4")); + + execute = + firestore + .pipeline() + .collection(randomCol.getPath()) + .sort(field("rating").descending()) + .limit(1) + .select(field("__name__").documentId().alias("docId")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("docId", "book4")); + } + @Test public void testDocumentsAsSource() { - Task execute = + Task execute = firestore .pipeline() .documents( @@ -1580,7 +1857,7 @@ public void testCollectionGroupAsSource() { randomCol.document("book1").collection(subcollectionId).add(ImmutableMap.of("order", 1))); waitFor( randomCol.document("book2").collection(subcollectionId).add(ImmutableMap.of("order", 2))); - Task execute = + Task execute = firestore .pipeline() .collectionGroup(subcollectionId) @@ -1606,6 +1883,104 @@ public void testErrorHandling() { }); } + @Test + public void testErrorExpression() { + Exception exception = + assertThrows( + Exception.class, + () -> { + waitFor( + firestore + .pipeline() + .collection(randomCol) + .select(error("test error").alias("error")) + .execute()); + }); + assertThat(exception.getMessage()).contains("test error"); + } + + @Test + public void testIfAbsent() { + // Case 1: Field is present, should return the field value. + Task execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select(field("rating").ifAbsent(0.0).alias("rating_or_default")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("rating_or_default", 4.2)); + + // Case 2: Field is absent, should return the default value. + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "The Hitchhiker's Guide to the Galaxy")) + .select( + Expression.ifAbsent(field("non_existent_field"), "default") + .alias("field_or_default")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("field_or_default", "default")); + + // Case 3: Field is present and null, should return null. + Map values = new HashMap<>(); + values.put("title", "Book With Null"); + values.put("optional_field", null); + waitFor(randomCol.document("bookWithNull").set(values)); + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "Book With Null")) + .select( + Expression.ifAbsent(field("optional_field"), "default").alias("field_or_default")) + .execute(); + assertThat(waitFor(execute).getResults().get(0).get("field_or_default")).isNull(); + waitFor(randomCol.document("bookWithNull").delete()); + + // Case 4: Test different overloads. + // ifAbsent(String, Any) + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "Dune")) + .select(Expression.ifAbsent("non_existent_field", "default_string").alias("res")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("res", "default_string")); + + // ifAbsent(String, Expression) + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "Dune")) + .select(Expression.ifAbsent("non_existent_field", field("author")).alias("res")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("res", "Frank Herbert")); + + // ifAbsent(Expression, Expression) + execute = + firestore + .pipeline() + .collection(randomCol) + .where(equal("title", "Dune")) + .select(Expression.ifAbsent(field("non_existent_field"), field("author")).alias("res")) + .execute(); + assertThat(waitFor(execute).getResults()) + .comparingElementsUsing(DATA_CORRESPONDENCE) + .containsExactly(ImmutableMap.of("res", "Frank Herbert")); + } + @Test public void testCrossDatabaseRejection() { FirebaseFirestore firestore2 = IntegrationTestUtil.testAlternateFirestore(); @@ -1624,8 +1999,8 @@ public void testOptions() { assumeFalse( "Certain options are not supported against the emulator yet.", isRunningAgainstEmulator()); - PipelineOptions opts = - new PipelineOptions().withIndexMode(PipelineOptions.IndexMode.RECOMMENDED); + Pipeline.ExecuteOptions opts = + new Pipeline.ExecuteOptions().withIndexMode(Pipeline.ExecuteOptions.IndexMode.RECOMMENDED); double[] vector = {1.0, 2.0, 3.0}; @@ -1643,7 +2018,8 @@ public void testOptions() { new FindNearestOptions().withLimit(10).withDistanceField("distance")) .unnest(field("awards").alias("award"), new UnnestOptions().withIndexField("fgoo")) .aggregate( - AggregateStage.withAccumulators(avg("rating").alias("avg_rating")) + AggregateStage.withAccumulators( + AggregateFunction.average("rating").alias("avg_rating")) .withGroups("genre"), new AggregateOptions() .withHints(new AggregateHints().withForceStreamableEnabled())); diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryToPipelineTest.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryToPipelineTest.java index df2ba833309..3ba10fc30d1 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryToPipelineTest.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/QueryToPipelineTest.java @@ -67,7 +67,7 @@ public void testLimitQueries() { Query query = collection.limit(2); FirebaseFirestore db = collection.firestore; - PipelineSnapshot set = waitFor(db.pipeline().createFrom(query).execute()); + Pipeline.Snapshot set = waitFor(db.pipeline().createFrom(query).execute()); List> data = pipelineSnapshotToValues(set); assertEquals(asList(map("k", "a"), map("k", "b")), data); } @@ -84,7 +84,7 @@ public void testLimitQueriesUsingDescendingSortOrder() { Query query = collection.limit(2).orderBy("sort", Direction.DESCENDING); FirebaseFirestore db = collection.firestore; - PipelineSnapshot set = waitFor(db.pipeline().createFrom(query).execute()); + Pipeline.Snapshot set = waitFor(db.pipeline().createFrom(query).execute()); List> data = pipelineSnapshotToValues(set); assertEquals(asList(map("k", "d", "sort", 2L), map("k", "c", "sort", 1L)), data); @@ -114,7 +114,7 @@ public void testLimitToLastQueriesWithCursors() { Query query = collection.limitToLast(3).orderBy("sort").endBefore(2); FirebaseFirestore db = collection.firestore; - PipelineSnapshot set = waitFor(db.pipeline().createFrom(query).execute()); + Pipeline.Snapshot set = waitFor(db.pipeline().createFrom(query).execute()); List> data = pipelineSnapshotToValues(set); assertEquals( asList(map("k", "a", "sort", 0L), map("k", "b", "sort", 1L), map("k", "c", "sort", 1L)), @@ -162,7 +162,7 @@ public void testKeyOrderIsDescendingForDescendingInequality() { Query query = collection.whereGreaterThan("foo", 21.0).orderBy("foo", Direction.DESCENDING); FirebaseFirestore db = collection.firestore; - PipelineSnapshot result = waitFor(db.pipeline().createFrom(query).execute()); + Pipeline.Snapshot result = waitFor(db.pipeline().createFrom(query).execute()); assertEquals(asList("g", "f", "c", "b", "a"), pipelineSnapshotToIds(result)); } @@ -175,7 +175,7 @@ public void testUnaryFilterQueries() { "b", map("null", null, "nan", 0), "c", map("null", false, "nan", Double.NaN))); FirebaseFirestore db = collection.firestore; - PipelineSnapshot results = + Pipeline.Snapshot results = waitFor( db.pipeline() .createFrom(collection.whereEqualTo("null", null).whereEqualTo("nan", Double.NaN)) @@ -195,7 +195,7 @@ public void testFilterOnInfinity() { "a", map("inf", Double.POSITIVE_INFINITY), "b", map("inf", Double.NEGATIVE_INFINITY))); FirebaseFirestore db = collection.firestore; - PipelineSnapshot results = + Pipeline.Snapshot results = waitFor( db.pipeline() .createFrom(collection.whereEqualTo("inf", Double.POSITIVE_INFINITY)) @@ -215,7 +215,7 @@ public void testCanExplicitlySortByDocumentId() { FirebaseFirestore db = collection.firestore; // Ideally this would be descending to validate it's different than // the default, but that requires an extra index - PipelineSnapshot docs = + Pipeline.Snapshot docs = waitFor(db.pipeline().createFrom(collection.orderBy(FieldPath.documentId())).execute()); assertEquals( asList(testDocs.get("a"), testDocs.get("b"), testDocs.get("c")), @@ -232,7 +232,7 @@ public void testCanQueryByDocumentId() { "bb", map("key", "bb")); CollectionReference collection = testCollectionWithDocs(testDocs); FirebaseFirestore db = collection.firestore; - PipelineSnapshot docs = + Pipeline.Snapshot docs = waitFor( db.pipeline() .createFrom(collection.whereEqualTo(FieldPath.documentId(), "ab")) @@ -260,7 +260,7 @@ public void testCanQueryByDocumentIdUsingRefs() { "bb", map("key", "bb")); CollectionReference collection = testCollectionWithDocs(testDocs); FirebaseFirestore db = collection.firestore; - PipelineSnapshot docs = + Pipeline.Snapshot docs = waitFor( db.pipeline() .createFrom( @@ -284,11 +284,11 @@ public void testCanQueryWithAndWithoutDocumentKey() { CollectionReference collection = testCollection(); FirebaseFirestore db = collection.firestore; collection.add(map()); - Task query1 = + Task query1 = db.pipeline() .createFrom(collection.orderBy(FieldPath.documentId(), Direction.ASCENDING)) .execute(); - Task query2 = db.pipeline().createFrom(collection).execute(); + Task query2 = db.pipeline().createFrom(collection).execute(); waitFor(query1); waitFor(query2); @@ -325,7 +325,7 @@ public void testQueriesCanUseNotEqualFilters() { expectedDocsMap.remove("i"); expectedDocsMap.remove("j"); - PipelineSnapshot snapshot = + Pipeline.Snapshot snapshot = waitFor(db.pipeline().createFrom(collection.whereNotEqualTo("zip", 98101L)).execute()); assertEquals(Lists.newArrayList(expectedDocsMap.values()), pipelineSnapshotToValues(snapshot)); @@ -372,7 +372,7 @@ public void testQueriesCanUseNotEqualFiltersWithDocIds() { "bb", docD); CollectionReference collection = testCollectionWithDocs(testDocs); FirebaseFirestore db = collection.firestore; - PipelineSnapshot docs = + Pipeline.Snapshot docs = waitFor( db.pipeline() .createFrom(collection.whereNotEqualTo(FieldPath.documentId(), "aa")) @@ -394,7 +394,7 @@ public void testQueriesCanUseArrayContainsFilters() { FirebaseFirestore db = collection.firestore; // Search for "array" to contain 42 - PipelineSnapshot snapshot = + Pipeline.Snapshot snapshot = waitFor(db.pipeline().createFrom(collection.whereArrayContains("array", 42L)).execute()); assertEquals(asList(docA, docB, docD), pipelineSnapshotToValues(snapshot)); @@ -426,7 +426,7 @@ public void testQueriesCanUseInFilters() { FirebaseFirestore db = collection.firestore; // Search for zips matching 98101, 98103, or [98101, 98102]. - PipelineSnapshot snapshot = + Pipeline.Snapshot snapshot = waitFor( db.pipeline() .createFrom( @@ -480,7 +480,7 @@ public void testQueriesCanUseInFiltersWithDocIds() { "bb", docD); CollectionReference collection = testCollectionWithDocs(testDocs); FirebaseFirestore db = collection.firestore; - PipelineSnapshot docs = + Pipeline.Snapshot docs = waitFor( db.pipeline() .createFrom(collection.whereIn(FieldPath.documentId(), asList("aa", "ab"))) @@ -518,7 +518,7 @@ public void testQueriesCanUseNotInFilters() { expectedDocsMap.remove("i"); expectedDocsMap.remove("j"); - PipelineSnapshot snapshot = + Pipeline.Snapshot snapshot = waitFor( db.pipeline() .createFrom( @@ -581,7 +581,7 @@ public void testQueriesCanUseNotInFiltersWithDocIds() { "bb", docD); CollectionReference collection = testCollectionWithDocs(testDocs); FirebaseFirestore db = collection.firestore; - PipelineSnapshot docs = + Pipeline.Snapshot docs = waitFor( db.pipeline() .createFrom(collection.whereNotIn(FieldPath.documentId(), asList("aa", "ab"))) @@ -611,7 +611,7 @@ public void testQueriesCanUseArrayContainsAnyFilters() { // Search for "array" to contain [42, 43]. Pipeline pipeline = db.pipeline().createFrom(collection.whereArrayContainsAny("array", asList(42L, 43L))); - PipelineSnapshot snapshot = waitFor(pipeline.execute()); + Pipeline.Snapshot snapshot = waitFor(pipeline.execute()); assertEquals(asList(docA, docB, docD, docE), pipelineSnapshotToValues(snapshot)); // With objects. @@ -673,7 +673,7 @@ public void testCollectionGroupQueries() { } waitFor(batch.commit()); - PipelineSnapshot snapshot = + Pipeline.Snapshot snapshot = waitFor(db.pipeline().createFrom(db.collectionGroup(collectionGroup)).execute()); assertEquals( asList("cg-doc1", "cg-doc2", "cg-doc3", "cg-doc4", "cg-doc5"), @@ -703,7 +703,7 @@ public void testCollectionGroupQueriesWithStartAtEndAtWithArbitraryDocumentIds() } waitFor(batch.commit()); - PipelineSnapshot snapshot = + Pipeline.Snapshot snapshot = waitFor( db.pipeline() .createFrom( @@ -749,7 +749,7 @@ public void testCollectionGroupQueriesWithWhereFiltersOnArbitraryDocumentIds() { } waitFor(batch.commit()); - PipelineSnapshot snapshot = + Pipeline.Snapshot snapshot = waitFor( db.pipeline() .createFrom( diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/RealtimePipelineTest.kt b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/RealtimePipelineTest.kt index 16f145e0497..62b6b5cc217 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/RealtimePipelineTest.kt +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/RealtimePipelineTest.kt @@ -17,58 +17,58 @@ package com.google.firebase.firestore import androidx.test.ext.junit.runners.AndroidJUnit4 import com.google.common.truth.Truth.assertThat import com.google.firebase.Timestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.abs -import com.google.firebase.firestore.pipeline.Expr.Companion.add -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContains -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAny -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayLength -import com.google.firebase.firestore.pipeline.Expr.Companion.byteLength -import com.google.firebase.firestore.pipeline.Expr.Companion.ceil -import com.google.firebase.firestore.pipeline.Expr.Companion.charLength -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.divide -import com.google.firebase.firestore.pipeline.Expr.Companion.endsWith -import com.google.firebase.firestore.pipeline.Expr.Companion.eqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.exists -import com.google.firebase.firestore.pipeline.Expr.Companion.exp -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.floor -import com.google.firebase.firestore.pipeline.Expr.Companion.isAbsent -import com.google.firebase.firestore.pipeline.Expr.Companion.isNan -import com.google.firebase.firestore.pipeline.Expr.Companion.isNotNan -import com.google.firebase.firestore.pipeline.Expr.Companion.isNotNull -import com.google.firebase.firestore.pipeline.Expr.Companion.isNull -import com.google.firebase.firestore.pipeline.Expr.Companion.like -import com.google.firebase.firestore.pipeline.Expr.Companion.ln -import com.google.firebase.firestore.pipeline.Expr.Companion.log -import com.google.firebase.firestore.pipeline.Expr.Companion.log10 -import com.google.firebase.firestore.pipeline.Expr.Companion.mod -import com.google.firebase.firestore.pipeline.Expr.Companion.multiply -import com.google.firebase.firestore.pipeline.Expr.Companion.not -import com.google.firebase.firestore.pipeline.Expr.Companion.notEqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.or -import com.google.firebase.firestore.pipeline.Expr.Companion.pow -import com.google.firebase.firestore.pipeline.Expr.Companion.regexContains -import com.google.firebase.firestore.pipeline.Expr.Companion.regexMatch -import com.google.firebase.firestore.pipeline.Expr.Companion.reverse -import com.google.firebase.firestore.pipeline.Expr.Companion.round -import com.google.firebase.firestore.pipeline.Expr.Companion.sqrt -import com.google.firebase.firestore.pipeline.Expr.Companion.startsWith -import com.google.firebase.firestore.pipeline.Expr.Companion.strConcat -import com.google.firebase.firestore.pipeline.Expr.Companion.strContains -import com.google.firebase.firestore.pipeline.Expr.Companion.subtract -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampAdd -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixMicros -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixMillis -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixSeconds -import com.google.firebase.firestore.pipeline.Expr.Companion.toLower -import com.google.firebase.firestore.pipeline.Expr.Companion.toUpper -import com.google.firebase.firestore.pipeline.Expr.Companion.trim -import com.google.firebase.firestore.pipeline.Expr.Companion.unixMicrosToTimestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.unixMillisToTimestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.unixSecondsToTimestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.xor +import com.google.firebase.firestore.pipeline.Expression.Companion.abs +import com.google.firebase.firestore.pipeline.Expression.Companion.add +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContains +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAny +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayLength +import com.google.firebase.firestore.pipeline.Expression.Companion.byteLength +import com.google.firebase.firestore.pipeline.Expression.Companion.ceil +import com.google.firebase.firestore.pipeline.Expression.Companion.charLength +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.divide +import com.google.firebase.firestore.pipeline.Expression.Companion.endsWith +import com.google.firebase.firestore.pipeline.Expression.Companion.equalAny +import com.google.firebase.firestore.pipeline.Expression.Companion.exists +import com.google.firebase.firestore.pipeline.Expression.Companion.exp +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.floor +import com.google.firebase.firestore.pipeline.Expression.Companion.isAbsent +import com.google.firebase.firestore.pipeline.Expression.Companion.isNan +import com.google.firebase.firestore.pipeline.Expression.Companion.isNotNan +import com.google.firebase.firestore.pipeline.Expression.Companion.isNotNull +import com.google.firebase.firestore.pipeline.Expression.Companion.isNull +import com.google.firebase.firestore.pipeline.Expression.Companion.like +import com.google.firebase.firestore.pipeline.Expression.Companion.ln +import com.google.firebase.firestore.pipeline.Expression.Companion.log +import com.google.firebase.firestore.pipeline.Expression.Companion.log10 +import com.google.firebase.firestore.pipeline.Expression.Companion.mod +import com.google.firebase.firestore.pipeline.Expression.Companion.multiply +import com.google.firebase.firestore.pipeline.Expression.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqualAny +import com.google.firebase.firestore.pipeline.Expression.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.pow +import com.google.firebase.firestore.pipeline.Expression.Companion.regexContains +import com.google.firebase.firestore.pipeline.Expression.Companion.regexMatch +import com.google.firebase.firestore.pipeline.Expression.Companion.reverse +import com.google.firebase.firestore.pipeline.Expression.Companion.round +import com.google.firebase.firestore.pipeline.Expression.Companion.sqrt +import com.google.firebase.firestore.pipeline.Expression.Companion.startsWith +import com.google.firebase.firestore.pipeline.Expression.Companion.stringConcat +import com.google.firebase.firestore.pipeline.Expression.Companion.stringContains +import com.google.firebase.firestore.pipeline.Expression.Companion.subtract +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampAdd +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixMicros +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixMillis +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixSeconds +import com.google.firebase.firestore.pipeline.Expression.Companion.toLower +import com.google.firebase.firestore.pipeline.Expression.Companion.toUpper +import com.google.firebase.firestore.pipeline.Expression.Companion.trim +import com.google.firebase.firestore.pipeline.Expression.Companion.unixMicrosToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.unixMillisToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.unixSecondsToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.xor import com.google.firebase.firestore.pipeline.Ordering.Companion.ascending import com.google.firebase.firestore.testutil.IntegrationTestUtil import com.google.firebase.firestore.testutil.IntegrationTestUtil.waitFor @@ -225,7 +225,8 @@ class RealtimePipelineTest { @Test fun testBasicAsyncStream() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(field("rating").gte(4.5)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(field("rating").greaterThanOrEqual(4.5)) val channel = Channel(Channel.UNLIMITED) val job = launch { pipeline.snapshots().collect { snapshot -> channel.send(snapshot) } } @@ -264,7 +265,8 @@ class RealtimePipelineTest { @Test fun testResultChanges() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(field("rating").gte(4.5)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(field("rating").greaterThanOrEqual(4.5)) val channel = Channel(Channel.UNLIMITED) val job = launch { pipeline.snapshots().collect { snapshot -> channel.send(snapshot) } } @@ -311,7 +313,8 @@ class RealtimePipelineTest { @Test fun testCanListenToCache() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(field("rating").gte(4.5)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(field("rating").greaterThanOrEqual(4.5)) val options = RealtimePipelineOptions() .withMetadataChanges(MetadataChanges.INCLUDE) @@ -337,7 +340,8 @@ class RealtimePipelineTest { @Test fun testCanListenToMetadataOnlyChanges() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(field("rating").gte(4.5)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(field("rating").greaterThanOrEqual(4.5)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -367,7 +371,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("title").eq("The Hitchhiker's Guide to the Galaxy")) + .where(field("title").equal("The Hitchhiker's Guide to the Galaxy")) val options = RealtimePipelineOptions() @@ -413,7 +417,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("rating").timestampAdd(constant("second"), constant(1)).gt(now)) + .where(field("rating").timestampAdd(constant("second"), constant(1)).greaterThan(now)) val options = RealtimePipelineOptions() @@ -442,7 +446,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("title").eq("The Hitchhiker's Guide to the Galaxy")) + .where(field("title").equal("The Hitchhiker's Guide to the Galaxy")) val options = RealtimePipelineOptions() @@ -486,7 +490,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("title").eq("The Hitchhiker's Guide to the Galaxy")) + .where(field("title").equal("The Hitchhiker's Guide to the Galaxy")) val options = RealtimePipelineOptions() @@ -513,7 +517,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("title").eq("The Hitchhiker's Guide to the Galaxy")) + .where(field("title").equal("The Hitchhiker's Guide to the Galaxy")) val channel = Channel(Channel.UNLIMITED) val job = launch { pipeline.snapshots().collect { snapshot -> channel.send(snapshot) } } @@ -625,8 +629,8 @@ class RealtimePipelineTest { .collection(collRef.path) .where( and( - field("genre").eq("Science Fiction"), - field("rating").gt(4.5), + field("genre").equal("Science Fiction"), + field("rating").greaterThan(4.5), ) ) .sort(ascending("title")) @@ -664,8 +668,8 @@ class RealtimePipelineTest { .collection(collRef.path) .where( or( - field("genre").eq("Dystopian"), - field("published").lt(1900), + field("genre").equal("Dystopian"), + field("published").lessThan(1900), ) ) .sort(ascending("published")) @@ -706,8 +710,8 @@ class RealtimePipelineTest { .collection(collRef.path) .where( xor( - field("rating").gt(4.5), - field("genre").eq("Science Fiction"), + field("rating").greaterThan(4.5), + field("genre").equal("Science Fiction"), ) ) .sort(ascending("rating")) @@ -747,7 +751,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(not(field("genre").eq("Science Fiction"))) + .where(not(field("genre").equal("Science Fiction"))) .sort(ascending("published")) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) @@ -781,7 +785,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(eqAny("genre", listOf("Dystopian", "Fantasy"))) + .where(equalAny("genre", listOf("Dystopian", "Fantasy"))) .sort(ascending("published")) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) @@ -819,7 +823,7 @@ class RealtimePipelineTest { .realtimePipeline() .collection(collRef.path) .where( - notEqAny( + notEqualAny( "genre", listOf( "Dystopian", @@ -981,7 +985,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("author").eq(strConcat(constant("Douglas"), constant(" Adams")))) + .where(field("author").equal(stringConcat(constant("Douglas"), constant(" Adams")))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1007,7 +1011,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("author").toLower().eq(toLower(constant("DOUGLAS ADAMS")))) + .where(field("author").toLower().equal(toLower(constant("DOUGLAS ADAMS")))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1033,7 +1037,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("author").toUpper().eq(toUpper(constant("dOUglAs adaMs")))) + .where(field("author").toUpper().equal(toUpper(constant("dOUglAs adaMs")))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1059,7 +1063,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("author").eq(trim(constant(" Douglas Adams ")))) + .where(field("author").equal(trim(constant(" Douglas Adams ")))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1081,7 +1085,8 @@ class RealtimePipelineTest { @Test fun testCharLength() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(charLength("author").gt(20)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(charLength("author").greaterThan(20)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1102,7 +1107,8 @@ class RealtimePipelineTest { @Test fun testByteLength() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(byteLength("author").gt(20)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(byteLength("author").greaterThan(20)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1127,7 +1133,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(field("author").eq(reverse(constant("smadA salguoD")))) + .where(field("author").equal(reverse(constant("smadA salguoD")))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1150,7 +1156,7 @@ class RealtimePipelineTest { @Test fun testStrContains() = runBlocking { val pipeline = - db.realtimePipeline().collection(collRef.path).where(strContains("author", "Adams")) + db.realtimePipeline().collection(collRef.path).where(stringContains("author", "Adams")) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1288,7 +1294,8 @@ class RealtimePipelineTest { @Test fun testAdd() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(add("rating", 0.8).eq(5.0)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(add("rating", 0.8).equal(5.0)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1313,7 +1320,7 @@ class RealtimePipelineTest { @Test fun testSubtract() = runBlocking { val pipeline = - db.realtimePipeline().collection(collRef.path).where(subtract("rating", 0.2).eq(4.0)) + db.realtimePipeline().collection(collRef.path).where(subtract("rating", 0.2).equal(4.0)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1338,7 +1345,7 @@ class RealtimePipelineTest { @Test fun testMultiply() = runBlocking { val pipeline = - db.realtimePipeline().collection(collRef.path).where(multiply("rating", 2.0).eq(8.4)) + db.realtimePipeline().collection(collRef.path).where(multiply("rating", 2.0).equal(8.4)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1363,7 +1370,7 @@ class RealtimePipelineTest { @Test fun testDivide() = runBlocking { val pipeline = - db.realtimePipeline().collection(collRef.path).where(divide("rating", 2.0).eq(2.1)) + db.realtimePipeline().collection(collRef.path).where(divide("rating", 2.0).equal(2.1)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1388,7 +1395,7 @@ class RealtimePipelineTest { @Test fun testMod() = runBlocking { val pipeline = - db.realtimePipeline().collection(collRef.path).where(mod("published", 100).eq(79)) + db.realtimePipeline().collection(collRef.path).where(mod("published", 100).equal(79)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1410,7 +1417,8 @@ class RealtimePipelineTest { @Test fun testPow() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(pow("rating", 2.0).gt(20.0)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(pow("rating", 2.0).greaterThan(20.0)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1431,7 +1439,7 @@ class RealtimePipelineTest { @Test fun testAbs() = runBlocking { collRef.document("book1").update("rating", -4.2).await() - val pipeline = db.realtimePipeline().collection(collRef.path).where(abs("rating").eq(4.2)) + val pipeline = db.realtimePipeline().collection(collRef.path).where(abs("rating").equal(4.2)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1458,7 +1466,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(and(exp("log_rating").gt(4.19), exp("log_rating").lt(4.21))) + .where(and(exp("log_rating").greaterThan(4.19), exp("log_rating").lessThan(4.21))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1484,7 +1492,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(and(ln("rating").gt(1.43), ln("rating").lt(1.44))) + .where(and(ln("rating").greaterThan(1.43), ln("rating").lessThan(1.44))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1510,7 +1518,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(log10("published").eq(kotlin.math.log10(1979.0))) + .where(log10("published").equal(kotlin.math.log10(1979.0))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1536,7 +1544,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(collRef.path) - .where(log("published", constant(4.2)).eq(kotlin.math.log(1954.0, 4.2))) + .where(log("published", constant(4.2)).equal(kotlin.math.log(1954.0, 4.2))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1559,7 +1567,7 @@ class RealtimePipelineTest { fun testSqrt() = runBlocking { val pipeline = // published since 1952 - db.realtimePipeline().collection(collRef.path).where(sqrt("published").gt(44.18)) + db.realtimePipeline().collection(collRef.path).where(sqrt("published").greaterThan(44.18)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1579,7 +1587,7 @@ class RealtimePipelineTest { @Test fun testRound() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(round("rating").eq(5.0)) + val pipeline = db.realtimePipeline().collection(collRef.path).where(round("rating").equal(5.0)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1599,7 +1607,7 @@ class RealtimePipelineTest { @Test fun testCeil() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(ceil("rating").eq(5.0)) + val pipeline = db.realtimePipeline().collection(collRef.path).where(ceil("rating").equal(5.0)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1628,7 +1636,7 @@ class RealtimePipelineTest { @Test fun testFloor() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(floor("rating").eq(4.0)) + val pipeline = db.realtimePipeline().collection(collRef.path).where(floor("rating").equal(4.0)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1654,7 +1662,7 @@ class RealtimePipelineTest { .collection(eventCollRef.path) .where( timestampAdd("timestamp", "day", 1) - .eq(unixSecondsToTimestamp(constant(1698228000 + 24 * 3600))) + .equal(unixSecondsToTimestamp(constant(1698228000 + 24 * 3600))) ) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) @@ -1682,8 +1690,8 @@ class RealtimePipelineTest { .collection(eventCollRef.path) .where( field("timestamp") - .timestampSub("day", 1) - .eq(unixSecondsToTimestamp(constant(1698228000 - 24 * 3600))) + .timestampSubtract("day", 1) + .equal(unixSecondsToTimestamp(constant(1698228000 - 24 * 3600))) ) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) @@ -1709,7 +1717,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(eventCollRef.path) - .where(field("timestamp").eq(unixSecondsToTimestamp(field("unix_seconds")))) + .where(field("timestamp").equal(unixSecondsToTimestamp(field("unix_seconds")))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1734,7 +1742,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(eventCollRef.path) - .where(field("timestamp").eq(unixMillisToTimestamp(constant(1698228000000L)))) + .where(field("timestamp").equal(unixMillisToTimestamp(constant(1698228000000L)))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1759,7 +1767,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(eventCollRef.path) - .where(timestampToUnixSeconds("timestamp").eq(1698228000)) + .where(timestampToUnixSeconds("timestamp").equal(1698228000)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1784,7 +1792,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(eventCollRef.path) - .where(timestampToUnixMillis("timestamp").eq(field("unix_millis"))) + .where(timestampToUnixMillis("timestamp").equal(field("unix_millis"))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1809,7 +1817,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(eventCollRef.path) - .where(timestampToUnixMicros("timestamp").eq(field("unix_micros"))) + .where(timestampToUnixMicros("timestamp").equal(field("unix_micros"))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1833,7 +1841,7 @@ class RealtimePipelineTest { db .realtimePipeline() .collection(eventCollRef.path) - .where(field("timestamp").eq(unixMicrosToTimestamp(field("unix_micros")))) + .where(field("timestamp").equal(unixMicrosToTimestamp(field("unix_micros")))) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1904,7 +1912,8 @@ class RealtimePipelineTest { @Test fun testArrayLength() = runBlocking { - val pipeline = db.realtimePipeline().collection(collRef.path).where(arrayLength("tags").eq(3)) + val pipeline = + db.realtimePipeline().collection(collRef.path).where(arrayLength("tags").equal(3)) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) @@ -1925,7 +1934,10 @@ class RealtimePipelineTest { @Test fun testSubstring() = runBlocking { val pipeline = - db.realtimePipeline().collection(collRef.path).where(field("title").substr(1, 3).eq("he ")) + db + .realtimePipeline() + .collection(collRef.path) + .where(field("title").substring(1, 3).equal("he ")) val options = RealtimePipelineOptions().withMetadataChanges(MetadataChanges.INCLUDE) val channel = Channel(Channel.UNLIMITED) diff --git a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java index 722b091d31c..58354c82541 100644 --- a/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java +++ b/firebase-firestore/src/androidTest/java/com/google/firebase/firestore/testutil/IntegrationTestUtil.java @@ -38,8 +38,8 @@ import com.google.firebase.firestore.FirebaseFirestoreSettings; import com.google.firebase.firestore.ListenerRegistration; import com.google.firebase.firestore.MetadataChanges; +import com.google.firebase.firestore.Pipeline; import com.google.firebase.firestore.PipelineResult; -import com.google.firebase.firestore.PipelineSnapshot; import com.google.firebase.firestore.Query; import com.google.firebase.firestore.QuerySnapshot; import com.google.firebase.firestore.Source; @@ -468,7 +468,7 @@ public static List> querySnapshotToValues(QuerySnapshot quer } public static List> pipelineSnapshotToValues( - PipelineSnapshot pipelineSnapshot) { + Pipeline.Snapshot pipelineSnapshot) { List> res = new ArrayList<>(); for (PipelineResult result : pipelineSnapshot) { res.add(result.getData()); @@ -484,7 +484,7 @@ public static List querySnapshotToIds(QuerySnapshot querySnapshot) { return res; } - public static List pipelineSnapshotToIds(PipelineSnapshot pipelineResults) { + public static List pipelineSnapshotToIds(Pipeline.Snapshot pipelineResults) { List res = new ArrayList<>(); for (PipelineResult result : pipelineResults) { DocumentReference ref = result.getRef(); @@ -597,7 +597,7 @@ public static void checkQueryAndPipelineResultsMatch(Query query, String... expe } catch (Exception e) { throw new RuntimeException("Classic Query FAILED", e); } - PipelineSnapshot docsFromPipeline; + Pipeline.Snapshot docsFromPipeline; try { docsFromPipeline = waitFor(query.getFirestore().pipeline().createFrom(query).execute()); } catch (Exception e) { diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateField.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateField.java index 76fa908eb30..bb74ebcbe66 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateField.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/AggregateField.java @@ -14,7 +14,7 @@ package com.google.firebase.firestore; -import static com.google.firebase.firestore.pipeline.Expr.field; +import static com.google.firebase.firestore.pipeline.Expression.field; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -232,7 +232,7 @@ private AverageAggregateField(@NonNull FieldPath fieldPath) { @NonNull @Override AliasedAggregate toPipeline() { - return field(getFieldPath()).avg().alias(getAlias()); + return field(getFieldPath()).average().alias(getAlias()); } } } diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/Pipeline.kt b/firebase-firestore/src/main/java/com/google/firebase/firestore/Pipeline.kt index 5ad811d518f..10c7b429681 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/Pipeline.kt +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/Pipeline.kt @@ -21,13 +21,14 @@ import com.google.firebase.firestore.model.Document import com.google.firebase.firestore.model.DocumentKey import com.google.firebase.firestore.model.ResourcePath import com.google.firebase.firestore.model.Values +import com.google.firebase.firestore.pipeline.AbstractOptions import com.google.firebase.firestore.pipeline.AddFieldsStage import com.google.firebase.firestore.pipeline.AggregateFunction import com.google.firebase.firestore.pipeline.AggregateOptions import com.google.firebase.firestore.pipeline.AggregateStage import com.google.firebase.firestore.pipeline.AliasedAggregate -import com.google.firebase.firestore.pipeline.AliasedExpr -import com.google.firebase.firestore.pipeline.BooleanExpr +import com.google.firebase.firestore.pipeline.AliasedExpression +import com.google.firebase.firestore.pipeline.BooleanExpression import com.google.firebase.firestore.pipeline.CollectionGroupOptions import com.google.firebase.firestore.pipeline.CollectionGroupSource import com.google.firebase.firestore.pipeline.CollectionSource @@ -35,17 +36,16 @@ import com.google.firebase.firestore.pipeline.CollectionSourceOptions import com.google.firebase.firestore.pipeline.DatabaseSource import com.google.firebase.firestore.pipeline.DistinctStage import com.google.firebase.firestore.pipeline.DocumentsSource -import com.google.firebase.firestore.pipeline.Expr -import com.google.firebase.firestore.pipeline.Expr.Companion.field +import com.google.firebase.firestore.pipeline.Expression +import com.google.firebase.firestore.pipeline.Expression.Companion.field import com.google.firebase.firestore.pipeline.Field import com.google.firebase.firestore.pipeline.FindNearestOptions import com.google.firebase.firestore.pipeline.FindNearestStage -import com.google.firebase.firestore.pipeline.FunctionExpr +import com.google.firebase.firestore.pipeline.FunctionExpression import com.google.firebase.firestore.pipeline.InternalOptions import com.google.firebase.firestore.pipeline.LimitStage import com.google.firebase.firestore.pipeline.OffsetStage import com.google.firebase.firestore.pipeline.Ordering -import com.google.firebase.firestore.pipeline.PipelineOptions import com.google.firebase.firestore.pipeline.RawStage import com.google.firebase.firestore.pipeline.RemoveFieldsStage import com.google.firebase.firestore.pipeline.ReplaceStage @@ -70,6 +70,50 @@ internal constructor( private val userDataReader: UserDataReader, private val stages: List> ) { + class ExecuteOptions private constructor(options: InternalOptions) : + AbstractOptions(options) { + + constructor() : this(InternalOptions.EMPTY) + + override fun self(options: InternalOptions) = ExecuteOptions(options) + + class IndexMode private constructor(internal val value: String) { + companion object { + @JvmField val RECOMMENDED = IndexMode("recommended") + } + } + + fun withIndexMode(indexMode: IndexMode): ExecuteOptions = with("index_mode", indexMode.value) + } + + /** + * A `Snapshot` contains the results of a pipeline execution. It can be iterated to retrieve the + * individual `PipelineResult` objects. + */ + class Snapshot internal constructor(executionTime: Timestamp, results: List) : + Iterable { + + /** The time at which the pipeline producing this result is executed. */ + val executionTime: Timestamp = executionTime + + /** List of all the results */ + val results: List = results + + override fun iterator() = results.iterator() + + override fun toString() = "Snapshot{executionTime=$executionTime, results=$results}" + override fun equals(other: Any?): Boolean { + if (this === other) return true + if (javaClass != other?.javaClass) return false + other as Snapshot + if (results != other.results) return false + return true + } + override fun hashCode(): Int { + return results.hashCode() + } + } + internal constructor( firestore: FirebaseFirestore, userDataReader: UserDataReader, @@ -101,24 +145,24 @@ internal constructor( } /** - * Executes this pipeline and returns the results as a [Task] of [PipelineSnapshot]. + * Executes this pipeline and returns the results as a [Task] of [Snapshot]. * * @return A [Task] that will be resolved with the results of the pipeline. */ - fun execute(): Task = execute(null) + fun execute(): Task = execute(null) /** - * Executes this pipeline and returns the results as a [Task] of [PipelineSnapshot]. + * Executes this pipeline and returns the results as a [Task] of [Snapshot]. * - * @param options The [PipelineOptions] to use to instruct Firestore backend execution. + * @param options The [ExecuteOptions] to use to instruct Firestore backend execution. * @return A [Task] that will be resolved with the results of the pipeline. */ - fun execute(options: PipelineOptions): Task = execute(options.options) + fun execute(options: ExecuteOptions): Task = execute(options.options) - internal fun execute(options: InternalOptions?): Task { + internal fun execute(options: InternalOptions?): Task { val request = toExecutePipelineRequest(options) val observerTask = ObserverSnapshotTask() - Logger.warn("Pipeline", "Executing pipeline: $request") + Logger.debug("Pipeline", "Executing pipeline: $request") firestore?.callClient { call -> call!!.executePipeline(request, observerTask) } return observerTask.task } @@ -126,7 +170,7 @@ internal constructor( private inner class ObserverSnapshotTask : PipelineResultObserver { private val userDataWriter = UserDataWriter(firestore, DocumentSnapshot.ServerTimestampBehavior.DEFAULT) - private val taskCompletionSource = TaskCompletionSource() + private val taskCompletionSource = TaskCompletionSource() private val results: MutableList = mutableListOf() override fun onDocument( key: DocumentKey?, @@ -146,14 +190,14 @@ internal constructor( } override fun onComplete(executionTime: Timestamp) { - taskCompletionSource.setResult(PipelineSnapshot(executionTime, results)) + taskCompletionSource.setResult(Snapshot(executionTime, results)) } override fun onError(exception: FirebaseFirestoreException) { taskCompletionSource.setException(exception) } - val task: Task + val task: Task get() = taskCompletionSource.task } @@ -183,7 +227,7 @@ internal constructor( * The added fields are defined using [Selectable]s, which can be: * * - [Field]: References an existing document field. - * - [AliasedExpr]: Represents the result of a expression with an assigned alias name using + * - [AliasedExpression]: Represents the result of a expression with an assigned alias name using * [Expr.alias] * * Example: @@ -237,7 +281,9 @@ internal constructor( */ fun removeFields(field: String, vararg additionalFields: String): Pipeline = append( - RemoveFieldsStage(arrayOf(field(field), *additionalFields.map(Expr::field).toTypedArray())) + RemoveFieldsStage( + arrayOf(field(field), *additionalFields.map(Expression::field).toTypedArray()) + ) ) /** @@ -247,7 +293,7 @@ internal constructor( * * - [String]: Name of an existing field * - [Field]: Reference to an existing field. - * - [AliasedExpr]: Represents the result of a expression with an assigned alias name using + * - [AliasedExpression]: Represents the result of a expression with an assigned alias name using * [Expr.alias] * * If no selections are provided, the output of this stage is empty. Use [Pipeline.addFields] @@ -278,7 +324,7 @@ internal constructor( * * - [String]: Name of an existing field * - [Field]: Reference to an existing field. - * - [AliasedExpr]: Represents the result of a expression with an assigned alias name using + * - [AliasedExpression]: Represents the result of a expression with an assigned alias name using * [Expr.alias] * * If no selections are provided, the output of this stage is empty. Use [Pipeline.addFields] @@ -332,14 +378,14 @@ internal constructor( /** * Filters the documents from previous stages to only include those matching the specified - * [BooleanExpr]. + * [BooleanExpression]. * * This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. * - * You can filter documents based on their field values, using implementations of [BooleanExpr], - * typically including but not limited to: + * You can filter documents based on their field values, using implementations of + * [BooleanExpression], typically including but not limited to: * - * - field comparators: [Expr.eq], [Expr.lt] (less than), [Expr.gt] (greater than), etc. + * - field comparators: [Expr.equal], [Expr.lessThan], [Expr.greaterThan], etc. * - logical operators: [Expr.and], [Expr.or], [Expr.not], etc. * - advanced functions: [Expr.regexMatch], [Expr.arrayContains], etc. * @@ -349,15 +395,15 @@ internal constructor( * .where( * and( * gt("rating", 4.0), // Filter for ratings greater than 4.0 - * field("genre").eq("Science Fiction") // Equivalent to eq("genre", "Science Fiction") + * field("genre").equal("Science Fiction") // Equivalent to equal("genre", "Science Fiction") * ) * ); * ``` * - * @param condition The [BooleanExpr] to apply. + * @param condition The [BooleanExpression] to apply. * @return A new [Pipeline] object with this stage appended to the stage list. */ - fun where(condition: BooleanExpr): Pipeline = append(WhereStage(condition)) + fun where(condition: BooleanExpression): Pipeline = append(WhereStage(condition)) /** * Skips the first `offset` number of documents from the results of previous stages. @@ -407,13 +453,13 @@ internal constructor( * Returns a set of distinct values from the inputs to this stage. * * This stage runs through the results from previous stages to include only results with unique - * combinations of [Expr] values [Field], [FunctionExpr], etc). + * combinations of [Expr] values [Field], [FunctionExpression], etc). * * The parameters to this stage are defined using [Selectable] expressions or strings: * * - [String]: Name of an existing field * - [Field]: References an existing document field. - * - [AliasedExpr]: Represents the result of a function with an assigned alias name using + * - [AliasedExpression]: Represents the result of a function with an assigned alias name using * [Expr.alias] * * Example: @@ -439,13 +485,13 @@ internal constructor( * Returns a set of distinct values from the inputs to this stage. * * This stage runs through the results from previous stages to include only results with unique - * combinations of [Expr] values ([Field], [FunctionExpr], etc). + * combinations of [Expr] values ([Field], [FunctionExpression], etc). * * The parameters to this stage are defined using [Selectable] expressions or strings: * * - [String]: Name of an existing field * - [Field]: References an existing document field. - * - [AliasedExpr]: Represents the result of a function with an assigned alias name using + * - [AliasedExpression]: Represents the result of a function with an assigned alias name using * [Expr.alias] * * Example: @@ -479,7 +525,7 @@ internal constructor( * // Calculate the average rating and the total number of books * firestore.pipeline().collection("books") * .aggregate( - * field("rating").avg().as("averageRating"), + * field("rating").average().as("averageRating"), * countAll().as("totalBooks") * ); * ``` @@ -517,7 +563,7 @@ internal constructor( * firestore.pipeline().collection("books") * .aggregate( * Aggregate - * .withAccumulators(avg("rating").as("avg_rating")) + * .withAccumulators(average("rating").as("avg_rating")) * .withGroups("genre")); * ``` * @@ -625,7 +671,7 @@ internal constructor( * and returning the first N documents in the result set. * * @param vectorField A [Field] that contains vector to search on. - * @param vectorValue The [Expr] that should evaluate to a [VectorValue] used to measure the + * @param vectorValue The [Expression] that should evaluate to a [VectorValue] used to measure the * distance from [vectorField] values in the documents. * @param distanceMeasure specifies what type of distance is calculated when performing the * search. @@ -633,7 +679,7 @@ internal constructor( */ fun findNearest( vectorField: String, - vectorValue: Expr, + vectorValue: Expression, distanceMeasure: FindNearestStage.DistanceMeasure ): Pipeline = findNearest(vectorField, vectorValue, distanceMeasure, FindNearestOptions()) @@ -652,7 +698,7 @@ internal constructor( * ``` * * @param vectorField A [Field] that contains vector to search on. - * @param vectorValue The [Expr] that should evaluate to a [VectorValue] used to measure the + * @param vectorValue The [Expression] that should evaluate to a [VectorValue] used to measure the * distance from [vectorField] values in the documents. * @param distanceMeasure specifies what type of distance is calculated when performing the * search. @@ -661,7 +707,7 @@ internal constructor( */ fun findNearest( vectorField: String, - vectorValue: Expr, + vectorValue: Expression, distanceMeasure: FindNearestStage.DistanceMeasure, options: FindNearestOptions ): Pipeline = append(FindNearestStage.of(vectorField, vectorValue, distanceMeasure, options)) @@ -723,10 +769,10 @@ internal constructor( * // } * ``` * - * @param mapValue The [Expr] or [Field] containing the nested map. + * @param mapValue The [Expression] or [Field] containing the nested map. * @return A new [Pipeline] object with this stage appended to the stage list. */ - fun replaceWith(mapValue: Expr): Pipeline = + fun replaceWith(mapValue: Expression): Pipeline = append(ReplaceStage(mapValue, ReplaceStage.Mode.FULL_REPLACE)) /** @@ -1034,35 +1080,6 @@ class PipelineSource internal constructor(private val firestore: FirebaseFiresto } } -/** - * A `PipelineSnapshot` contains the results of a pipeline execution. It can be iterated to retrieve - * the individual `PipelineResult` objects. - */ -class PipelineSnapshot -internal constructor(executionTime: Timestamp, results: List) : - Iterable { - - /** The time at which the pipeline producing this result is executed. */ - val executionTime: Timestamp = executionTime - - /** List of all the results */ - val results: List = results - - override fun iterator() = results.iterator() - - override fun toString() = "PipelineSnapshot{executionTime=$executionTime, results=$results}" - override fun equals(other: Any?): Boolean { - if (this === other) return true - if (javaClass != other?.javaClass) return false - other as PipelineSnapshot - if (results != other.results) return false - return true - } - override fun hashCode(): Int { - return results.hashCode() - } -} - class PipelineResult internal constructor( private val userDataWriter: UserDataWriter, diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/RealtimePipeline.kt b/firebase-firestore/src/main/java/com/google/firebase/firestore/RealtimePipeline.kt index 81987ab36fa..1f7eacd9890 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/RealtimePipeline.kt +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/RealtimePipeline.kt @@ -15,7 +15,6 @@ package com.google.firebase.firestore import com.google.firebase.firestore.core.AsyncEventListener -import com.google.firebase.firestore.core.Canonicalizable import com.google.firebase.firestore.core.DocumentViewChange import com.google.firebase.firestore.core.EventManager import com.google.firebase.firestore.core.QueryListener @@ -24,14 +23,14 @@ import com.google.firebase.firestore.core.ViewSnapshot import com.google.firebase.firestore.model.Document import com.google.firebase.firestore.model.MutableDocument import com.google.firebase.firestore.model.ResourcePath -import com.google.firebase.firestore.pipeline.BooleanExpr +import com.google.firebase.firestore.pipeline.BooleanExpression import com.google.firebase.firestore.pipeline.CollectionGroupOptions import com.google.firebase.firestore.pipeline.CollectionGroupSource import com.google.firebase.firestore.pipeline.CollectionSource import com.google.firebase.firestore.pipeline.CollectionSourceOptions import com.google.firebase.firestore.pipeline.EvaluationContext import com.google.firebase.firestore.pipeline.Field -import com.google.firebase.firestore.pipeline.FunctionExpr +import com.google.firebase.firestore.pipeline.FunctionExpression import com.google.firebase.firestore.pipeline.InternalOptions import com.google.firebase.firestore.pipeline.LimitStage import com.google.firebase.firestore.pipeline.OffsetStage @@ -138,7 +137,7 @@ internal constructor( internal val userDataReader: UserDataReader, internal val stages: List>, internal val internalOptions: EventManager.ListenOptions? = null -) : Canonicalizable { +) { internal constructor( firestore: FirebaseFirestore, serializer: RemoteSerializer, @@ -202,12 +201,12 @@ internal constructor( /** * Filters the documents from previous stages to only include those matching the specified - * [BooleanExpr]. + * [BooleanExpression]. * * This stage allows you to apply conditions to the data, similar to a "WHERE" clause in SQL. * - * You can filter documents based on their field values, using implementations of [BooleanExpr], - * typically including but not limited to: + * You can filter documents based on their field values, using implementations of + * [BooleanExpression], typically including but not limited to: * - field comparators: [Expr.eq], [Expr.lt] (less than), [Expr.gt] (greater than), etc. * - logical operators: [Expr.and], [Expr.or], [Expr.not], etc. * - advanced functions: [Expr.arrayContains], [Expr.eqAny]etc. @@ -223,10 +222,10 @@ internal constructor( * ); * ``` * - * @param condition The [BooleanExpr] to apply. + * @param condition The [BooleanExpression] to apply. * @return A new [RealtimePipeline] object with this stage appended to the stage list. */ - fun where(condition: BooleanExpr): RealtimePipeline = append(WhereStage(condition)) + fun where(condition: BooleanExpression): RealtimePipeline = append(WhereStage(condition)) /** * Starts listening to this pipeline and emits a [RealtimePipelineSnapshot] every time the results @@ -352,8 +351,8 @@ internal constructor( } } - override fun canonicalId(): String { - return rewrittenStages.joinToString("|") { stage -> (stage as Canonicalizable).canonicalId() } + internal fun canonicalId(): String { + return rewrittenStages.joinToString("|") { stage -> stage.canonicalId() } } override fun toString(): String = canonicalId() @@ -384,7 +383,7 @@ internal constructor( // Check for Where stage if (stage is WhereStage) { // Check if it's the special 'exists(__name__)' case - val funcExpr = stage.condition as? FunctionExpr + val funcExpr = stage.condition as? FunctionExpression if (funcExpr?.name == "exists" && funcExpr.params.size == 1) { val fieldExpr = funcExpr.params[0] as? Field if (fieldExpr?.fieldPath?.isKeyField == true) { diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java index ec630125b38..20fcd9054ca 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/UserDataReader.java @@ -37,7 +37,7 @@ import com.google.firebase.firestore.model.mutation.FieldMask; import com.google.firebase.firestore.model.mutation.NumericIncrementTransformOperation; import com.google.firebase.firestore.model.mutation.ServerTimestampOperation; -import com.google.firebase.firestore.pipeline.Expr; +import com.google.firebase.firestore.pipeline.Expression; import com.google.firebase.firestore.util.Assert; import com.google.firebase.firestore.util.CustomClassMapper; import com.google.firebase.firestore.util.Util; @@ -399,7 +399,7 @@ public Value parseScalarValue(Object input, ParseContext context) { DocumentReference ref = (DocumentReference) input; validateDocumentReference(ref, context::createError); return Values.encodeValue(ref); - } else if (input instanceof Expr) { + } else if (input instanceof Expression) { throw context.createError("Pipeline expressions are not supported user objects"); } else { try { diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Canonicalizable.kt b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Canonicalizable.kt deleted file mode 100644 index 9b463b43a5c..00000000000 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Canonicalizable.kt +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.google.firebase.firestore.core - -/** An internal interface for classes that can be canonicalized to a string representation. */ -internal interface Canonicalizable { - fun canonicalId(): String -} diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/CompositeFilter.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/CompositeFilter.java index 090ddf9c17b..135fd7bc036 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/CompositeFilter.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/CompositeFilter.java @@ -17,7 +17,7 @@ import android.text.TextUtils; import androidx.annotation.Nullable; import com.google.firebase.firestore.model.Document; -import com.google.firebase.firestore.pipeline.BooleanExpr; +import com.google.firebase.firestore.pipeline.BooleanExpression; import com.google.firebase.firestore.util.Function; import java.util.ArrayList; import java.util.Collections; @@ -169,17 +169,17 @@ public String getCanonicalId() { } @Override - BooleanExpr toPipelineExpr() { - BooleanExpr first = filters.get(0).toPipelineExpr(); - BooleanExpr[] additional = new BooleanExpr[filters.size() - 1]; + BooleanExpression toPipelineExpr() { + BooleanExpression first = filters.get(0).toPipelineExpr(); + BooleanExpression[] additional = new BooleanExpression[filters.size() - 1]; for (int i = 1, filtersSize = filters.size(); i < filtersSize; i++) { additional[i - 1] = filters.get(i).toPipelineExpr(); } switch (operator) { case AND: - return BooleanExpr.and(first, additional); + return BooleanExpression.and(first, additional); case OR: - return BooleanExpr.or(first, additional); + return BooleanExpression.or(first, additional); } // Handle OPERATOR_UNSPECIFIED and UNRECOGNIZED cases as needed throw new IllegalArgumentException("Unsupported operator: " + operator); diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/FieldFilter.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/FieldFilter.java index 775857d5390..58b00b8fe0b 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/FieldFilter.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/FieldFilter.java @@ -15,16 +15,16 @@ package com.google.firebase.firestore.core; import static com.google.firebase.firestore.model.Values.isNanValue; -import static com.google.firebase.firestore.pipeline.Expr.and; -import static com.google.firebase.firestore.pipeline.Expr.ifError; +import static com.google.firebase.firestore.pipeline.Expression.and; +import static com.google.firebase.firestore.pipeline.Expression.ifError; import static com.google.firebase.firestore.util.Assert.hardAssert; import androidx.annotation.NonNull; import com.google.firebase.firestore.model.Document; import com.google.firebase.firestore.model.FieldPath; import com.google.firebase.firestore.model.Values; -import com.google.firebase.firestore.pipeline.BooleanExpr; -import com.google.firebase.firestore.pipeline.Expr; +import com.google.firebase.firestore.pipeline.BooleanExpression; +import com.google.firebase.firestore.pipeline.Expression; import com.google.firebase.firestore.pipeline.Field; import com.google.firebase.firestore.util.Assert; import com.google.firestore.v1.Value; @@ -183,50 +183,52 @@ public List getFilters() { } @Override - BooleanExpr toPipelineExpr() { + BooleanExpression toPipelineExpr() { Field x = new Field(field); - BooleanExpr exists = x.exists(); + BooleanExpression exists = x.exists(); switch (operator) { case LESS_THAN: - return and(exists, x.lt(value)); + return and(exists, x.lessThan(value)); case LESS_THAN_OR_EQUAL: - return and(exists, x.lte(value)); + return and(exists, x.lessThanOrEqual(value)); case EQUAL: if (value.hasNullValue()) { return and(exists, x.isNull()); } else if (isNanValue(value)) { // The isNan will error on non-numeric values. - return and(exists, ifError(x.isNan(), Expr.constant(false))); + return and(exists, ifError(x.isNan(), Expression.constant(false))); } else { - return and(exists, x.eq(value)); + return and(exists, x.equal(value)); } case NOT_EQUAL: if (value.hasNullValue()) { return and(exists, x.isNotNull()); } else if (isNanValue(value)) { // The isNotNan will error on non-numeric values. - return and(exists, ifError(x.isNotNan(), Expr.constant(true))); + return and(exists, ifError(x.isNotNan(), Expression.constant(true))); } else { - return and(exists, x.neq(value)); + return and(exists, x.notEqual(value)); } case GREATER_THAN: - return and(exists, x.gt(value)); + return and(exists, x.greaterThan(value)); case GREATER_THAN_OR_EQUAL: - return and(exists, x.gte(value)); + return and(exists, x.greaterThanOrEqual(value)); case ARRAY_CONTAINS: return and(exists, x.arrayContains(value)); case ARRAY_CONTAINS_ANY: return and(exists, x.arrayContainsAny(value.getArrayValue().getValuesList())); case IN: - return and(exists, x.eqAny(value.getArrayValue().getValuesList())); + return and(exists, x.equalAny(value.getArrayValue().getValuesList())); case NOT_IN: { List list = value.getArrayValue().getValuesList(); if (hasNaN(list)) { return and( - exists, x.notEqAny(filterNaN(list)), ifError(x.isNotNan(), Expr.constant(true))); + exists, + x.notEqualAny(filterNaN(list)), + ifError(x.isNotNan(), Expression.constant(true))); } else { - return and(exists, x.notEqAny(list)); + return and(exists, x.notEqualAny(list)); } } default: diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Filter.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Filter.java index 3f33bd3d5bc..2802f4d0a1b 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Filter.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Filter.java @@ -15,7 +15,7 @@ package com.google.firebase.firestore.core; import com.google.firebase.firestore.model.Document; -import com.google.firebase.firestore.pipeline.BooleanExpr; +import com.google.firebase.firestore.pipeline.BooleanExpression; import java.util.List; public abstract class Filter { @@ -31,5 +31,5 @@ public abstract class Filter { /** Returns a list of all filters that are contained within this filter */ public abstract List getFilters(); - abstract BooleanExpr toPipelineExpr(); + abstract BooleanExpression toPipelineExpr(); } diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java index 263cb4cafee..7a53d0f407b 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/core/Query.java @@ -14,8 +14,8 @@ package com.google.firebase.firestore.core; -import static com.google.firebase.firestore.pipeline.Expr.and; -import static com.google.firebase.firestore.pipeline.Expr.or; +import static com.google.firebase.firestore.pipeline.Expression.and; +import static com.google.firebase.firestore.pipeline.Expression.or; import static com.google.firebase.firestore.util.Assert.hardAssert; import androidx.annotation.NonNull; @@ -30,14 +30,14 @@ import com.google.firebase.firestore.model.DocumentKey; import com.google.firebase.firestore.model.FieldPath; import com.google.firebase.firestore.model.ResourcePath; -import com.google.firebase.firestore.pipeline.BooleanExpr; +import com.google.firebase.firestore.pipeline.BooleanExpression; import com.google.firebase.firestore.pipeline.CollectionGroupOptions; import com.google.firebase.firestore.pipeline.CollectionGroupSource; import com.google.firebase.firestore.pipeline.CollectionSource; import com.google.firebase.firestore.pipeline.DocumentsSource; -import com.google.firebase.firestore.pipeline.Expr; +import com.google.firebase.firestore.pipeline.Expression; import com.google.firebase.firestore.pipeline.Field; -import com.google.firebase.firestore.pipeline.FunctionExpr; +import com.google.firebase.firestore.pipeline.FunctionExpression; import com.google.firebase.firestore.pipeline.InternalOptions; import com.google.firebase.firestore.pipeline.LimitStage; import com.google.firebase.firestore.pipeline.Ordering; @@ -572,21 +572,23 @@ private List> convertToStages(UserDataReader userDataReader) { if (fields.size() == 1) { stages.add(new WhereStage(fields.get(0).exists(), InternalOptions.EMPTY)); } else { - BooleanExpr[] conditions = - skipFirstToArray(fields, BooleanExpr[]::new, Expr.Companion::exists); + BooleanExpression[] conditions = + skipFirstToArray(fields, BooleanExpression[]::new, Expression.Companion::exists); stages.add(new WhereStage(and(fields.get(0).exists(), conditions), InternalOptions.EMPTY)); } if (startAt != null) { stages.add( new WhereStage( - whereConditionsFromCursor(startAt, fields, FunctionExpr::gt), InternalOptions.EMPTY)); + whereConditionsFromCursor(startAt, fields, FunctionExpression::greaterThan), + InternalOptions.EMPTY)); } if (endAt != null) { stages.add( new WhereStage( - whereConditionsFromCursor(endAt, fields, FunctionExpr::lt), InternalOptions.EMPTY)); + whereConditionsFromCursor(endAt, fields, FunctionExpression::lessThan), + InternalOptions.EMPTY)); } // Cursors, Limit, Offset @@ -603,7 +605,11 @@ private List> convertToStages(UserDataReader userDataReader) { List reversedOrderings = new ArrayList<>(); for (Ordering ordering : orderings) { - reversedOrderings.add(ordering.reverse()); + Ordering reversed = + ordering.getDir() == Ordering.Direction.ASCENDING + ? ordering.getExpr().descending() + : ordering.getExpr().ascending(); + reversedOrderings.add(reversed); } stages.add( new SortStage(reversedOrderings.toArray(new Ordering[0]), InternalOptions.EMPTY)); @@ -638,20 +644,20 @@ private static R[] skipFirstToArray( return result; } - private static BooleanExpr whereConditionsFromCursor( - Bound bound, List fields, BiFunction cmp) { + private static BooleanExpression whereConditionsFromCursor( + Bound bound, List fields, BiFunction cmp) { List boundPosition = bound.getPosition(); int size = boundPosition.size(); hardAssert(size <= fields.size(), "Bound positions must not exceed order fields."); int last = size - 1; - BooleanExpr condition = cmp.apply(fields.get(last), boundPosition.get(last)); + BooleanExpression condition = cmp.apply(fields.get(last), boundPosition.get(last)); if (bound.isInclusive()) { - condition = or(condition, Expr.eq(fields.get(last), boundPosition.get(last))); + condition = or(condition, Expression.equal(fields.get(last), boundPosition.get(last))); } for (int i = size - 2; i >= 0; i--) { final Field field = fields.get(i); final Value value = boundPosition.get(i); - condition = or(cmp.apply(field, value), and(field.eq(value), condition)); + condition = or(cmp.apply(field, value), and(field.equal(value), condition)); } return condition; } diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/aggregates.kt b/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/aggregates.kt index a86405be192..cf5256ec8fd 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/aggregates.kt +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/aggregates.kt @@ -24,12 +24,12 @@ internal constructor(internal val alias: String, internal val expr: AggregateFun class AggregateFunction private constructor( private val name: String, - private val params: Array, + private val params: Array, private val options: InternalOptions = InternalOptions.EMPTY ) { private constructor(name: String) : this(name, emptyArray()) - private constructor(name: String, expr: Expr) : this(name, arrayOf(expr)) - private constructor(name: String, fieldName: String) : this(name, Expr.field(fieldName)) + private constructor(name: String, expr: Expression) : this(name, arrayOf(expr)) + private constructor(name: String, fieldName: String) : this(name, Expression.field(fieldName)) companion object { @@ -43,7 +43,7 @@ private constructor( * @param expr The expressions to pass as arguments to the function. * @return A new [AggregateFunction] for the specified function. */ - @JvmStatic fun generic(name: String, vararg expr: Expr) = AggregateFunction(name, expr) + @JvmStatic fun generic(name: String, vararg expr: Expression) = AggregateFunction(name, expr) /** * Creates an aggregation that counts the total number of stage inputs. @@ -67,7 +67,7 @@ private constructor( * @param expression The expression to count. * @return A new [AggregateFunction] representing the 'count' aggregation. */ - @JvmStatic fun count(expression: Expr) = AggregateFunction("count", expression) + @JvmStatic fun count(expression: Expression) = AggregateFunction("count", expression) /** * Creates an aggregation that counts the number of stage inputs where the provided boolean @@ -76,7 +76,7 @@ private constructor( * @param condition The boolean expression to evaluate on each input. * @return A new [AggregateFunction] representing the count aggregation. */ - @JvmStatic fun countIf(condition: BooleanExpr) = AggregateFunction("count_if", condition) + @JvmStatic fun countIf(condition: BooleanExpression) = AggregateFunction("count_if", condition) /** * Creates an aggregation that calculates the sum of a field's values across multiple stage @@ -94,7 +94,7 @@ private constructor( * @param expression The expression to sum up. * @return A new [AggregateFunction] representing the sum aggregation. */ - @JvmStatic fun sum(expression: Expr) = AggregateFunction("sum", expression) + @JvmStatic fun sum(expression: Expression) = AggregateFunction("sum", expression) /** * Creates an aggregation that calculates the average (mean) of a field's values across multiple @@ -103,7 +103,7 @@ private constructor( * @param fieldName The name of the field containing numeric values to average. * @return A new [AggregateFunction] representing the average aggregation. */ - @JvmStatic fun avg(fieldName: String) = AggregateFunction("avg", fieldName) + @JvmStatic fun average(fieldName: String) = AggregateFunction("average", fieldName) /** * Creates an aggregation that calculates the average (mean) of values from an expression across @@ -112,7 +112,7 @@ private constructor( * @param expression The expression representing the values to average. * @return A new [AggregateFunction] representing the average aggregation. */ - @JvmStatic fun avg(expression: Expr) = AggregateFunction("avg", expression) + @JvmStatic fun average(expression: Expression) = AggregateFunction("average", expression) /** * Creates an aggregation that finds the minimum value of a field across multiple stage inputs. @@ -120,7 +120,7 @@ private constructor( * @param fieldName The name of the field to find the minimum value of. * @return A new [AggregateFunction] representing the minimum aggregation. */ - @JvmStatic fun minimum(fieldName: String) = AggregateFunction("min", fieldName) + @JvmStatic fun minimum(fieldName: String) = AggregateFunction("minimum", fieldName) /** * Creates an aggregation that finds the minimum value of an expression across multiple stage @@ -129,7 +129,7 @@ private constructor( * @param expression The expression to find the minimum value of. * @return A new [AggregateFunction] representing the minimum aggregation. */ - @JvmStatic fun minimum(expression: Expr) = AggregateFunction("min", expression) + @JvmStatic fun minimum(expression: Expression) = AggregateFunction("minimum", expression) /** * Creates an aggregation that finds the maximum value of a field across multiple stage inputs. @@ -137,7 +137,7 @@ private constructor( * @param fieldName The name of the field to find the maximum value of. * @return A new [AggregateFunction] representing the maximum aggregation. */ - @JvmStatic fun maximum(fieldName: String) = AggregateFunction("max", fieldName) + @JvmStatic fun maximum(fieldName: String) = AggregateFunction("maximum", fieldName) /** * Creates an aggregation that finds the maximum value of an expression across multiple stage @@ -146,7 +146,7 @@ private constructor( * @param expression The expression to find the maximum value of. * @return A new [AggregateFunction] representing the maximum aggregation. */ - @JvmStatic fun maximum(expression: Expr) = AggregateFunction("max", expression) + @JvmStatic fun maximum(expression: Expression) = AggregateFunction("maximum", expression) /** * Creates an aggregation that counts the number of distinct values of a field across multiple @@ -164,7 +164,8 @@ private constructor( * @param expression The expression to count the distinct values of. * @return A new [AggregateFunction] representing the count distinct aggregation. */ - @JvmStatic fun countDistinct(expression: Expr) = AggregateFunction("count_distinct", expression) + @JvmStatic + fun countDistinct(expression: Expression) = AggregateFunction("count_distinct", expression) } /** diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/evaluation.kt b/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/evaluation.kt index 6160cc57c99..7db367e30cd 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/evaluation.kt +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/evaluation.kt @@ -375,11 +375,11 @@ internal val evaluateSubtract = arithmeticPrimitive(LongMath::checkedSubtract, D internal val evaluateArray = variadicNullableValueFunction(EvaluateResult.Companion::list) -internal val evaluateEqAny = binaryFunction(::eqAny) +internal val evaluateEqAny = binaryFunction(::equalAny) -internal val evaluateNotEqAny = binaryFunction(::notEqAny) +internal val evaluateNotEqAny = binaryFunction(::notEqualAny) -internal val evaluateArrayContains = binaryFunction { l: List, v: Value -> eqAny(v, l) } +internal val evaluateArrayContains = binaryFunction { l: List, v: Value -> equalAny(v, l) } internal val evaluateArrayContainsAny = binaryFunction { array: List, searchValues: List -> @@ -419,7 +419,7 @@ internal val evaluateArrayLength = unaryFunction { array: List -> EvaluateResult.long(array.size) } -private fun eqAny(value: Value, list: List): EvaluateResult { +private fun equalAny(value: Value, list: List): EvaluateResult { var foundNull = false for (element in list) when (strictEquals(value, element)) { true -> return EvaluateResult.TRUE @@ -429,7 +429,7 @@ private fun eqAny(value: Value, list: List): EvaluateResult { return if (foundNull) EvaluateResult.NULL else EvaluateResult.FALSE } -private fun notEqAny(value: Value, list: List): EvaluateResult { +private fun notEqualAny(value: Value, list: List): EvaluateResult { var foundNull = false for (element in list) when (strictEquals(value, element)) { true -> return EvaluateResult.FALSE diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/expressions.kt b/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/expressions.kt index 8d248e1e980..ca7ea55ba60 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/expressions.kt +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/pipeline/expressions.kt @@ -23,7 +23,6 @@ import com.google.firebase.firestore.GeoPoint import com.google.firebase.firestore.Pipeline import com.google.firebase.firestore.UserDataReader import com.google.firebase.firestore.VectorValue -import com.google.firebase.firestore.core.Canonicalizable import com.google.firebase.firestore.model.DocumentKey import com.google.firebase.firestore.model.FieldPath as ModelFieldPath import com.google.firebase.firestore.model.FieldPath.CREATE_TIME_PATH @@ -36,7 +35,7 @@ import com.google.firebase.firestore.model.ServerTimestamps.isServerTimestamp import com.google.firebase.firestore.model.Values import com.google.firebase.firestore.model.Values.canonicalId import com.google.firebase.firestore.model.Values.encodeValue -import com.google.firebase.firestore.pipeline.Expr.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.field import com.google.firebase.firestore.util.CustomClassMapper import com.google.firestore.v1.MapValue import com.google.firestore.v1.Value @@ -52,12 +51,14 @@ import java.util.Date * - **Literals:** Represent constant values (strings, numbers, booleans). * - **Function calls:** Apply functions to one or more expressions. * - * The [Expr] class provides a fluent API for building expressions. You can chain together method - * calls to create complex expressions. + * The [Expression] class provides a fluent API for building expressions. You can chain together + * method calls to create complex expressions. */ -abstract class Expr internal constructor() : Canonicalizable { +abstract class Expression internal constructor() { - internal class Constant(val value: Value) : Expr() { + internal abstract fun canonicalId(): String + + internal class Constant(val value: Value) : Expression() { override fun toProto(userDataReader: UserDataReader): Value = value override fun evaluateFunction(context: EvaluationContext) = { _: MutableDocument -> EvaluateResultValue(value) @@ -79,18 +80,18 @@ abstract class Expr internal constructor() : Canonicalizable { } companion object { - internal fun toExprOrConstant(value: Any?): Expr = + internal fun toExprOrConstant(value: Any?): Expression = toExpr(value, ::toExprOrConstant) ?: pojoToExprOrConstant(CustomClassMapper.convertToPlainJavaTypes(value)) - private fun pojoToExprOrConstant(value: Any?): Expr = + private fun pojoToExprOrConstant(value: Any?): Expression = toExpr(value, ::pojoToExprOrConstant) ?: throw IllegalArgumentException("Unknown type: $value") - private inline fun toExpr(value: Any?, toExpr: (Any?) -> Expr): Expr? { + private inline fun toExpr(value: Any?, toExpr: (Any?) -> Expression): Expression? { if (value == null) return NULL return when (value) { - is Expr -> value + is Expression -> value is String -> constant(value) is Number -> constant(value) is Date -> constant(value) @@ -117,69 +118,95 @@ abstract class Expr internal constructor() : Canonicalizable { } } - private fun toArrayOfExprOrConstant(others: Iterable): Array = + private fun toArrayOfExprOrConstant(others: Iterable): Array = others.map(::toExprOrConstant).toTypedArray() - internal fun toArrayOfExprOrConstant(others: Array): Array = + internal fun toArrayOfExprOrConstant(others: Array): Array = others.map(::toExprOrConstant).toTypedArray() - private val NULL: Expr = Constant(Values.NULL_VALUE) + private val NULL: Expression = Constant(Values.NULL_VALUE) /** * Create a constant for a [String] value. * + * ```kotlin + * // Create a constant with the value "hello" + * constant("hello") + * ``` + * * @param value The [String] value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(value: String): Expr { + fun constant(value: String): Expression { return Constant(encodeValue(value)) } /** * Create a constant for a [Number] value. * + * ```kotlin + * // Create a constant with the value 123 + * constant(123) + * ``` + * * @param value The [Number] value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(value: Number): Expr { + fun constant(value: Number): Expression { return Constant(encodeValue(value)) } /** * Create a constant for a [Date] value. * + * ```kotlin + * // Create a constant with the current date + * constant(Date()) + * ``` + * * @param value The [Date] value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(value: Date): Expr { + fun constant(value: Date): Expression { return Constant(encodeValue(value)) } /** * Create a constant for a [Timestamp] value. * + * ```kotlin + * // Create a constant with the current timestamp + * constant(Timestamp.now()) + * ``` + * * @param value The [Timestamp] value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(value: Timestamp): Expr { + fun constant(value: Timestamp): Expression { return Constant(encodeValue(value)) } /** * Create a constant for a [Boolean] value. * + * ```kotlin + * // Create a constant with the value true + * constant(true) + * ``` + * * @param value The [Boolean] value. - * @return A new [BooleanExpr] constant instance. + * @return A new [BooleanExpression] constant instance. */ @JvmStatic - fun constant(value: Boolean): BooleanExpr { + fun constant(value: Boolean): BooleanExpression { val encodedValue = encodeValue(value) val evaluateResultValue = EvaluateResultValue(encodedValue) - return object : BooleanExpr("N/A", { _ -> { _ -> evaluateResultValue } }, emptyArray()) { + return object : + BooleanExpression("N/A", { _ -> { _ -> evaluateResultValue } }, emptyArray()) { override fun toProto(userDataReader: UserDataReader): Value { return encodedValue } @@ -197,85 +224,121 @@ abstract class Expr internal constructor() : Canonicalizable { /** * Create a constant for a [GeoPoint] value. * + * ```kotlin + * // Create a constant with a GeoPoint + * constant(GeoPoint(37.7749, -122.4194)) + * ``` + * * @param value The [GeoPoint] value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(value: GeoPoint): Expr { // Ensure this overload exists or is correctly placed + fun constant( + value: GeoPoint + ): Expression { // Ensure this overload exists or is correctly placed return Constant(encodeValue(value)) } /** * Create a constant for a bytes value. * + * ```kotlin + * // Create a constant with a byte array + * constant(byteArrayOf(0x48, 0x65, 0x6c, 0x6c, 0x6f)) // "Hello" + * ``` + * * @param value The bytes value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(value: ByteArray): Expr { + fun constant(value: ByteArray): Expression { return Constant(encodeValue(value)) } /** * Create a constant for a [Blob] value. * + * ```kotlin + * // Create a constant with a Blob + * constant(Blob.fromBytes(byteArrayOf(0x48, 0x65, 0x6c, 0x6c, 0x6f))) // "Hello" + * ``` + * * @param value The [Blob] value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(value: Blob): Expr { + fun constant(value: Blob): Expression { return Constant(encodeValue(value)) } /** * Create a constant for a [DocumentReference] value. * + * ```kotlin + * // val firestore = FirebaseFirestore.getInstance() + * // val docRef = firestore.collection("cities").document("SF") + * // constant(docRef) + * ``` + * * @param ref The [DocumentReference] value. - * @return A new [Expr] constant instance. + * @return A new [Expression] constant instance. */ @JvmStatic - fun constant(ref: DocumentReference): Expr { + fun constant(ref: DocumentReference): Expression { return Constant(encodeValue(ref)) } /** * Create a constant for a [VectorValue] value. * - * @param value The [VectorValue] value. - * @return A new [Expr] constant instance. - */ - @JvmStatic fun constant(value: VectorValue): Expr = Constant(encodeValue(value)) - - /** - * Create a [Blob] constant from a [ByteArray]. + * ```kotlin + * // Create a constant with a VectorValue + * constant(VectorValue(listOf(1.0, 2.0, 3.0))) + * ``` * - * @param bytes The [ByteArray] to convert to a Blob. - * @return A new [Expr] constant instance representing the Blob. + * @param value The [VectorValue] value. + * @return A new [Expression] constant instance. */ - @JvmStatic fun blob(bytes: ByteArray): Expr = constant(Blob.fromBytes(bytes)) + @JvmStatic fun constant(value: VectorValue): Expression = Constant(encodeValue(value)) /** * Constant for a null value. * - * @return A [Expr] constant instance. + * ```kotlin + * // Create a null constant + * nullValue() + * ``` + * + * @return A [Expression] constant instance. */ - @JvmStatic fun nullValue(): Expr = NULL + @JvmStatic fun nullValue(): Expression = NULL /** * Create a vector constant for a [DoubleArray] value. * + * ```kotlin + * // Create a vector constant from a DoubleArray + * vector(doubleArrayOf(1.0, 2.0, 3.0)) + * ``` + * * @param vector The [DoubleArray] value. - * @return A [Expr] constant instance. + * @return A [Expression] constant instance. */ - @JvmStatic fun vector(vector: DoubleArray): Expr = Constant(Values.encodeVectorValue(vector)) + @JvmStatic + fun vector(vector: DoubleArray): Expression = Constant(Values.encodeVectorValue(vector)) /** * Create a vector constant for a [VectorValue] value. * + * ```kotlin + * // Create a vector constant from a VectorValue + * vector(VectorValue(listOf(1.0, 2.0, 3.0))) + * ``` + * * @param vector The [VectorValue] value. - * @return A [Expr] constant instance. + * @return A [Expression] constant instance. */ - @JvmStatic fun vector(vector: VectorValue): Expr = Constant(encodeValue(vector)) + @JvmStatic fun vector(vector: VectorValue): Expression = Constant(encodeValue(vector)) /** * Creates a [Field] instance representing the field at the given path. @@ -302,2782 +365,4219 @@ abstract class Expr internal constructor() : Canonicalizable { * The path can be a simple field name (e.g., "name") or a dot-separated path to a nested field * (e.g., "address.city"). * + * ```kotlin + * // Get the 'address.city' field + * field(FieldPath.of("address", "city")) + * ``` + * * @param fieldPath The [FieldPath] to the field. * @return A new [Field] instance representing the specified path. */ @JvmStatic fun field(fieldPath: FieldPath): Field = Field(fieldPath.internalPath) /** - * Creates a generic function expression that is not yet implemented. + * Creates a 'raw' function expression. This is useful if the expression is available in the + * backend, but not yet in the current version of the SDK yet. * - * @param name The name of the generic function. + * ```kotlin + * // Create a generic function call + * rawFunction("my_function", field("arg1"), constant(42)) + * ``` + * + * @param name The name of the raw function. * @param expr The expressions to be passed as arguments to the function. - * @return A new [Expr] representing the generic function. + * @return A new [Expression] representing the raw function. */ @JvmStatic - fun generic(name: String, vararg expr: Expr): Expr = FunctionExpr(name, notImplemented, expr) + fun rawFunction(name: String, vararg expr: Expression): Expression = + FunctionExpression(name, notImplemented, expr) /** * Creates an expression that performs a logical 'AND' operation. * - * @param condition The first [BooleanExpr]. - * @param conditions Additional [BooleanExpr]s. - * @return A new [BooleanExpr] representing the logical 'AND' operation. + * ```kotlin + * // Check if 'status' is "new" and 'priority' is greater than 1 + * and(field("status").equal("new"), field("priority").greaterThan(1)) + * ``` + * + * @param condition The first [BooleanExpression]. + * @param conditions Additional [BooleanExpression]s. + * @return A new [BooleanExpression] representing the logical 'AND' operation. */ @JvmStatic - fun and(condition: BooleanExpr, vararg conditions: BooleanExpr) = - BooleanExpr("and", evaluateAnd, condition, *conditions) + fun and(condition: BooleanExpression, vararg conditions: BooleanExpression) = + BooleanExpression("and", evaluateAnd, condition, *conditions) /** * Creates an expression that performs a logical 'OR' operation. * - * @param condition The first [BooleanExpr]. - * @param conditions Additional [BooleanExpr]s. - * @return A new [BooleanExpr] representing the logical 'OR' operation. + * ```kotlin + * // Check if 'status' is "new" or "open" + * or(field("status").equal("new"), field("status").equal("open")) + * ``` + * + * @param condition The first [BooleanExpression]. + * @param conditions Additional [BooleanExpression]s. + * @return A new [BooleanExpression] representing the logical 'OR' operation. */ @JvmStatic - fun or(condition: BooleanExpr, vararg conditions: BooleanExpr) = - BooleanExpr("or", evaluateOr, condition, *conditions) + fun or(condition: BooleanExpression, vararg conditions: BooleanExpression) = + BooleanExpression("or", evaluateOr, condition, *conditions) /** * Creates an expression that performs a logical 'XOR' operation. * - * @param condition The first [BooleanExpr]. - * @param conditions Additional [BooleanExpr]s. - * @return A new [BooleanExpr] representing the logical 'XOR' operation. + * ```kotlin + * // Check if either 'a' is true or 'b' is true, but not both + * xor(field("a"), field("b")) + * ``` + * + * @param condition The first [BooleanExpression]. + * @param conditions Additional [BooleanExpression]s. + * @return A new [BooleanExpression] representing the logical 'XOR' operation. */ @JvmStatic - fun xor(condition: BooleanExpr, vararg conditions: BooleanExpr) = - BooleanExpr("xor", evaluateXor, condition, *conditions) + fun xor(condition: BooleanExpression, vararg conditions: BooleanExpression) = + BooleanExpression("xor", evaluateXor, condition, *conditions) /** * Creates an expression that negates a boolean expression. * + * ```kotlin + * // Check if 'is_admin' is not true + * not(field("is_admin")) + * ``` + * * @param condition The boolean expression to negate. - * @return A new [BooleanExpr] representing the not operation. + * @return A new [BooleanExpression] representing the not operation. */ @JvmStatic - fun not(condition: BooleanExpr): BooleanExpr = BooleanExpr("not", evaluateNot, condition) + fun not(condition: BooleanExpression): BooleanExpression = + BooleanExpression("not", evaluateNot, condition) /** * Creates an expression that applies a bitwise AND operation between two expressions. * + * ```kotlin + * // Bitwise AND the value of the 'flags' field with the value of the 'mask' field. + * bitAnd(field("flags"), field("mask")) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise AND operation. + * @return A new [Expression] representing the bitwise AND operation. */ @JvmStatic - fun bitAnd(bits: Expr, bitsOther: Expr): Expr = - FunctionExpr("bit_and", notImplemented, bits, bitsOther) + fun bitAnd(bits: Expression, bitsOther: Expression): Expression = + FunctionExpression("bit_and", notImplemented, bits, bitsOther) /** * Creates an expression that applies a bitwise AND operation between an expression and a * constant. * + * ```kotlin + * // Bitwise AND the value of the 'flags' field with a constant mask. + * bitAnd(field("flags"), byteArrayOf(0b00001111)) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise AND operation. + * @return A new [Expression] representing the bitwise AND operation. */ @JvmStatic - fun bitAnd(bits: Expr, bitsOther: ByteArray): Expr = - FunctionExpr("bit_and", notImplemented, bits, constant(bitsOther)) + fun bitAnd(bits: Expression, bitsOther: ByteArray): Expression = + FunctionExpression("bit_and", notImplemented, bits, constant(bitsOther)) /** * Creates an expression that applies a bitwise AND operation between an field and an * expression. * + * ```kotlin + * // Bitwise AND the value of the 'flags' field with the value of the 'mask' field. + * bitAnd("flags", field("mask")) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise AND operation. + * @return A new [Expression] representing the bitwise AND operation. */ @JvmStatic - fun bitAnd(bitsFieldName: String, bitsOther: Expr): Expr = - FunctionExpr("bit_and", notImplemented, bitsFieldName, bitsOther) + fun bitAnd(bitsFieldName: String, bitsOther: Expression): Expression = + FunctionExpression("bit_and", notImplemented, bitsFieldName, bitsOther) /** * Creates an expression that applies a bitwise AND operation between an field and constant. * + * ```kotlin + * // Bitwise AND the value of the 'flags' field with a constant mask. + * bitAnd("flags", byteArrayOf(0b00001111)) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise AND operation. + * @return A new [Expression] representing the bitwise AND operation. */ @JvmStatic - fun bitAnd(bitsFieldName: String, bitsOther: ByteArray): Expr = - FunctionExpr("bit_and", notImplemented, bitsFieldName, constant(bitsOther)) + fun bitAnd(bitsFieldName: String, bitsOther: ByteArray): Expression = + FunctionExpression("bit_and", notImplemented, bitsFieldName, constant(bitsOther)) /** * Creates an expression that applies a bitwise OR operation between two expressions. * + * ```kotlin + * // Bitwise OR the value of the 'flags' field with the value of the 'mask' field. + * bitOr(field("flags"), field("mask")) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise OR operation. + * @return A new [Expression] representing the bitwise OR operation. */ @JvmStatic - fun bitOr(bits: Expr, bitsOther: Expr): Expr = - FunctionExpr("bit_or", notImplemented, bits, bitsOther) + fun bitOr(bits: Expression, bitsOther: Expression): Expression = + FunctionExpression("bit_or", notImplemented, bits, bitsOther) /** * Creates an expression that applies a bitwise OR operation between an expression and a * constant. * + * ```kotlin + * // Bitwise OR the value of the 'flags' field with a constant mask. + * bitOr(field("flags"), byteArrayOf(0b00001111)) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise OR operation. + * @return A new [Expression] representing the bitwise OR operation. */ @JvmStatic - fun bitOr(bits: Expr, bitsOther: ByteArray): Expr = - FunctionExpr("bit_or", notImplemented, bits, constant(bitsOther)) + fun bitOr(bits: Expression, bitsOther: ByteArray): Expression = + FunctionExpression("bit_or", notImplemented, bits, constant(bitsOther)) /** * Creates an expression that applies a bitwise OR operation between an field and an expression. * + * ```kotlin + * // Bitwise OR the value of the 'flags' field with the value of the 'mask' field. + * bitOr("flags", field("mask")) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise OR operation. + * @return A new [Expression] representing the bitwise OR operation. */ @JvmStatic - fun bitOr(bitsFieldName: String, bitsOther: Expr): Expr = - FunctionExpr("bit_or", notImplemented, bitsFieldName, bitsOther) + fun bitOr(bitsFieldName: String, bitsOther: Expression): Expression = + FunctionExpression("bit_or", notImplemented, bitsFieldName, bitsOther) /** * Creates an expression that applies a bitwise OR operation between an field and constant. * + * ```kotlin + * // Bitwise OR the value of the 'flags' field with a constant mask. + * bitOr("flags", byteArrayOf(0b00001111)) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise OR operation. + * @return A new [Expression] representing the bitwise OR operation. */ @JvmStatic - fun bitOr(bitsFieldName: String, bitsOther: ByteArray): Expr = - FunctionExpr("bit_or", notImplemented, bitsFieldName, constant(bitsOther)) + fun bitOr(bitsFieldName: String, bitsOther: ByteArray): Expression = + FunctionExpression("bit_or", notImplemented, bitsFieldName, constant(bitsOther)) /** * Creates an expression that applies a bitwise XOR operation between two expressions. * + * ```kotlin + * // Bitwise XOR the value of the 'flags' field with the value of the 'mask' field. + * bitXor(field("flags"), field("mask")) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise XOR operation. + * @return A new [Expression] representing the bitwise XOR operation. */ @JvmStatic - fun bitXor(bits: Expr, bitsOther: Expr): Expr = - FunctionExpr("bit_xor", notImplemented, bits, bitsOther) + fun bitXor(bits: Expression, bitsOther: Expression): Expression = + FunctionExpression("bit_xor", notImplemented, bits, bitsOther) /** * Creates an expression that applies a bitwise XOR operation between an expression and a * constant. * + * ```kotlin + * // Bitwise XOR the value of the 'flags' field with a constant mask. + * bitXor(field("flags"), byteArrayOf(0b00001111)) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise XOR operation. + * @return A new [Expression] representing the bitwise XOR operation. */ @JvmStatic - fun bitXor(bits: Expr, bitsOther: ByteArray): Expr = - FunctionExpr("bit_xor", notImplemented, bits, constant(bitsOther)) + fun bitXor(bits: Expression, bitsOther: ByteArray): Expression = + FunctionExpression("bit_xor", notImplemented, bits, constant(bitsOther)) /** * Creates an expression that applies a bitwise XOR operation between an field and an * expression. * + * ```kotlin + * // Bitwise XOR the value of the 'flags' field with the value of the 'mask' field. + * bitXor("flags", field("mask")) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise XOR operation. + * @return A new [Expression] representing the bitwise XOR operation. */ @JvmStatic - fun bitXor(bitsFieldName: String, bitsOther: Expr): Expr = - FunctionExpr("bit_xor", notImplemented, bitsFieldName, bitsOther) + fun bitXor(bitsFieldName: String, bitsOther: Expression): Expression = + FunctionExpression("bit_xor", notImplemented, bitsFieldName, bitsOther) /** * Creates an expression that applies a bitwise XOR operation between an field and constant. * + * ```kotlin + * // Bitwise XOR the value of the 'flags' field with a constant mask. + * bitXor("flags", byteArrayOf(0b00001111)) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise XOR operation. + * @return A new [Expression] representing the bitwise XOR operation. */ @JvmStatic - fun bitXor(bitsFieldName: String, bitsOther: ByteArray): Expr = - FunctionExpr("bit_xor", notImplemented, bitsFieldName, constant(bitsOther)) + fun bitXor(bitsFieldName: String, bitsOther: ByteArray): Expression = + FunctionExpression("bit_xor", notImplemented, bitsFieldName, constant(bitsOther)) /** * Creates an expression that applies a bitwise NOT operation to an expression. * + * ```kotlin + * // Bitwise NOT the value of the 'flags' field. + * bitNot(field("flags")) + * ``` + * * @param bits An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise NOT operation. + * @return A new [Expression] representing the bitwise NOT operation. */ - @JvmStatic fun bitNot(bits: Expr): Expr = FunctionExpr("bit_not", notImplemented, bits) + @JvmStatic + fun bitNot(bits: Expression): Expression = FunctionExpression("bit_not", notImplemented, bits) /** * Creates an expression that applies a bitwise NOT operation to a field. * + * ```kotlin + * // Bitwise NOT the value of the 'flags' field. + * bitNot("flags") + * ``` + * * @param bitsFieldName Name of field that contains bits data. - * @return A new [Expr] representing the bitwise NOT operation. + * @return A new [Expression] representing the bitwise NOT operation. */ @JvmStatic - fun bitNot(bitsFieldName: String): Expr = FunctionExpr("bit_not", notImplemented, bitsFieldName) + fun bitNot(bitsFieldName: String): Expression = + FunctionExpression("bit_not", notImplemented, bitsFieldName) /** * Creates an expression that applies a bitwise left shift operation between two expressions. * + * ```kotlin + * // Left shift the value of the 'bits' field by the value of the 'shift' field. + * bitLeftShift(field("bits"), field("shift")) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param numberExpr The number of bits to shift. - * @return A new [Expr] representing the bitwise left shift operation. + * @return A new [Expression] representing the bitwise left shift operation. */ @JvmStatic - fun bitLeftShift(bits: Expr, numberExpr: Expr): Expr = - FunctionExpr("bit_left_shift", notImplemented, bits, numberExpr) + fun bitLeftShift(bits: Expression, numberExpr: Expression): Expression = + FunctionExpression("bit_left_shift", notImplemented, bits, numberExpr) /** * Creates an expression that applies a bitwise left shift operation between an expression and a * constant. * + * ```kotlin + * // Left shift the value of the 'bits' field by 2. + * bitLeftShift(field("bits"), 2) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param number The number of bits to shift. - * @return A new [Expr] representing the bitwise left shift operation. + * @return A new [Expression] representing the bitwise left shift operation. */ @JvmStatic - fun bitLeftShift(bits: Expr, number: Int): Expr = - FunctionExpr("bit_left_shift", notImplemented, bits, number) + fun bitLeftShift(bits: Expression, number: Int): Expression = + FunctionExpression("bit_left_shift", notImplemented, bits, number) /** * Creates an expression that applies a bitwise left shift operation between a field and an * expression. * + * ```kotlin + * // Left shift the value of the 'bits' field by the value of the 'shift' field. + * bitLeftShift("bits", field("shift")) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param numberExpr The number of bits to shift. - * @return A new [Expr] representing the bitwise left shift operation. + * @return A new [Expression] representing the bitwise left shift operation. */ @JvmStatic - fun bitLeftShift(bitsFieldName: String, numberExpr: Expr): Expr = - FunctionExpr("bit_left_shift", notImplemented, bitsFieldName, numberExpr) + fun bitLeftShift(bitsFieldName: String, numberExpr: Expression): Expression = + FunctionExpression("bit_left_shift", notImplemented, bitsFieldName, numberExpr) /** * Creates an expression that applies a bitwise left shift operation between a field and a * constant. * + * ```kotlin + * // Left shift the value of the 'bits' field by 2. + * bitLeftShift("bits", 2) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param number The number of bits to shift. - * @return A new [Expr] representing the bitwise left shift operation. + * @return A new [Expression] representing the bitwise left shift operation. */ @JvmStatic - fun bitLeftShift(bitsFieldName: String, number: Int): Expr = - FunctionExpr("bit_left_shift", notImplemented, bitsFieldName, number) + fun bitLeftShift(bitsFieldName: String, number: Int): Expression = + FunctionExpression("bit_left_shift", notImplemented, bitsFieldName, number) /** * Creates an expression that applies a bitwise right shift operation between two expressions. * + * ```kotlin + * // Right shift the value of the 'bits' field by the value of the 'shift' field. + * bitRightShift(field("bits"), field("shift")) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param numberExpr The number of bits to shift. - * @return A new [Expr] representing the bitwise right shift operation. + * @return A new [Expression] representing the bitwise right shift operation. */ @JvmStatic - fun bitRightShift(bits: Expr, numberExpr: Expr): Expr = - FunctionExpr("bit_right_shift", notImplemented, bits, numberExpr) + fun bitRightShift(bits: Expression, numberExpr: Expression): Expression = + FunctionExpression("bit_right_shift", notImplemented, bits, numberExpr) /** * Creates an expression that applies a bitwise right shift operation between an expression and * a constant. * + * ```kotlin + * // Right shift the value of the 'bits' field by 2. + * bitRightShift(field("bits"), 2) + * ``` + * * @param bits An expression that returns bits when evaluated. * @param number The number of bits to shift. - * @return A new [Expr] representing the bitwise right shift operation. + * @return A new [Expression] representing the bitwise right shift operation. */ @JvmStatic - fun bitRightShift(bits: Expr, number: Int): Expr = - FunctionExpr("bit_right_shift", notImplemented, bits, number) + fun bitRightShift(bits: Expression, number: Int): Expression = + FunctionExpression("bit_right_shift", notImplemented, bits, number) /** * Creates an expression that applies a bitwise right shift operation between a field and an * expression. * + * ```kotlin + * // Right shift the value of the 'bits' field by the value of the 'shift' field. + * bitRightShift("bits", field("shift")) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param numberExpr The number of bits to shift. - * @return A new [Expr] representing the bitwise right shift operation. + * @return A new [Expression] representing the bitwise right shift operation. */ @JvmStatic - fun bitRightShift(bitsFieldName: String, numberExpr: Expr): Expr = - FunctionExpr("bit_right_shift", notImplemented, bitsFieldName, numberExpr) + fun bitRightShift(bitsFieldName: String, numberExpr: Expression): Expression = + FunctionExpression("bit_right_shift", notImplemented, bitsFieldName, numberExpr) /** * Creates an expression that applies a bitwise right shift operation between a field and a * constant. * + * ```kotlin + * // Right shift the value of the 'bits' field by 2. + * bitRightShift("bits", 2) + * ``` + * * @param bitsFieldName Name of field that contains bits data. * @param number The number of bits to shift. - * @return A new [Expr] representing the bitwise right shift operation. + * @return A new [Expression] representing the bitwise right shift operation. */ @JvmStatic - fun bitRightShift(bitsFieldName: String, number: Int): Expr = - FunctionExpr("bit_right_shift", notImplemented, bitsFieldName, number) + fun bitRightShift(bitsFieldName: String, number: Int): Expression = + FunctionExpression("bit_right_shift", notImplemented, bitsFieldName, number) /** * Creates an expression that rounds [numericExpr] to nearest integer. * + * ```kotlin + * // Round the value of the 'price' field. + * round(field("price")) + * ``` + * * Rounds away from zero in halfway cases. * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing an integer result from the round operation. + * @return A new [Expression] representing an integer result from the round operation. */ @JvmStatic - fun round(numericExpr: Expr): Expr = FunctionExpr("round", evaluateRound, numericExpr) + fun round(numericExpr: Expression): Expression = + FunctionExpression("round", evaluateRound, numericExpr) /** * Creates an expression that rounds [numericField] to nearest integer. * + * ```kotlin + * // Round the value of the 'price' field. + * round("price") + * ``` + * * Rounds away from zero in halfway cases. * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing an integer result from the round operation. + * @return A new [Expression] representing an integer result from the round operation. */ @JvmStatic - fun round(numericField: String): Expr = FunctionExpr("round", evaluateRound, numericField) + fun round(numericField: String): Expression = + FunctionExpression("round", evaluateRound, numericField) /** * Creates an expression that rounds off [numericExpr] to [decimalPlace] decimal places if * [decimalPlace] is positive, rounds off digits to the left of the decimal point if * [decimalPlace] is negative. Rounds away from zero in halfway cases. * + * ```kotlin + * // Round the value of the 'price' field to 2 decimal places. + * roundToPrecision(field("price"), 2) + * ``` + * * @param numericExpr An expression that returns number when evaluated. * @param decimalPlace The number of decimal places to round. - * @return A new [Expr] representing the round operation. + * @return A new [Expression] representing the round operation. */ @JvmStatic - fun roundToPrecision(numericExpr: Expr, decimalPlace: Int): Expr = - FunctionExpr("round", evaluateRoundToPrecision, numericExpr, constant(decimalPlace)) + fun roundToPrecision(numericExpr: Expression, decimalPlace: Int): Expression = + FunctionExpression("round", evaluateRoundToPrecision, numericExpr, constant(decimalPlace)) /** * Creates an expression that rounds off [numericField] to [decimalPlace] decimal places if * [decimalPlace] is positive, rounds off digits to the left of the decimal point if * [decimalPlace] is negative. Rounds away from zero in halfway cases. * + * ```kotlin + * // Round the value of the 'price' field to 2 decimal places. + * roundToPrecision("price", 2) + * ``` + * * @param numericField Name of field that returns number when evaluated. * @param decimalPlace The number of decimal places to round. - * @return A new [Expr] representing the round operation. + * @return A new [Expression] representing the round operation. */ @JvmStatic - fun roundToPrecision(numericField: String, decimalPlace: Int): Expr = - FunctionExpr("round", evaluateRoundToPrecision, numericField, constant(decimalPlace)) + fun roundToPrecision(numericField: String, decimalPlace: Int): Expression = + FunctionExpression("round", evaluateRoundToPrecision, numericField, constant(decimalPlace)) /** * Creates an expression that rounds off [numericExpr] to [decimalPlace] decimal places if * [decimalPlace] is positive, rounds off digits to the left of the decimal point if * [decimalPlace] is negative. Rounds away from zero in halfway cases. * + * ```kotlin + * // Round the value of the 'price' field to the number of decimal places specified in the + * // 'precision' field. + * roundToPrecision(field("price"), field("precision")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. * @param decimalPlace The number of decimal places to round. - * @return A new [Expr] representing the round operation. + * @return A new [Expression] representing the round operation. */ @JvmStatic - fun roundToPrecision(numericExpr: Expr, decimalPlace: Expr): Expr = - FunctionExpr("round", evaluateRoundToPrecision, numericExpr, decimalPlace) + fun roundToPrecision(numericExpr: Expression, decimalPlace: Expression): Expression = + FunctionExpression("round", evaluateRoundToPrecision, numericExpr, decimalPlace) /** * Creates an expression that rounds off [numericField] to [decimalPlace] decimal places if * [decimalPlace] is positive, rounds off digits to the left of the decimal point if * [decimalPlace] is negative. Rounds away from zero in halfway cases. * + * ```kotlin + * // Round the value of the 'price' field to the number of decimal places specified in the + * // 'precision' field. + * roundToPrecision("price", field("precision")) + * ``` + * * @param numericField Name of field that returns number when evaluated. * @param decimalPlace The number of decimal places to round. - * @return A new [Expr] representing the round operation. + * @return A new [Expression] representing the round operation. */ @JvmStatic - fun roundToPrecision(numericField: String, decimalPlace: Expr): Expr = - FunctionExpr("round", evaluateRoundToPrecision, numericField, decimalPlace) + fun roundToPrecision(numericField: String, decimalPlace: Expression): Expression = + FunctionExpression("round", evaluateRoundToPrecision, numericField, decimalPlace) /** * Creates an expression that returns the smallest integer that isn't less than [numericExpr]. * + * ```kotlin + * // Compute the ceiling of the 'price' field. + * ceil(field("price")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing an integer result from the ceil operation. + * @return A new [Expression] representing an integer result from the ceil operation. */ - @JvmStatic fun ceil(numericExpr: Expr): Expr = FunctionExpr("ceil", evaluateCeil, numericExpr) + @JvmStatic + fun ceil(numericExpr: Expression): Expression = + FunctionExpression("ceil", evaluateCeil, numericExpr) /** * Creates an expression that returns the smallest integer that isn't less than [numericField]. * + * ```kotlin + * // Compute the ceiling of the 'price' field. + * ceil("price") + * ``` + * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing an integer result from the ceil operation. + * @return A new [Expression] representing an integer result from the ceil operation. */ @JvmStatic - fun ceil(numericField: String): Expr = FunctionExpr("ceil", evaluateCeil, numericField) + fun ceil(numericField: String): Expression = + FunctionExpression("ceil", evaluateCeil, numericField) /** * Creates an expression that returns the largest integer that is not greater than [numericExpr] - * . + * + * ```kotlin + * // Compute the floor of the 'price' field. + * floor(field("price")) + * ``` * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing an integer result from the floor operation. + * @return A new [Expression] representing an integer result from the floor operation. */ @JvmStatic - fun floor(numericExpr: Expr): Expr = FunctionExpr("floor", evaluateFloor, numericExpr) + fun floor(numericExpr: Expression): Expression = + FunctionExpression("floor", evaluateFloor, numericExpr) /** * Creates an expression that returns the largest integer that is not greater than * [numericField]. * + * ```kotlin + * // Compute the floor of the 'price' field. + * floor("price") + * ``` + * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing an integer result from the floor operation. + * @return A new [Expression] representing an integer result from the floor operation. */ @JvmStatic - fun floor(numericField: String): Expr = FunctionExpr("floor", evaluateFloor, numericField) + fun floor(numericField: String): Expression = + FunctionExpression("floor", evaluateFloor, numericField) /** * Creates an expression that returns the [numericExpr] raised to the power of the [exponent]. * Returns infinity on overflow and zero on underflow. * + * ```kotlin + * // Raise the value of the 'base' field to the power of 2. + * pow(field("base"), 2) + * ``` + * * @param numericExpr An expression that returns number when evaluated. * @param exponent The numeric power to raise the [numericExpr]. - * @return A new [Expr] representing a numeric result from raising [numericExpr] to the power of - * [exponent]. + * @return A new [Expression] representing a numeric result from raising [numericExpr] to the + * power of [exponent]. */ @JvmStatic - fun pow(numericExpr: Expr, exponent: Number): Expr = - FunctionExpr("pow", evaluatePow, numericExpr, constant(exponent)) + fun pow(numericExpr: Expression, exponent: Number): Expression = + FunctionExpression("pow", evaluatePow, numericExpr, constant(exponent)) /** * Creates an expression that returns the [numericField] raised to the power of the [exponent]. * Returns infinity on overflow and zero on underflow. * + * ```kotlin + * // Raise the value of the 'base' field to the power of 2. + * pow("base", 2) + * ``` + * * @param numericField Name of field that returns number when evaluated. * @param exponent The numeric power to raise the [numericField]. - * @return A new [Expr] representing a numeric result from raising [numericField] to the power - * of [exponent]. + * @return A new [Expression] representing a numeric result from raising [numericField] to the + * power of [exponent]. */ @JvmStatic - fun pow(numericField: String, exponent: Number): Expr = - FunctionExpr("pow", evaluatePow, numericField, constant(exponent)) + fun pow(numericField: String, exponent: Number): Expression = + FunctionExpression("pow", evaluatePow, numericField, constant(exponent)) /** * Creates an expression that returns the [numericExpr] raised to the power of the [exponent]. * Returns infinity on overflow and zero on underflow. * + * ```kotlin + * // Raise the value of the 'base' field to the power of the 'exponent' field. + * pow(field("base"), field("exponent")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. * @param exponent The numeric power to raise the [numericExpr]. - * @return A new [Expr] representing a numeric result from raising [numericExpr] to the power of - * [exponent]. + * @return A new [Expression] representing a numeric result from raising [numericExpr] to the + * power of [exponent]. */ @JvmStatic - fun pow(numericExpr: Expr, exponent: Expr): Expr = - FunctionExpr("pow", evaluatePow, numericExpr, exponent) + fun pow(numericExpr: Expression, exponent: Expression): Expression = + FunctionExpression("pow", evaluatePow, numericExpr, exponent) /** * Creates an expression that returns the [numericField] raised to the power of the [exponent]. * Returns infinity on overflow and zero on underflow. * + * ```kotlin + * // Raise the value of the 'base' field to the power of the 'exponent' field. + * pow("base", field("exponent")) + * ``` + * * @param numericField Name of field that returns number when evaluated. * @param exponent The numeric power to raise the [numericField]. - * @return A new [Expr] representing a numeric result from raising [numericField] to the power - * of [exponent]. + * @return A new [Expression] representing a numeric result from raising [numericField] to the + * power of [exponent]. */ @JvmStatic - fun pow(numericField: String, exponent: Expr): Expr = - FunctionExpr("pow", evaluatePow, numericField, exponent) + fun pow(numericField: String, exponent: Expression): Expression = + FunctionExpression("pow", evaluatePow, numericField, exponent) /** * Creates an expression that returns the absolute value of [numericExpr]. * + * ```kotlin + * // Get the absolute value of the 'change' field. + * abs(field("change")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the absolute value operation. + * @return A new [Expression] representing the numeric result of the absolute value operation. */ - @JvmStatic fun abs(numericExpr: Expr): Expr = FunctionExpr("abs", evaluateAbs, numericExpr) + @JvmStatic + fun abs(numericExpr: Expression): Expression = + FunctionExpression("abs", evaluateAbs, numericExpr) /** * Creates an expression that returns the absolute value of [numericField]. * + * ```kotlin + * // Get the absolute value of the 'change' field. + * abs("change") + * ``` + * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the absolute value operation. + * @return A new [Expression] representing the numeric result of the absolute value operation. */ - @JvmStatic fun abs(numericField: String): Expr = FunctionExpr("abs", evaluateAbs, numericField) + @JvmStatic + fun abs(numericField: String): Expression = FunctionExpression("abs", evaluateAbs, numericField) /** * Creates an expression that returns Euler's number e raised to the power of [numericExpr]. * + * ```kotlin + * // Compute e to the power of the 'value' field. + * exp(field("value")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the exponentiation. + * @return A new [Expression] representing the numeric result of the exponentiation. */ - @JvmStatic fun exp(numericExpr: Expr): Expr = FunctionExpr("exp", evaluateExp, numericExpr) + @JvmStatic + fun exp(numericExpr: Expression): Expression = + FunctionExpression("exp", evaluateExp, numericExpr) /** * Creates an expression that returns Euler's number e raised to the power of [numericField]. * + * ```kotlin + * // Compute e to the power of the 'value' field. + * exp("value") + * ``` + * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the exponentiation. + * @return A new [Expression] representing the numeric result of the exponentiation. */ - @JvmStatic fun exp(numericField: String): Expr = FunctionExpr("exp", evaluateExp, numericField) + @JvmStatic + fun exp(numericField: String): Expression = FunctionExpression("exp", evaluateExp, numericField) /** * Creates an expression that returns the natural logarithm (base e) of [numericExpr]. * + * ```kotlin + * // Compute the natural logarithm of the 'value' field. + * ln(field("value")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the natural logarithm. + * @return A new [Expression] representing the numeric result of the natural logarithm. */ - @JvmStatic fun ln(numericExpr: Expr): Expr = FunctionExpr("ln", evaluateLn, numericExpr) + @JvmStatic + fun ln(numericExpr: Expression): Expression = FunctionExpression("ln", evaluateLn, numericExpr) /** * Creates an expression that returns the natural logarithm (base e) of [numericField]. * + * ```kotlin + * // Compute the natural logarithm of the 'value' field. + * ln("value") + * ``` + * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the natural logarithm. + * @return A new [Expression] representing the numeric result of the natural logarithm. */ - @JvmStatic fun ln(numericField: String): Expr = FunctionExpr("ln", evaluateLn, numericField) + @JvmStatic + fun ln(numericField: String): Expression = FunctionExpression("ln", evaluateLn, numericField) /** * Creates an expression that returns the logarithm of [numericExpr] with a given [base]. * + * ```kotlin + * // Compute the logarithm of the 'value' field with base 10. + * log(field("value"), 10) + * ``` + * * @param numericExpr An expression that returns number when evaluated. * @param base The base of the logarithm. - * @return A new [Expr] representing a numeric result from the logarithm of [numericExpr] with a - * given [base]. + * @return A new [Expression] representing a numeric result from the logarithm of [numericExpr] + * with a given [base]. */ @JvmStatic - fun log(numericExpr: Expr, base: Number): Expr = - FunctionExpr("log", evaluateLog, numericExpr, constant(base)) + fun log(numericExpr: Expression, base: Number): Expression = + FunctionExpression("log", evaluateLog, numericExpr, constant(base)) /** * Creates an expression that returns the logarithm of [numericField] with a given [base]. * + * ```kotlin + * // Compute the logarithm of the 'value' field with base 10. + * log("value", 10) + * ``` + * * @param numericField Name of field that returns number when evaluated. * @param base The base of the logarithm. - * @return A new [Expr] representing a numeric result from the logarithm of [numericField] with - * a given [base]. + * @return A new [Expression] representing a numeric result from the logarithm of [numericField] + * with a given [base]. */ @JvmStatic - fun log(numericField: String, base: Number): Expr = - FunctionExpr("log", evaluateLog, numericField, constant(base)) + fun log(numericField: String, base: Number): Expression = + FunctionExpression("log", evaluateLog, numericField, constant(base)) /** * Creates an expression that returns the logarithm of [numericExpr] with a given [base]. * + * ```kotlin + * // Compute the logarithm of the 'value' field with the base in the 'base' field. + * log(field("value"), field("base")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. * @param base The base of the logarithm. - * @return A new [Expr] representing a numeric result from the logarithm of [numericExpr] with a - * given [base]. + * @return A new [Expression] representing a numeric result from the logarithm of [numericExpr] + * with a given [base]. */ @JvmStatic - fun log(numericExpr: Expr, base: Expr): Expr = - FunctionExpr("log", evaluateLog, numericExpr, base) + fun log(numericExpr: Expression, base: Expression): Expression = + FunctionExpression("log", evaluateLog, numericExpr, base) /** * Creates an expression that returns the logarithm of [numericField] with a given [base]. * + * ```kotlin + * // Compute the logarithm of the 'value' field with the base in the 'base' field. + * log("value", field("base")) + * ``` + * * @param numericField Name of field that returns number when evaluated. * @param base The base of the logarithm. - * @return A new [Expr] representing a numeric result from the logarithm of [numericField] with - * a given [base]. + * @return A new [Expression] representing a numeric result from the logarithm of [numericField] + * with a given [base]. */ @JvmStatic - fun log(numericField: String, base: Expr): Expr = - FunctionExpr("log", evaluateLog, numericField, base) + fun log(numericField: String, base: Expression): Expression = + FunctionExpression("log", evaluateLog, numericField, base) /** * Creates an expression that returns the base 10 logarithm of [numericExpr]. * + * ```kotlin + * // Compute the base 10 logarithm of the 'value' field. + * log10(field("value")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the base 10 logarithm. + * @return A new [Expression] representing the numeric result of the base 10 logarithm. */ @JvmStatic - fun log10(numericExpr: Expr): Expr = FunctionExpr("log10", evaluateLog10, numericExpr) + fun log10(numericExpr: Expression): Expression = + FunctionExpression("log10", evaluateLog10, numericExpr) /** * Creates an expression that returns the base 10 logarithm of [numericField]. * + * ```kotlin + * // Compute the base 10 logarithm of the 'value' field. + * log10("value") + * ``` + * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the base 10 logarithm. + * @return A new [Expression] representing the numeric result of the base 10 logarithm. */ @JvmStatic - fun log10(numericField: String): Expr = FunctionExpr("log10", evaluateLog10, numericField) + fun log10(numericField: String): Expression = + FunctionExpression("log10", evaluateLog10, numericField) /** * Creates an expression that returns the square root of [numericExpr]. * + * ```kotlin + * // Compute the square root of the 'value' field. + * sqrt(field("value")) + * ``` + * * @param numericExpr An expression that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the square root operation. + * @return A new [Expression] representing the numeric result of the square root operation. */ - @JvmStatic fun sqrt(numericExpr: Expr): Expr = FunctionExpr("sqrt", evaluateSqrt, numericExpr) + @JvmStatic + fun sqrt(numericExpr: Expression): Expression = + FunctionExpression("sqrt", evaluateSqrt, numericExpr) /** * Creates an expression that returns the square root of [numericField]. * + * ```kotlin + * // Compute the square root of the 'value' field. + * sqrt("value") + * ``` + * * @param numericField Name of field that returns number when evaluated. - * @return A new [Expr] representing the numeric result of the square root operation. + * @return A new [Expression] representing the numeric result of the square root operation. */ @JvmStatic - fun sqrt(numericField: String): Expr = FunctionExpr("sqrt", evaluateSqrt, numericField) + fun sqrt(numericField: String): Expression = + FunctionExpression("sqrt", evaluateSqrt, numericField) /** * Creates an expression that adds numeric expressions. * + * ```kotlin + * // Add the value of the 'quantity' field and the 'reserve' field. + * add(field("quantity"), field("reserve")) + * ``` + * * @param first Numeric expression to add. * @param second Numeric expression to add. - * @return A new [Expr] representing the addition operation. + * @return A new [Expression] representing the addition operation. */ @JvmStatic - fun add(first: Expr, second: Expr): Expr = FunctionExpr("add", evaluateAdd, first, second) + fun add(first: Expression, second: Expression): Expression = + FunctionExpression("add", evaluateAdd, first, second) /** * Creates an expression that adds numeric expressions with a constant. * + * ```kotlin + * // Add 5 to the value of the 'quantity' field. + * add(field("quantity"), 5) + * ``` + * * @param first Numeric expression to add. * @param second Constant to add. - * @return A new [Expr] representing the addition operation. + * @return A new [Expression] representing the addition operation. */ @JvmStatic - fun add(first: Expr, second: Number): Expr = FunctionExpr("add", evaluateAdd, first, second) + fun add(first: Expression, second: Number): Expression = + FunctionExpression("add", evaluateAdd, first, second) /** * Creates an expression that adds a numeric field with a numeric expression. * + * ```kotlin + * // Add the value of the 'quantity' field and the 'reserve' field. + * add("quantity", field("reserve")) + * ``` + * * @param numericFieldName Numeric field to add. * @param second Numeric expression to add to field value. - * @return A new [Expr] representing the addition operation. + * @return A new [Expression] representing the addition operation. */ @JvmStatic - fun add(numericFieldName: String, second: Expr): Expr = - FunctionExpr("add", evaluateAdd, numericFieldName, second) + fun add(numericFieldName: String, second: Expression): Expression = + FunctionExpression("add", evaluateAdd, numericFieldName, second) /** * Creates an expression that adds a numeric field with constant. * + * ```kotlin + * // Add 5 to the value of the 'quantity' field. + * add("quantity", 5) + * ``` + * * @param numericFieldName Numeric field to add. * @param second Constant to add. - * @return A new [Expr] representing the addition operation. + * @return A new [Expression] representing the addition operation. */ @JvmStatic - fun add(numericFieldName: String, second: Number): Expr = - FunctionExpr("add", evaluateAdd, numericFieldName, second) + fun add(numericFieldName: String, second: Number): Expression = + FunctionExpression("add", evaluateAdd, numericFieldName, second) /** * Creates an expression that subtracts two expressions. * + * ```kotlin + * // Subtract the 'discount' field from the 'price' field + * subtract(field("price"), field("discount")) + * ``` + * * @param minuend Numeric expression to subtract from. * @param subtrahend Numeric expression to subtract. - * @return A new [Expr] representing the subtract operation. + * @return A new [Expression] representing the subtract operation. */ @JvmStatic - fun subtract(minuend: Expr, subtrahend: Expr): Expr = - FunctionExpr("subtract", evaluateSubtract, minuend, subtrahend) + fun subtract(minuend: Expression, subtrahend: Expression): Expression = + FunctionExpression("subtract", evaluateSubtract, minuend, subtrahend) /** * Creates an expression that subtracts a constant value from a numeric expression. * + * ```kotlin + * // Subtract 10 from the 'price' field. + * subtract(field("price"), 10) + * ``` + * * @param minuend Numeric expression to subtract from. * @param subtrahend Constant to subtract. - * @return A new [Expr] representing the subtract operation. + * @return A new [Expression] representing the subtract operation. */ @JvmStatic - fun subtract(minuend: Expr, subtrahend: Number): Expr = - FunctionExpr("subtract", evaluateSubtract, minuend, subtrahend) + fun subtract(minuend: Expression, subtrahend: Number): Expression = + FunctionExpression("subtract", evaluateSubtract, minuend, subtrahend) /** * Creates an expression that subtracts a numeric expressions from numeric field. * + * ```kotlin + * // Subtract the 'discount' field from the 'price' field. + * subtract("price", field("discount")) + * ``` + * * @param numericFieldName Numeric field to subtract from. * @param subtrahend Numeric expression to subtract. - * @return A new [Expr] representing the subtract operation. + * @return A new [Expression] representing the subtract operation. */ @JvmStatic - fun subtract(numericFieldName: String, subtrahend: Expr): Expr = - FunctionExpr("subtract", evaluateSubtract, numericFieldName, subtrahend) + fun subtract(numericFieldName: String, subtrahend: Expression): Expression = + FunctionExpression("subtract", evaluateSubtract, numericFieldName, subtrahend) /** * Creates an expression that subtracts a constant from numeric field. * + * ```kotlin + * // Subtract 10 from the 'price' field. + * subtract("price", 10) + * ``` + * * @param numericFieldName Numeric field to subtract from. * @param subtrahend Constant to subtract. - * @return A new [Expr] representing the subtract operation. + * @return A new [Expression] representing the subtract operation. */ @JvmStatic - fun subtract(numericFieldName: String, subtrahend: Number): Expr = - FunctionExpr("subtract", evaluateSubtract, numericFieldName, subtrahend) + fun subtract(numericFieldName: String, subtrahend: Number): Expression = + FunctionExpression("subtract", evaluateSubtract, numericFieldName, subtrahend) /** * Creates an expression that multiplies numeric expressions. * + * ```kotlin + * // Multiply the 'quantity' field by the 'price' field + * multiply(field("quantity"), field("price")) + * ``` + * * @param first Numeric expression to multiply. * @param second Numeric expression to multiply. - * @return A new [Expr] representing the multiplication operation. + * @return A new [Expression] representing the multiplication operation. */ @JvmStatic - fun multiply(first: Expr, second: Expr): Expr = - FunctionExpr("multiply", evaluateMultiply, first, second) + fun multiply(first: Expression, second: Expression): Expression = + FunctionExpression("multiply", evaluateMultiply, first, second) /** * Creates an expression that multiplies numeric expressions with a constant. * + * ```kotlin + * // Multiply the 'quantity' field by 1.1. + * multiply(field("quantity"), 1.1) + * ``` + * * @param first Numeric expression to multiply. * @param second Constant to multiply. - * @return A new [Expr] representing the multiplication operation. + * @return A new [Expression] representing the multiplication operation. */ @JvmStatic - fun multiply(first: Expr, second: Number): Expr = - FunctionExpr("multiply", evaluateMultiply, first, second) + fun multiply(first: Expression, second: Number): Expression = + FunctionExpression("multiply", evaluateMultiply, first, second) /** * Creates an expression that multiplies a numeric field with a numeric expression. * + * ```kotlin + * // Multiply the 'quantity' field by the 'price' field. + * multiply("quantity", field("price")) + * ``` + * * @param numericFieldName Numeric field to multiply. * @param second Numeric expression to multiply. - * @return A new [Expr] representing the multiplication operation. + * @return A new [Expression] representing the multiplication operation. */ @JvmStatic - fun multiply(numericFieldName: String, second: Expr): Expr = - FunctionExpr("multiply", evaluateMultiply, numericFieldName, second) + fun multiply(numericFieldName: String, second: Expression): Expression = + FunctionExpression("multiply", evaluateMultiply, numericFieldName, second) /** * Creates an expression that multiplies a numeric field with a constant. * + * ```kotlin + * // Multiply the 'quantity' field by 1.1. + * multiply("quantity", 1.1) + * ``` + * * @param numericFieldName Numeric field to multiply. * @param second Constant to multiply. - * @return A new [Expr] representing the multiplication operation. + * @return A new [Expression] representing the multiplication operation. */ @JvmStatic - fun multiply(numericFieldName: String, second: Number): Expr = - FunctionExpr("multiply", evaluateMultiply, numericFieldName, second) + fun multiply(numericFieldName: String, second: Number): Expression = + FunctionExpression("multiply", evaluateMultiply, numericFieldName, second) /** * Creates an expression that divides two numeric expressions. * + * ```kotlin + * // Divide the 'total' field by the 'count' field + * divide(field("total"), field("count")) + * ``` + * * @param dividend The numeric expression to be divided. * @param divisor The numeric expression to divide by. - * @return A new [Expr] representing the division operation. + * @return A new [Expression] representing the division operation. */ @JvmStatic - fun divide(dividend: Expr, divisor: Expr): Expr = - FunctionExpr("divide", evaluateDivide, dividend, divisor) + fun divide(dividend: Expression, divisor: Expression): Expression = + FunctionExpression("divide", evaluateDivide, dividend, divisor) /** * Creates an expression that divides a numeric expression by a constant. * + * ```kotlin + * // Divide the 'value' field by 10 + * divide(field("value"), 10) + * ``` + * * @param dividend The numeric expression to be divided. * @param divisor The constant to divide by. - * @return A new [Expr] representing the division operation. + * @return A new [Expression] representing the division operation. */ @JvmStatic - fun divide(dividend: Expr, divisor: Number): Expr = - FunctionExpr("divide", evaluateDivide, dividend, divisor) + fun divide(dividend: Expression, divisor: Number): Expression = + FunctionExpression("divide", evaluateDivide, dividend, divisor) /** * Creates an expression that divides numeric field by a numeric expression. * + * ```kotlin + * // Divide the 'total' field by the 'count' field. + * divide("total", field("count")) + * ``` + * * @param dividendFieldName The numeric field name to be divided. * @param divisor The numeric expression to divide by. - * @return A new [Expr] representing the divide operation. + * @return A new [Expression] representing the divide operation. */ @JvmStatic - fun divide(dividendFieldName: String, divisor: Expr): Expr = - FunctionExpr("divide", evaluateDivide, dividendFieldName, divisor) + fun divide(dividendFieldName: String, divisor: Expression): Expression = + FunctionExpression("divide", evaluateDivide, dividendFieldName, divisor) /** * Creates an expression that divides a numeric field by a constant. * + * ```kotlin + * // Divide the 'total' field by 2. + * divide("total", 2) + * ``` + * * @param dividendFieldName The numeric field name to be divided. * @param divisor The constant to divide by. - * @return A new [Expr] representing the divide operation. + * @return A new [Expression] representing the divide operation. */ @JvmStatic - fun divide(dividendFieldName: String, divisor: Number): Expr = - FunctionExpr("divide", evaluateDivide, dividendFieldName, divisor) + fun divide(dividendFieldName: String, divisor: Number): Expression = + FunctionExpression("divide", evaluateDivide, dividendFieldName, divisor) /** * Creates an expression that calculates the modulo (remainder) of dividing two numeric * expressions. * + * ```kotlin + * // Calculate the remainder of dividing the 'value' field by the 'divisor' field + * mod(field("value"), field("divisor")) + * ``` + * * @param dividend The numeric expression to be divided. * @param divisor The numeric expression to divide by. - * @return A new [Expr] representing the modulo operation. + * @return A new [Expression] representing the modulo operation. */ @JvmStatic - fun mod(dividend: Expr, divisor: Expr): Expr = - FunctionExpr("mod", evaluateMod, dividend, divisor) + fun mod(dividend: Expression, divisor: Expression): Expression = + FunctionExpression("mod", evaluateMod, dividend, divisor) /** * Creates an expression that calculates the modulo (remainder) of dividing a numeric expression * by a constant. * + * ```kotlin + * // Calculate the remainder of dividing the 'value' field by 3. + * mod(field("value"), 3) + * ``` + * * @param dividend The numeric expression to be divided. * @param divisor The constant to divide by. - * @return A new [Expr] representing the modulo operation. + * @return A new [Expression] representing the modulo operation. */ @JvmStatic - fun mod(dividend: Expr, divisor: Number): Expr = - FunctionExpr("mod", evaluateMod, dividend, divisor) + fun mod(dividend: Expression, divisor: Number): Expression = + FunctionExpression("mod", evaluateMod, dividend, divisor) /** * Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a * constant. * + * ```kotlin + * // Calculate the remainder of dividing the 'value' field by the 'divisor' field. + * mod("value", field("divisor")) + * ``` + * * @param dividendFieldName The numeric field name to be divided. * @param divisor The numeric expression to divide by. - * @return A new [Expr] representing the modulo operation. + * @return A new [Expression] representing the modulo operation. */ @JvmStatic - fun mod(dividendFieldName: String, divisor: Expr): Expr = - FunctionExpr("mod", evaluateMod, dividendFieldName, divisor) + fun mod(dividendFieldName: String, divisor: Expression): Expression = + FunctionExpression("mod", evaluateMod, dividendFieldName, divisor) /** * Creates an expression that calculates the modulo (remainder) of dividing a numeric field by a * constant. * + * ```kotlin + * // Calculate the remainder of dividing the 'value' field by 3. + * mod("value", 3) + * ``` + * * @param dividendFieldName The numeric field name to be divided. * @param divisor The constant to divide by. - * @return A new [Expr] representing the modulo operation. + * @return A new [Expression] representing the modulo operation. */ @JvmStatic - fun mod(dividendFieldName: String, divisor: Number): Expr = - FunctionExpr("mod", evaluateMod, dividendFieldName, divisor) + fun mod(dividendFieldName: String, divisor: Number): Expression = + FunctionExpression("mod", evaluateMod, dividendFieldName, divisor) /** * Creates an expression that checks if an [expression], when evaluated, is equal to any of the * provided [values]. * + * ```kotlin + * // Check if the 'category' field is either "Electronics" or the value of the 'primaryType' field. + * equalAny(field("category"), listOf("Electronics", field("primaryType"))) + * ``` + * * @param expression The expression whose results to compare. * @param values The values to check against. - * @return A new [BooleanExpr] representing the 'IN' comparison. + * @return A new [BooleanExpression] representing the 'IN' comparison. */ @JvmStatic - fun eqAny(expression: Expr, values: List): BooleanExpr = eqAny(expression, array(values)) + fun equalAny(expression: Expression, values: List): BooleanExpression = + equalAny(expression, array(values)) /** * Creates an expression that checks if an [expression], when evaluated, is equal to any of the * elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'category' field is in the 'availableCategories' array field. + * equalAny(field("category"), field("availableCategories")) + * ``` + * * @param expression The expression whose results to compare. * @param arrayExpression An expression that evaluates to an array, whose elements to check for * equality to the input. - * @return A new [BooleanExpr] representing the 'IN' comparison. + * @return A new [BooleanExpression] representing the 'IN' comparison. */ @JvmStatic - fun eqAny(expression: Expr, arrayExpression: Expr): BooleanExpr = - BooleanExpr("eq_any", evaluateEqAny, expression, arrayExpression) + fun equalAny(expression: Expression, arrayExpression: Expression): BooleanExpression = + BooleanExpression("equal_any", evaluateEqAny, expression, arrayExpression) /** * Creates an expression that checks if a field's value is equal to any of the provided [values] * . * + * ```kotlin + * // Check if the 'category' field is either "Electronics" or "Apparel". + * equalAny("category", listOf("Electronics", "Apparel")) + * ``` + * * @param fieldName The field to compare. * @param values The values to check against. - * @return A new [BooleanExpr] representing the 'IN' comparison. + * @return A new [BooleanExpression] representing the 'IN' comparison. */ @JvmStatic - fun eqAny(fieldName: String, values: List): BooleanExpr = eqAny(fieldName, array(values)) + fun equalAny(fieldName: String, values: List): BooleanExpression = + equalAny(fieldName, array(values)) /** * Creates an expression that checks if a field's value is equal to any of the elements of * [arrayExpression]. * + * ```kotlin + * // Check if the 'category' field is in the 'availableCategories' array field. + * equalAny("category", field("availableCategories")) + * ``` + * * @param fieldName The field to compare. * @param arrayExpression An expression that evaluates to an array, whose elements to check for * equality to the input. - * @return A new [BooleanExpr] representing the 'IN' comparison. + * @return A new [BooleanExpression] representing the 'IN' comparison. */ @JvmStatic - fun eqAny(fieldName: String, arrayExpression: Expr): BooleanExpr = - BooleanExpr("eq_any", evaluateEqAny, fieldName, arrayExpression) + fun equalAny(fieldName: String, arrayExpression: Expression): BooleanExpression = + BooleanExpression("equal_any", evaluateEqAny, fieldName, arrayExpression) /** * Creates an expression that checks if an [expression], when evaluated, is not equal to all the * provided [values]. * + * ```kotlin + * // Check if the 'status' field is neither "pending" nor the value of the 'rejectedStatus' field. + * notEqualAny(field("status"), listOf("pending", field("rejectedStatus"))) + * ``` + * * @param expression The expression whose results to compare. * @param values The values to check against. - * @return A new [BooleanExpr] representing the 'NOT IN' comparison. + * @return A new [BooleanExpression] representing the 'NOT IN' comparison. */ @JvmStatic - fun notEqAny(expression: Expr, values: List): BooleanExpr = - notEqAny(expression, array(values)) + fun notEqualAny(expression: Expression, values: List): BooleanExpression = + notEqualAny(expression, array(values)) /** * Creates an expression that checks if an [expression], when evaluated, is not equal to all the * elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'status' field is not in the 'inactiveStatuses' array field. + * notEqualAny(field("status"), field("inactiveStatuses")) + * ``` + * * @param expression The expression whose results to compare. * @param arrayExpression An expression that evaluates to an array, whose elements to check for * equality to the input. - * @return A new [BooleanExpr] representing the 'NOT IN' comparison. + * @return A new [BooleanExpression] representing the 'NOT IN' comparison. */ @JvmStatic - fun notEqAny(expression: Expr, arrayExpression: Expr): BooleanExpr = - BooleanExpr("not_eq_any", evaluateNotEqAny, expression, arrayExpression) + fun notEqualAny(expression: Expression, arrayExpression: Expression): BooleanExpression = + BooleanExpression("not_equal_any", evaluateNotEqAny, expression, arrayExpression) /** * Creates an expression that checks if a field's value is not equal to all of the provided * [values]. * + * ```kotlin + * // Check if the 'status' field is not "archived" or "deleted". + * notEqualAny("status", listOf("archived", "deleted")) + * ``` + * * @param fieldName The field to compare. * @param values The values to check against. - * @return A new [BooleanExpr] representing the 'NOT IN' comparison. + * @return A new [BooleanExpression] representing the 'NOT IN' comparison. */ @JvmStatic - fun notEqAny(fieldName: String, values: List): BooleanExpr = - notEqAny(fieldName, array(values)) + fun notEqualAny(fieldName: String, values: List): BooleanExpression = + notEqualAny(fieldName, array(values)) /** * Creates an expression that checks if a field's value is not equal to all of the elements of * [arrayExpression]. * + * ```kotlin + * // Check if the 'status' field is not in the 'inactiveStatuses' array field. + * notEqualAny("status", field("inactiveStatuses")) + * ``` + * * @param fieldName The field to compare. * @param arrayExpression An expression that evaluates to an array, whose elements to check for * equality to the input. - * @return A new [BooleanExpr] representing the 'NOT IN' comparison. + * @return A new [BooleanExpression] representing the 'NOT IN' comparison. */ @JvmStatic - fun notEqAny(fieldName: String, arrayExpression: Expr): BooleanExpr = - BooleanExpr("not_eq_any", evaluateNotEqAny, fieldName, arrayExpression) + fun notEqualAny(fieldName: String, arrayExpression: Expression): BooleanExpression = + BooleanExpression("not_equal_any", evaluateNotEqAny, fieldName, arrayExpression) /** * Creates an expression that returns true if a value is absent. Otherwise, returns false even * if the value is null. * + * ```kotlin + * // Check if the field `value` is absent. + * isAbsent(field("value")) + * ``` + * * @param value The expression to check. - * @return A new [BooleanExpr] representing the isAbsent operation. + * @return A new [BooleanExpression] representing the isAbsent operation. */ @JvmStatic - fun isAbsent(value: Expr): BooleanExpr = BooleanExpr("is_absent", evaluateIsAbsent, value) + fun isAbsent(value: Expression): BooleanExpression = + BooleanExpression("is_absent", evaluateIsAbsent, value) /** * Creates an expression that returns true if a field is absent. Otherwise, returns false even * if the field value is null. * + * ```kotlin + * // Check if the field `value` is absent. + * isAbsent("value") + * ``` + * * @param fieldName The field to check. - * @return A new [BooleanExpr] representing the isAbsent operation. + * @return A new [BooleanExpression] representing the isAbsent operation. */ @JvmStatic - fun isAbsent(fieldName: String): BooleanExpr = - BooleanExpr("is_absent", evaluateIsAbsent, fieldName) + fun isAbsent(fieldName: String): BooleanExpression = + BooleanExpression("is_absent", evaluateIsAbsent, fieldName) /** * Creates an expression that checks if an expression evaluates to 'NaN' (Not a Number). * + * ```kotlin + * // Check if the result of a calculation is NaN + * isNan(divide("value", 0)) + * ``` + * * @param expr The expression to check. - * @return A new [BooleanExpr] representing the isNan operation. + * @return A new [BooleanExpression] representing the isNan operation. */ - @JvmStatic fun isNan(expr: Expr): BooleanExpr = BooleanExpr("is_nan", evaluateIsNaN, expr) + @JvmStatic + fun isNan(expr: Expression): BooleanExpression = + BooleanExpression("is_nan", evaluateIsNaN, expr) /** * Creates an expression that checks if the field's value evaluates to 'NaN' (Not a Number). * + * ```kotlin + * // Check if the value of a field is NaN + * isNan("value") + * ``` + * * @param fieldName The field to check. - * @return A new [BooleanExpr] representing the isNan operation. + * @return A new [BooleanExpression] representing the isNan operation. */ @JvmStatic - fun isNan(fieldName: String): BooleanExpr = BooleanExpr("is_nan", evaluateIsNaN, fieldName) + fun isNan(fieldName: String): BooleanExpression = + BooleanExpression("is_nan", evaluateIsNaN, fieldName) /** * Creates an expression that checks if the results of [expr] is NOT 'NaN' (Not a Number). * + * ```kotlin + * // Check if the result of a calculation is NOT NaN + * isNotNan(divide("value", 0)) + * ``` + * * @param expr The expression to check. - * @return A new [BooleanExpr] representing the isNotNan operation. + * @return A new [BooleanExpression] representing the isNotNan operation. */ @JvmStatic - fun isNotNan(expr: Expr): BooleanExpr = BooleanExpr("is_not_nan", evaluateIsNotNaN, expr) + fun isNotNan(expr: Expression): BooleanExpression = + BooleanExpression("is_not_nan", evaluateIsNotNaN, expr) /** * Creates an expression that checks if the field's value is NOT 'NaN' (Not a Number). * + * ```kotlin + * // Check if the value of a field is NOT NaN + * isNotNan("value") + * ``` + * * @param fieldName The field to check. - * @return A new [BooleanExpr] representing the isNotNan operation. + * @return A new [BooleanExpression] representing the isNotNan operation. */ @JvmStatic - fun isNotNan(fieldName: String): BooleanExpr = - BooleanExpr("is_not_nan", evaluateIsNotNaN, fieldName) + fun isNotNan(fieldName: String): BooleanExpression = + BooleanExpression("is_not_nan", evaluateIsNotNaN, fieldName) /** * Creates an expression that checks if the result of [expr] is null. * + * ```kotlin + * // Check if the value of the 'name' field is null + * isNull("name") + * ``` + * * @param expr The expression to check. - * @return A new [BooleanExpr] representing the isNull operation. + * @return A new [BooleanExpression] representing the isNull operation. */ - @JvmStatic fun isNull(expr: Expr): BooleanExpr = BooleanExpr("is_null", evaluateIsNull, expr) + @JvmStatic + fun isNull(expr: Expression): BooleanExpression = + BooleanExpression("is_null", evaluateIsNull, expr) /** * Creates an expression that checks if the value of a field is null. * + * ```kotlin + * // Check if the value of the 'name' field is null + * isNull("name") + * ``` + * * @param fieldName The field to check. - * @return A new [BooleanExpr] representing the isNull operation. + * @return A new [BooleanExpression] representing the isNull operation. */ @JvmStatic - fun isNull(fieldName: String): BooleanExpr = BooleanExpr("is_null", evaluateIsNull, fieldName) + fun isNull(fieldName: String): BooleanExpression = + BooleanExpression("is_null", evaluateIsNull, fieldName) /** * Creates an expression that checks if the result of [expr] is not null. * + * ```kotlin + * // Check if the value of the 'name' field is not null + * isNotNull(field("name")) + * ``` + * * @param expr The expression to check. - * @return A new [BooleanExpr] representing the isNotNull operation. + * @return A new [BooleanExpression] representing the isNotNull operation. */ @JvmStatic - fun isNotNull(expr: Expr): BooleanExpr = BooleanExpr("is_not_null", evaluateIsNotNull, expr) + fun isNotNull(expr: Expression): BooleanExpression = + BooleanExpression("is_not_null", evaluateIsNotNull, expr) /** * Creates an expression that checks if the value of a field is not null. * + * ```kotlin + * // Check if the value of the 'name' field is not null + * isNotNull("name") + * ``` + * * @param fieldName The field to check. - * @return A new [BooleanExpr] representing the isNotNull operation. + * @return A new [BooleanExpression] representing the isNotNull operation. */ @JvmStatic - fun isNotNull(fieldName: String): BooleanExpr = - BooleanExpr("is_not_null", evaluateIsNotNull, fieldName) + fun isNotNull(fieldName: String): BooleanExpression = + BooleanExpression("is_not_null", evaluateIsNotNull, fieldName) /** - * Creates an expression that replaces the first occurrence of a substring within the - * [stringExpression]. + * Creates an expression that calculates the length of a string, array, map, vector, or blob + * expression. * - * @param stringExpression The expression representing the string to perform the replacement on. - * @param find The expression representing the substring to search for in [stringExpression]. - * @param replace The expression representing the replacement for the first occurrence of [find] - * . - * @return A new [Expr] representing the string with the first occurrence replaced. - */ - @JvmStatic - fun replaceFirst(stringExpression: Expr, find: Expr, replace: Expr): Expr = - FunctionExpr("replace_first", evaluateReplaceFirst, stringExpression, find, replace) - - /** - * Creates an expression that replaces the first occurrence of a substring within the - * [stringExpression]. + * ```kotlin + * // Get the length of the 'value' field where the value type can be any of a string, array, map, vector or blob. + * length(field("value")) + * ``` * - * @param stringExpression The expression representing the string to perform the replacement on. - * @param find The substring to search for in [stringExpression]. - * @param replace The replacement for the first occurrence of [find] with. - * @return A new [Expr] representing the string with the first occurrence replaced. + * @param expr The expression representing the string. + * @return A new [Expression] representing the length operation. */ @JvmStatic - fun replaceFirst(stringExpression: Expr, find: String, replace: String): Expr = - FunctionExpr("replace_first", evaluateReplaceFirst, stringExpression, find, replace) + fun length(expr: Expression): Expression = FunctionExpression("length", notImplemented, expr) /** - * Creates an expression that replaces the first occurrence of a substring within the specified - * string field. - * - * @param fieldName The name of the field representing the string to perform the replacement on. - * @param find The expression representing the substring to search for in specified string + * Creates an expression that calculates the length of a string, array, map, vector, or blob * field. - * @param replace The expression representing the replacement for the first occurrence of [find] - * with. - * @return A new [Expr] representing the string with the first occurrence replaced. - */ - @JvmStatic - fun replaceFirst(fieldName: String, find: Expr, replace: Expr): Expr = - FunctionExpr("replace_first", evaluateReplaceFirst, fieldName, find, replace) - - /** - * Creates an expression that replaces the first occurrence of a substring within the specified - * string field. * - * @param fieldName The name of the field representing the string to perform the replacement on. - * @param find The substring to search for in specified string field. - * @param replace The replacement for the first occurrence of [find] with. - * @return A new [Expr] representing the string with the first occurrence replaced. + * ```kotlin + * // Get the length of the 'value' field where the value type can be any of a string, array, map, vector or blob. + * charLength("value") + * ``` + * + * @param fieldName The name of the field containing the string. + * @return A new [Expression] representing the length operation. */ @JvmStatic - fun replaceFirst(fieldName: String, find: String, replace: String): Expr = - FunctionExpr("replace_first", evaluateReplaceFirst, fieldName, find, replace) + fun length(fieldName: String): Expression = + FunctionExpression("length", notImplemented, fieldName) /** - * Creates an expression that replaces all occurrences of a substring within the - * [stringExpression]. + * Creates an expression that calculates the character length of a string expression in UTF8. * - * @param stringExpression The expression representing the string to perform the replacement on. - * @param find The expression representing the substring to search for in [stringExpression]. - * @param replace The expression representing the replacement for all occurrences of [find]. - * @return A new [Expr] representing the string with all occurrences replaced. + * ```kotlin + * // Get the character length of the 'name' field in UTF-8. + * charLength("name") + * ``` + * + * @param expr The expression representing the string. + * @return A new [Expression] representing the charLength operation. */ @JvmStatic - fun replaceAll(stringExpression: Expr, find: Expr, replace: Expr): Expr = - FunctionExpr("replace_all", evaluateReplaceAll, stringExpression, find, replace) + fun charLength(expr: Expression): Expression = + FunctionExpression("char_length", evaluateCharLength, expr) /** - * Creates an expression that replaces all occurrences of a substring within the - * [stringExpression]. + * Creates an expression that calculates the character length of a string field in UTF8. + * + * ```kotlin + * // Get the character length of the 'name' field in UTF-8. + * charLength("name") + * ``` * - * @param stringExpression The expression representing the string to perform the replacement on. - * @param find The substring to search for in [stringExpression]. - * @param replace The replacement for all occurrences of [find] with. - * @return A new [Expr] representing the string with all occurrences replaced. + * @param fieldName The name of the field containing the string. + * @return A new [Expression] representing the charLength operation. */ @JvmStatic - fun replaceAll(stringExpression: Expr, find: String, replace: String): Expr = - FunctionExpr("replace_all", evaluateReplaceAll, stringExpression, find, replace) + fun charLength(fieldName: String): Expression = + FunctionExpression("char_length", evaluateCharLength, fieldName) /** - * Creates an expression that replaces all occurrences of a substring within the specified - * string field. + * Creates an expression that calculates the length of a string in UTF-8 bytes, or just the + * length of a Blob. * - * @param fieldName The name of the field representing the string to perform the replacement on. - * @param find The expression representing the substring to search for in specified string - * field. - * @param replace The expression representing the replacement for all occurrences of [find] - * with. - * @return A new [Expr] representing the string with all occurrences replaced. + * ```kotlin + * // Calculate the length of the 'myString' field in bytes. + * byteLength("myString") + * ``` + * + * @param value The expression representing the string. + * @return A new [Expression] representing the length of the string in bytes. */ @JvmStatic - fun replaceAll(fieldName: String, find: Expr, replace: Expr): Expr = - FunctionExpr("replace_all", evaluateReplaceAll, fieldName, find, replace) + fun byteLength(value: Expression): Expression = + FunctionExpression("byte_length", evaluateByteLength, value) /** - * Creates an expression that replaces all occurrences of a substring within the specified - * string field. + * Creates an expression that calculates the length of a string represented by a field in UTF-8 + * bytes, or just the length of a Blob. * - * @param fieldName The name of the field representing the string to perform the replacement on. - * @param find The substring to search for in specified string field. - * @param replace The replacement for all occurrences of [find] with. - * @return A new [Expr] representing the string with all occurrences replaced. + * ```kotlin + * // Calculate the length of the 'myString' field in bytes. + * byteLength("myString") + * ``` + * + * @param fieldName The name of the field containing the string. + * @return A new [Expression] representing the length of the string in bytes. */ @JvmStatic - fun replaceAll(fieldName: String, find: String, replace: String): Expr = - FunctionExpr("replace_all", evaluateReplaceAll, fieldName, find, replace) + fun byteLength(fieldName: String): Expression = + FunctionExpression("byte_length", evaluateByteLength, fieldName) /** - * Creates an expression that calculates the character length of a string expression in UTF8. + * Creates an expression that performs a case-sensitive wildcard string comparison. * - * @param expr The expression representing the string. - * @return A new [Expr] representing the charLength operation. + * ```kotlin + * // Check if the 'title' field contains the string "guide" + * like(field("title"), "%guide%") + * ``` + * + * @param stringExpression The expression representing the string to perform the comparison on. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new [BooleanExpression] representing the like operation. */ @JvmStatic - fun charLength(expr: Expr): Expr = FunctionExpr("char_length", evaluateCharLength, expr) + fun like(stringExpression: Expression, pattern: Expression): BooleanExpression = + BooleanExpression("like", evaluateLike, stringExpression, pattern) /** - * Creates an expression that calculates the character length of a string field in UTF8. + * Creates an expression that joins the elements of an array into a string. * - * @param fieldName The name of the field containing the string. - * @return A new [Expr] representing the charLength operation. + * ```kotlin + * // Join the elements of the 'tags' field with a comma and space. + * join(field("tags"), ", ") + * ``` + * + * @param arrayExpression The expression that evaluates to an array. + * @param delimiter The string to use as a delimiter. + * @return A new [Expression] representing the join operation. */ @JvmStatic - fun charLength(fieldName: String): Expr = - FunctionExpr("char_length", evaluateCharLength, fieldName) + fun join(arrayExpression: Expression, delimiter: String): Expression = + FunctionExpression("join", notImplemented, arrayExpression, constant(delimiter)) /** - * Creates an expression that calculates the length of a string in UTF-8 bytes, or just the - * length of a Blob. + * Creates an expression that joins the elements of an array into a string. * - * @param value The expression representing the string. - * @return A new [Expr] representing the length of the string in bytes. + * ```kotlin + * // Join the elements of the 'tags' field with the delimiter from the 'separator' field. + * join(field("tags"), field("separator")) + * ``` + * + * @param arrayExpression The expression that evaluates to an array. + * @param delimiterExpression The expression that evaluates to the delimiter string. + * @return A new [Expression] representing the join operation. */ @JvmStatic - fun byteLength(value: Expr): Expr = FunctionExpr("byte_length", evaluateByteLength, value) + fun join(arrayExpression: Expression, delimiterExpression: Expression): Expression = + FunctionExpression("join", notImplemented, arrayExpression, delimiterExpression) /** - * Creates an expression that calculates the length of a string represented by a field in UTF-8 - * bytes, or just the length of a Blob. + * Creates an expression that joins the elements of an array field into a string. * - * @param fieldName The name of the field containing the string. - * @return A new [Expr] representing the length of the string in bytes. + * ```kotlin + * // Join the elements of the 'tags' field with a comma and space. + * join("tags", ", ") + * ``` + * + * @param arrayFieldName The name of the field containing the array. + * @param delimiter The string to use as a delimiter. + * @return A new [Expression] representing the join operation. */ @JvmStatic - fun byteLength(fieldName: String): Expr = - FunctionExpr("byte_length", evaluateByteLength, fieldName) + fun join(arrayFieldName: String, delimiter: String): Expression = + FunctionExpression("join", notImplemented, arrayFieldName, constant(delimiter)) /** - * Creates an expression that performs a case-sensitive wildcard string comparison. + * Creates an expression that joins the elements of an array field into a string. * - * @param stringExpression The expression representing the string to perform the comparison on. - * @param pattern The pattern to search for. You can use "%" as a wildcard character. - * @return A new [BooleanExpr] representing the like operation. + * ```kotlin + * // Join the elements of the 'tags' field with the delimiter from the 'separator' field. + * join("tags", field("separator")) + * ``` + * + * @param arrayFieldName The name of the field containing the array. + * @param delimiterExpression The expression that evaluates to the delimiter string. + * @return A new [Expression] representing the join operation. */ @JvmStatic - fun like(stringExpression: Expr, pattern: Expr): BooleanExpr = - BooleanExpr("like", evaluateLike, stringExpression, pattern) + fun join(arrayFieldName: String, delimiterExpression: Expression): Expression = + FunctionExpression("join", notImplemented, arrayFieldName, delimiterExpression) /** * Creates an expression that performs a case-sensitive wildcard string comparison. * + * ```kotlin + * // Check if the 'title' field contains the string "guide" + * like(field("title"), "%guide%") + * ``` + * * @param stringExpression The expression representing the string to perform the comparison on. * @param pattern The pattern to search for. You can use "%" as a wildcard character. - * @return A new [BooleanExpr] representing the like operation. + * @return A new [BooleanExpression] representing the like operation. */ @JvmStatic - fun like(stringExpression: Expr, pattern: String): BooleanExpr = - BooleanExpr("like", evaluateLike, stringExpression, pattern) + fun like(stringExpression: Expression, pattern: String): BooleanExpression = + BooleanExpression("like", evaluateLike, stringExpression, pattern) /** * Creates an expression that performs a case-sensitive wildcard string comparison against a * field. * + * ```kotlin + * // Check if the 'title' field contains the string "guide" + * like("title", "%guide%") + * ``` + * * @param fieldName The name of the field containing the string. * @param pattern The pattern to search for. You can use "%" as a wildcard character. - * @return A new [BooleanExpr] representing the like comparison. + * @return A new [BooleanExpression] representing the like comparison. */ @JvmStatic - fun like(fieldName: String, pattern: Expr): BooleanExpr = - BooleanExpr("like", evaluateLike, fieldName, pattern) + fun like(fieldName: String, pattern: Expression): BooleanExpression = + BooleanExpression("like", evaluateLike, fieldName, pattern) /** * Creates an expression that performs a case-sensitive wildcard string comparison against a * field. * + * ```kotlin + * // Check if the 'title' field contains the string "guide" + * like("title", "%guide%") + * ``` + * * @param fieldName The name of the field containing the string. * @param pattern The pattern to search for. You can use "%" as a wildcard character. - * @return A new [BooleanExpr] representing the like comparison. + * @return A new [BooleanExpression] representing the like comparison. */ @JvmStatic - fun like(fieldName: String, pattern: String): BooleanExpr = - BooleanExpr("like", evaluateLike, fieldName, pattern) + fun like(fieldName: String, pattern: String): BooleanExpression = + BooleanExpression("like", evaluateLike, fieldName, pattern) /** * Creates an expression that returns a pseudo-random number of type double in the range of [0, * 1), inclusive of 0 and exclusive of 1. * - * @return A new [Expr] representing the random number operation. + * ```kotlin + * // Get a random number. + * rand() + * ``` + * + * @return A new [Expression] representing the random number operation. */ - @JvmStatic fun rand(): Expr = FunctionExpr("rand", notImplemented) + @JvmStatic internal fun rand(): Expression = FunctionExpression("rand", notImplemented) /** * Creates an expression that checks if a string expression contains a specified regular * expression as a substring. * + * ```kotlin + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains(field("description"), "(?i)example") + * ``` + * * @param stringExpression The expression representing the string to perform the comparison on. * @param pattern The regular expression to use for the search. - * @return A new [BooleanExpr] representing the contains regular expression comparison. + * @return A new [BooleanExpression] representing the contains regular expression comparison. */ @JvmStatic - fun regexContains(stringExpression: Expr, pattern: Expr): BooleanExpr = - BooleanExpr("regex_contains", evaluateRegexContains, stringExpression, pattern) + fun regexContains(stringExpression: Expression, pattern: Expression): BooleanExpression = + BooleanExpression("regex_contains", evaluateRegexContains, stringExpression, pattern) /** * Creates an expression that checks if a string expression contains a specified regular * expression as a substring. * + * ```kotlin + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains(field("description"), "(?i)example") + * ``` + * * @param stringExpression The expression representing the string to perform the comparison on. * @param pattern The regular expression to use for the search. - * @return A new [BooleanExpr] representing the contains regular expression comparison. + * @return A new [BooleanExpression] representing the contains regular expression comparison. */ @JvmStatic - fun regexContains(stringExpression: Expr, pattern: String): BooleanExpr = - BooleanExpr("regex_contains", evaluateRegexContains, stringExpression, pattern) + fun regexContains(stringExpression: Expression, pattern: String): BooleanExpression = + BooleanExpression("regex_contains", evaluateRegexContains, stringExpression, pattern) /** * Creates an expression that checks if a string field contains a specified regular expression * as a substring. * + * ```kotlin + * // Check if the 'description' field contains the regex from the 'pattern' field. + * regexContains("description", field("pattern")) + * ``` + * * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the search. - * @return A new [BooleanExpr] representing the contains regular expression comparison. + * @return A new [BooleanExpression] representing the contains regular expression comparison. */ @JvmStatic - fun regexContains(fieldName: String, pattern: Expr) = - BooleanExpr("regex_contains", evaluateRegexContains, fieldName, pattern) + fun regexContains(fieldName: String, pattern: Expression) = + BooleanExpression("regex_contains", evaluateRegexContains, fieldName, pattern) /** * Creates an expression that checks if a string field contains a specified regular expression * as a substring. * + * ```kotlin + * // Check if the 'description' field contains "example" (case-insensitive) + * regexContains("description", "(?i)example") + * ``` + * * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the search. - * @return A new [BooleanExpr] representing the contains regular expression comparison. + * @return A new [BooleanExpression] representing the contains regular expression comparison. */ @JvmStatic fun regexContains(fieldName: String, pattern: String) = - BooleanExpr("regex_contains", evaluateRegexContains, fieldName, pattern) + BooleanExpression("regex_contains", evaluateRegexContains, fieldName, pattern) /** * Creates an expression that checks if a string field matches a specified regular expression. * + * ```kotlin + * // Check if the 'email' field matches a valid email pattern + * regexMatch(field("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}") + * ``` + * * @param stringExpression The expression representing the string to match against. * @param pattern The regular expression to use for the match. - * @return A new [BooleanExpr] representing the regular expression match comparison. + * @return A new [BooleanExpression] representing the regular expression match comparison. */ @JvmStatic - fun regexMatch(stringExpression: Expr, pattern: Expr): BooleanExpr = - BooleanExpr("regex_match", evaluateRegexMatch, stringExpression, pattern) + fun regexMatch(stringExpression: Expression, pattern: Expression): BooleanExpression = + BooleanExpression("regex_match", evaluateRegexMatch, stringExpression, pattern) /** * Creates an expression that checks if a string field matches a specified regular expression. * + * ```kotlin + * // Check if the 'email' field matches a valid email pattern + * regexMatch(field("email"), "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}") + * ``` + * * @param stringExpression The expression representing the string to match against. * @param pattern The regular expression to use for the match. - * @return A new [BooleanExpr] representing the regular expression match comparison. + * @return A new [BooleanExpression] representing the regular expression match comparison. */ @JvmStatic - fun regexMatch(stringExpression: Expr, pattern: String): BooleanExpr = - BooleanExpr("regex_match", evaluateRegexMatch, stringExpression, pattern) + fun regexMatch(stringExpression: Expression, pattern: String): BooleanExpression = + BooleanExpression("regex_match", evaluateRegexMatch, stringExpression, pattern) /** * Creates an expression that checks if a string field matches a specified regular expression. * + * ```kotlin + * // Check if the 'email' field matches the regex from the 'pattern' field. + * regexMatch("email", field("pattern")) + * ``` + * * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the match. - * @return A new [BooleanExpr] representing the regular expression match comparison. + * @return A new [BooleanExpression] representing the regular expression match comparison. */ @JvmStatic - fun regexMatch(fieldName: String, pattern: Expr) = - BooleanExpr("regex_match", evaluateRegexMatch, fieldName, pattern) + fun regexMatch(fieldName: String, pattern: Expression) = + BooleanExpression("regex_match", evaluateRegexMatch, fieldName, pattern) /** * Creates an expression that checks if a string field matches a specified regular expression. * + * ```kotlin + * // Check if the 'email' field matches a valid email pattern + * regexMatch("email", "[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}") + * ``` + * * @param fieldName The name of the field containing the string. * @param pattern The regular expression to use for the match. - * @return A new [BooleanExpr] representing the regular expression match comparison. + * @return A new [BooleanExpression] representing the regular expression match comparison. */ @JvmStatic fun regexMatch(fieldName: String, pattern: String) = - BooleanExpr("regex_match", evaluateRegexMatch, fieldName, pattern) + BooleanExpression("regex_match", evaluateRegexMatch, fieldName, pattern) /** * Creates an expression that returns the largest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the larger value between the 'timestamp' field and the current timestamp. + * logicalMaximum(field("timestamp"), currentTimestamp()) + * ``` + * * @param expr The first operand expression. * @param others Optional additional expressions or literals. - * @return A new [Expr] representing the logical maximum operation. + * @return A new [Expression] representing the logical maximum operation. */ @JvmStatic - fun logicalMaximum(expr: Expr, vararg others: Any): Expr = - FunctionExpr("max", evaluateLogicalMaximum, expr, *others) + fun logicalMaximum(expr: Expression, vararg others: Any): Expression = + FunctionExpression("maximum", evaluateLogicalMaximum, expr, *others) /** * Creates an expression that returns the largest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the larger value between the 'timestamp' field and the current timestamp. + * logicalMaximum("timestamp", currentTimestamp()) + * ``` + * * @param fieldName The first operand field name. * @param others Optional additional expressions or literals. - * @return A new [Expr] representing the logical maximum operation. + * @return A new [Expression] representing the logical maximum operation. */ @JvmStatic - fun logicalMaximum(fieldName: String, vararg others: Any): Expr = - FunctionExpr("max", evaluateLogicalMaximum, fieldName, *others) + fun logicalMaximum(fieldName: String, vararg others: Any): Expression = + FunctionExpression("maximum", evaluateLogicalMaximum, fieldName, *others) /** * Creates an expression that returns the smallest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the smaller value between the 'timestamp' field and the current timestamp. + * logicalMinimum(field("timestamp"), currentTimestamp()) + * ``` + * * @param expr The first operand expression. * @param others Optional additional expressions or literals. - * @return A new [Expr] representing the logical minimum operation. + * @return A new [Expression] representing the logical minimum operation. */ @JvmStatic - fun logicalMinimum(expr: Expr, vararg others: Any): Expr = - FunctionExpr("min", evaluateLogicalMinimum, expr, *others) + fun logicalMinimum(expr: Expression, vararg others: Any): Expression = + FunctionExpression("minimum", evaluateLogicalMinimum, expr, *others) /** * Creates an expression that returns the smallest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the smaller value between the 'timestamp' field and the current timestamp. + * logicalMinimum("timestamp", currentTimestamp()) + * ``` + * * @param fieldName The first operand field name. * @param others Optional additional expressions or literals. - * @return A new [Expr] representing the logical minimum operation. + * @return A new [Expression] representing the logical minimum operation. */ @JvmStatic - fun logicalMinimum(fieldName: String, vararg others: Any): Expr = - FunctionExpr("min", evaluateLogicalMinimum, fieldName, *others) + fun logicalMinimum(fieldName: String, vararg others: Any): Expression = + FunctionExpression("minimum", evaluateLogicalMinimum, fieldName, *others) /** * Creates an expression that reverses a string. * - * @param stringExpression An expression evaluating to a string value, which will be reversed. - * @return A new [Expr] representing the reversed string. - */ - @JvmStatic - fun reverse(stringExpression: Expr): Expr = - FunctionExpr("reverse", evaluateReverse, stringExpression) - - /** - * Creates an expression that reverses a string value from the specified field. - * - * @param fieldName The name of the field that contains the string to reverse. - * @return A new [Expr] representing the reversed string. - */ - @JvmStatic - fun reverse(fieldName: String): Expr = FunctionExpr("reverse", evaluateReverse, fieldName) - - /** - * Creates an expression that reverses a string. + * ```kotlin + * // Reverse the value of the 'myString' field. + * reverse(field("myString")) + * ``` * * @param stringExpression An expression evaluating to a string value, which will be reversed. - * @return A new [Expr] representing the reversed string. + * @return A new [Expression] representing the reversed string. */ @JvmStatic - fun strReverse(stringExpression: Expr): Expr = - FunctionExpr("str_reverse", evaluateReverse, stringExpression) + fun reverse(stringExpression: Expression): Expression = + FunctionExpression("reverse", evaluateReverse, stringExpression) /** * Creates an expression that reverses a string value from the specified field. * + * ```kotlin + * // Reverse the value of the 'myString' field. + * reverse("myString") + * ``` + * * @param fieldName The name of the field that contains the string to reverse. - * @return A new [Expr] representing the reversed string. + * @return A new [Expression] representing the reversed string. */ @JvmStatic - fun strReverse(fieldName: String): Expr = - FunctionExpr("str_reverse", evaluateReverse, fieldName) + fun reverse(fieldName: String): Expression = + FunctionExpression("reverse", evaluateReverse, fieldName) /** * Creates an expression that checks if a string expression contains a specified substring. * + * ```kotlin + * // Check if the 'description' field contains the value of the 'keyword' field. + * stringContains(field("description"), field("keyword")) + * ``` + * * @param stringExpression The expression representing the string to perform the comparison on. * @param substring The expression representing the substring to search for. - * @return A new [BooleanExpr] representing the contains comparison. + * @return A new [BooleanExpression] representing the contains comparison. */ @JvmStatic - fun strContains(stringExpression: Expr, substring: Expr): BooleanExpr = - BooleanExpr("str_contains", evaluateStrContains, stringExpression, substring) + fun stringContains(stringExpression: Expression, substring: Expression): BooleanExpression = + BooleanExpression("string_contains", evaluateStrContains, stringExpression, substring) /** * Creates an expression that checks if a string expression contains a specified substring. * + * ```kotlin + * // Check if the 'description' field contains "example". + * stringContains(field("description"), "example") + * ``` + * * @param stringExpression The expression representing the string to perform the comparison on. * @param substring The substring to search for. - * @return A new [BooleanExpr] representing the contains comparison. + * @return A new [BooleanExpression] representing the contains comparison. */ @JvmStatic - fun strContains(stringExpression: Expr, substring: String): BooleanExpr = - BooleanExpr("str_contains", evaluateStrContains, stringExpression, substring) + fun stringContains(stringExpression: Expression, substring: String): BooleanExpression = + BooleanExpression("string_contains", evaluateStrContains, stringExpression, substring) /** * Creates an expression that checks if a string field contains a specified substring. * + * ```kotlin + * // Check if the 'description' field contains the value of the 'keyword' field. + * stringContains("description", field("keyword")) + * ``` + * * @param fieldName The name of the field to perform the comparison on. * @param substring The expression representing the substring to search for. - * @return A new [BooleanExpr] representing the contains comparison. + * @return A new [BooleanExpression] representing the contains comparison. */ @JvmStatic - fun strContains(fieldName: String, substring: Expr): BooleanExpr = - BooleanExpr("str_contains", evaluateStrContains, fieldName, substring) + fun stringContains(fieldName: String, substring: Expression): BooleanExpression = + BooleanExpression("string_contains", evaluateStrContains, fieldName, substring) /** * Creates an expression that checks if a string field contains a specified substring. * + * ```kotlin + * // Check if the 'description' field contains "example". + * stringContains("description", "example") + * ``` + * * @param fieldName The name of the field to perform the comparison on. * @param substring The substring to search for. - * @return A new [BooleanExpr] representing the contains comparison. + * @return A new [BooleanExpression] representing the contains comparison. */ @JvmStatic - fun strContains(fieldName: String, substring: String): BooleanExpr = - BooleanExpr("str_contains", evaluateStrContains, fieldName, substring) + fun stringContains(fieldName: String, substring: String): BooleanExpression = + BooleanExpression("string_contains", evaluateStrContains, fieldName, substring) /** - * Creates an expression that checks if a string expression starts with a given [prefix]. + * ```kotlin + * // Check if the 'fullName' field starts with the value of the 'firstName' field + * startsWith(field("fullName"), field("firstName")) + * ``` * * @param stringExpr The expression to check. * @param prefix The prefix string expression to check for. - * @return A new [BooleanExpr] representing the 'starts with' comparison. + * @return A new [BooleanExpression] representing the 'starts with' comparison. */ @JvmStatic - fun startsWith(stringExpr: Expr, prefix: Expr): BooleanExpr = - BooleanExpr("starts_with", evaluateStartsWith, stringExpr, prefix) + fun startsWith(stringExpr: Expression, prefix: Expression): BooleanExpression = + BooleanExpression("starts_with", evaluateStartsWith, stringExpr, prefix) /** * Creates an expression that checks if a string expression starts with a given [prefix]. * + * ```kotlin + * // Check if the 'name' field starts with "Mr." + * startsWith(field("name"), "Mr.") + * ``` + * * @param stringExpr The expression to check. * @param prefix The prefix string to check for. - * @return A new [BooleanExpr] representing the 'starts with' comparison. + * @return A new [BooleanExpression] representing the 'starts with' comparison. */ @JvmStatic - fun startsWith(stringExpr: Expr, prefix: String): BooleanExpr = - BooleanExpr("starts_with", evaluateStartsWith, stringExpr, prefix) + fun startsWith(stringExpr: Expression, prefix: String): BooleanExpression = + BooleanExpression("starts_with", evaluateStartsWith, stringExpr, prefix) /** * Creates an expression that checks if a string expression starts with a given [prefix]. * + * ```kotlin + * // Check if the 'fullName' field starts with the value of the 'firstName' field + * startsWith("fullName", field("firstName")) + * ``` + * * @param fieldName The name of field that contains a string to check. * @param prefix The prefix string expression to check for. - * @return A new [BooleanExpr] representing the 'starts with' comparison. + * @return A new [BooleanExpression] representing the 'starts with' comparison. */ @JvmStatic - fun startsWith(fieldName: String, prefix: Expr): BooleanExpr = - BooleanExpr("starts_with", evaluateStartsWith, fieldName, prefix) + fun startsWith(fieldName: String, prefix: Expression): BooleanExpression = + BooleanExpression("starts_with", evaluateStartsWith, fieldName, prefix) /** * Creates an expression that checks if a string expression starts with a given [prefix]. * + * ```kotlin + * // Check if the 'name' field starts with "Mr." + * startsWith("name", "Mr.") + * ``` + * * @param fieldName The name of field that contains a string to check. * @param prefix The prefix string to check for. - * @return A new [BooleanExpr] representing the 'starts with' comparison. + * @return A new [BooleanExpression] representing the 'starts with' comparison. */ @JvmStatic - fun startsWith(fieldName: String, prefix: String): BooleanExpr = - BooleanExpr("starts_with", evaluateStartsWith, fieldName, prefix) + fun startsWith(fieldName: String, prefix: String): BooleanExpression = + BooleanExpression("starts_with", evaluateStartsWith, fieldName, prefix) /** * Creates an expression that checks if a string expression ends with a given [suffix]. * + * ```kotlin + * // Check if the 'url' field ends with the value of the 'extension' field + * endsWith(field("url"), field("extension")) + * ``` + * * @param stringExpr The expression to check. * @param suffix The suffix string expression to check for. - * @return A new [BooleanExpr] representing the 'ends with' comparison. + * @return A new [BooleanExpression] representing the 'ends with' comparison. */ @JvmStatic - fun endsWith(stringExpr: Expr, suffix: Expr): BooleanExpr = - BooleanExpr("ends_with", evaluateEndsWith, stringExpr, suffix) + fun endsWith(stringExpr: Expression, suffix: Expression): BooleanExpression = + BooleanExpression("ends_with", evaluateEndsWith, stringExpr, suffix) /** * Creates an expression that checks if a string expression ends with a given [suffix]. * + * ```kotlin + * // Check if the 'filename' field ends with ".txt" + * endsWith(field("filename"), ".txt") + * ``` + * * @param stringExpr The expression to check. * @param suffix The suffix string to check for. - * @return A new [BooleanExpr] representing the 'ends with' comparison. + * @return A new [BooleanExpression] representing the 'ends with' comparison. */ @JvmStatic - fun endsWith(stringExpr: Expr, suffix: String): BooleanExpr = - BooleanExpr("ends_with", evaluateEndsWith, stringExpr, suffix) + fun endsWith(stringExpr: Expression, suffix: String): BooleanExpression = + BooleanExpression("ends_with", evaluateEndsWith, stringExpr, suffix) /** * Creates an expression that checks if a string expression ends with a given [suffix]. * + * ```kotlin + * // Check if the 'url' field ends with the value of the 'extension' field + * endsWith("url", field("extension")) + * ``` + * * @param fieldName The name of field that contains a string to check. * @param suffix The suffix string expression to check for. - * @return A new [BooleanExpr] representing the 'ends with' comparison. + * @return A new [BooleanExpression] representing the 'ends with' comparison. */ @JvmStatic - fun endsWith(fieldName: String, suffix: Expr): BooleanExpr = - BooleanExpr("ends_with", evaluateEndsWith, fieldName, suffix) + fun endsWith(fieldName: String, suffix: Expression): BooleanExpression = + BooleanExpression("ends_with", evaluateEndsWith, fieldName, suffix) /** * Creates an expression that checks if a string expression ends with a given [suffix]. * + * ```kotlin + * // Check if the 'filename' field ends with ".txt" + * endsWith("filename", ".txt") + * ``` + * * @param fieldName The name of field that contains a string to check. * @param suffix The suffix string to check for. - * @return A new [BooleanExpr] representing the 'ends with' comparison. + * @return A new [BooleanExpression] representing the 'ends with' comparison. + */ + @JvmStatic + fun endsWith(fieldName: String, suffix: String): BooleanExpression = + BooleanExpression("ends_with", evaluateEndsWith, fieldName, suffix) + + /** + * Reverses the given string expression. + * + * ```kotlin + * // Reverse the value of the 'myString' field. + * stringReverse(field("myString")) + * ``` + * + * @param str The string expression to reverse. + * @return A new [Expression] representing the stringReverse operation. + */ + @JvmStatic + fun stringReverse(str: Expression): Expression = + FunctionExpression("string_reverse", notImplemented, str) + + /** + * Reverses the given string field. + * + * ```kotlin + * // Reverse the value of the 'myString' field. + * stringReverse("myString") + * ``` + * + * @param fieldName The name of field that contains the string to reverse. + * @return A new [Expression] representing the stringReverse operation. */ @JvmStatic - fun endsWith(fieldName: String, suffix: String): BooleanExpr = - BooleanExpr("ends_with", evaluateEndsWith, fieldName, suffix) + fun stringReverse(fieldName: String): Expression = + FunctionExpression("string_reverse", notImplemented, fieldName) /** * Creates an expression that returns a substring of the given string. * + * ```kotlin + * // Get a substring of the 'message' field starting at index 5 with length 10. + * substring(field("message"), constant(5), constant(10)) + * ``` + * * @param stringExpression The expression representing the string to get a substring from. * @param index The starting index of the substring. * @param length The length of the substring. - * @return A new [Expr] representing the substring. + * @return A new [Expression] representing the substring. */ @JvmStatic - fun substr(stringExpression: Expr, index: Expr, length: Expr): Expr = - FunctionExpr("substr", evaluateSubstring, stringExpression, index, length) + fun substring(stringExpression: Expression, index: Expression, length: Expression): Expression = + FunctionExpression("substring", evaluateSubstring, stringExpression, index, length) /** * Creates an expression that returns a substring of the given string. * + * ```kotlin + * // Get a substring of the 'message' field starting at index 5 with length 10. + * substring("message", 5, 10) + * ``` + * * @param fieldName The name of the field containing the string to get a substring from. * @param index The starting index of the substring. * @param length The length of the substring. - * @return A new [Expr] representing the substring. + * @return A new [Expression] representing the substring. */ @JvmStatic - fun substr(fieldName: String, index: Int, length: Int): Expr = - FunctionExpr("substr", evaluateSubstring, fieldName, index, length) + fun substring(fieldName: String, index: Int, length: Int): Expression = + FunctionExpression("substring", evaluateSubstring, fieldName, index, length) /** * Creates an expression that converts a string expression to lowercase. * + * ```kotlin + * // Convert the 'name' field to lowercase + * toLower(field("name")) + * ``` + * * @param stringExpression The expression representing the string to convert to lowercase. - * @return A new [Expr] representing the lowercase string. + * @return A new [Expression] representing the lowercase string. */ @JvmStatic - fun toLower(stringExpression: Expr): Expr = - FunctionExpr("to_lower", evaluateToLowercase, stringExpression) + fun toLower(stringExpression: Expression): Expression = + FunctionExpression("to_lower", evaluateToLowercase, stringExpression) /** * Creates an expression that converts a string field to lowercase. * + * ```kotlin + * // Convert the 'name' field to lowercase + * toLower("name") + * ``` + * * @param fieldName The name of the field containing the string to convert to lowercase. - * @return A new [Expr] representing the lowercase string. + * @return A new [Expression] representing the lowercase string. */ @JvmStatic - fun toLower(fieldName: String): Expr = FunctionExpr("to_lower", evaluateToLowercase, fieldName) + fun toLower(fieldName: String): Expression = + FunctionExpression("to_lower", evaluateToLowercase, fieldName) /** * Creates an expression that converts a string expression to uppercase. * + * ```kotlin + * // Convert the 'title' field to uppercase + * toUpper(field("title")) + * ``` + * * @param stringExpression The expression representing the string to convert to uppercase. - * @return A new [Expr] representing the uppercase string. + * @return A new [Expression] representing the uppercase string. */ @JvmStatic - fun toUpper(stringExpression: Expr): Expr = - FunctionExpr("to_upper", evaluateToUppercase, stringExpression) + fun toUpper(stringExpression: Expression): Expression = + FunctionExpression("to_upper", evaluateToUppercase, stringExpression) /** * Creates an expression that converts a string field to uppercase. * + * ```kotlin + * // Convert the 'title' field to uppercase + * toUpper("title") + * ``` + * * @param fieldName The name of the field containing the string to convert to uppercase. - * @return A new [Expr] representing the uppercase string. + * @return A new [Expression] representing the uppercase string. */ @JvmStatic - fun toUpper(fieldName: String): Expr = FunctionExpr("to_upper", evaluateToUppercase, fieldName) + fun toUpper(fieldName: String): Expression = + FunctionExpression("to_upper", evaluateToUppercase, fieldName) /** * Creates an expression that removes leading and trailing whitespace from a string expression. * + * ```kotlin + * // Trim whitespace from the 'userInput' field + * trim(field("userInput")) + * ``` + * * @param stringExpression The expression representing the string to trim. - * @return A new [Expr] representing the trimmed string. + * @return A new [Expression] representing the trimmed string. */ @JvmStatic - fun trim(stringExpression: Expr): Expr = FunctionExpr("trim", evaluateTrim, stringExpression) + fun trim(stringExpression: Expression): Expression = + FunctionExpression("trim", evaluateTrim, stringExpression) /** * Creates an expression that removes leading and trailing whitespace from a string field. * + * ```kotlin + * // Trim whitespace from the 'userInput' field + * trim("userInput") + * ``` + * * @param fieldName The name of the field containing the string to trim. - * @return A new [Expr] representing the trimmed string. + * @return A new [Expression] representing the trimmed string. */ - @JvmStatic fun trim(fieldName: String): Expr = FunctionExpr("trim", evaluateTrim, fieldName) + @JvmStatic + fun trim(fieldName: String): Expression = FunctionExpression("trim", evaluateTrim, fieldName) /** * Creates an expression that concatenates string expressions together. * + * ```kotlin + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * stringConcat(field("firstName"), constant(" "), field("lastName")) + * ``` + * * @param firstString The expression representing the initial string value. * @param otherStrings Optional additional string expressions to concatenate. - * @return A new [Expr] representing the concatenated string. + * @return A new [Expression] representing the concatenated string. */ @JvmStatic - fun strConcat(firstString: Expr, vararg otherStrings: Expr): Expr = - FunctionExpr("str_concat", evaluateStrConcat, firstString, *otherStrings) + fun stringConcat(firstString: Expression, vararg otherStrings: Expression): Expression = + FunctionExpression("string_concat", evaluateStrConcat, firstString, *otherStrings) /** * Creates an expression that concatenates string expressions together. * + * ```kotlin + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * stringConcat(field("firstName"), " ", field("lastName")) + * ``` + * * @param firstString The expression representing the initial string value. * @param otherStrings Optional additional string expressions or string constants to * concatenate. - * @return A new [Expr] representing the concatenated string. + * @return A new [Expression] representing the concatenated string. */ @JvmStatic - fun strConcat(firstString: Expr, vararg otherStrings: Any): Expr = - FunctionExpr("str_concat", evaluateStrConcat, firstString, *otherStrings) + fun stringConcat(firstString: Expression, vararg otherStrings: Any): Expression = + FunctionExpression("string_concat", evaluateStrConcat, firstString, *otherStrings) /** * Creates an expression that concatenates string expressions together. * + * ```kotlin + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * stringConcat("firstName", constant(" "), field("lastName")) + * ``` + * * @param fieldName The field name containing the initial string value. * @param otherStrings Optional additional string expressions to concatenate. - * @return A new [Expr] representing the concatenated string. + * @return A new [Expression] representing the concatenated string. */ @JvmStatic - fun strConcat(fieldName: String, vararg otherStrings: Expr): Expr = - FunctionExpr("str_concat", evaluateStrConcat, fieldName, *otherStrings) + fun stringConcat(fieldName: String, vararg otherStrings: Expression): Expression = + FunctionExpression("string_concat", evaluateStrConcat, fieldName, *otherStrings) /** * Creates an expression that concatenates string expressions together. * + * ```kotlin + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * stringConcat("firstName", " ", "lastName") + * ``` + * * @param fieldName The field name containing the initial string value. * @param otherStrings Optional additional string expressions or string constants to * concatenate. - * @return A new [Expr] representing the concatenated string. + * @return A new [Expression] representing the concatenated string. */ @JvmStatic - fun strConcat(fieldName: String, vararg otherStrings: Any): Expr = - FunctionExpr("str_concat", evaluateStrConcat, fieldName, *otherStrings) + fun stringConcat(fieldName: String, vararg otherStrings: Any): Expression = + FunctionExpression("string_concat", evaluateStrConcat, fieldName, *otherStrings) - internal fun map(elements: Array): Expr = FunctionExpr("map", evaluateMap, elements) + internal fun map(elements: Array): Expression = + FunctionExpression("map", evaluateMap, elements) /** * Creates an expression that creates a Firestore map value from an input object. * + * ```kotlin + * // Create a map with a constant key and a field value + * map(mapOf("name" to field("productName"), "quantity" to 1)) + * ``` + * * @param elements The input map to evaluate in the expression. - * @return A new [Expr] representing the map function. + * @return A new [Expression] representing the map function. */ @JvmStatic - fun map(elements: Map): Expr = + fun map(elements: Map): Expression = map(elements.flatMap { listOf(constant(it.key), toExprOrConstant(it.value)) }.toTypedArray()) /** * Accesses a value from a map (object) field using the provided [key]. * + * ```kotlin + * // Get the 'city' value from the 'address' map field + * mapGet(field("address"), "city") + * ``` + * * @param mapExpression The expression representing the map. * @param key The key to access in the map. - * @return A new [Expr] representing the value associated with the given key in the map. + * @return A new [Expression] representing the value associated with the given key in the map. */ @JvmStatic - fun mapGet(mapExpression: Expr, key: String): Expr = - FunctionExpr("map_get", evaluateMapGet, mapExpression, key) + fun mapGet(mapExpression: Expression, key: String): Expression = + FunctionExpression("map_get", evaluateMapGet, mapExpression, key) /** * Accesses a value from a map (object) field using the provided [key]. * + * ```kotlin + * // Get the 'city' value from the 'address' map field + * mapGet("address", "city") + * ``` + * * @param fieldName The field name of the map field. * @param key The key to access in the map. - * @return A new [Expr] representing the value associated with the given key in the map. + * @return A new [Expression] representing the value associated with the given key in the map. */ @JvmStatic - fun mapGet(fieldName: String, key: String): Expr = - FunctionExpr("map_get", evaluateMapGet, fieldName, key) + fun mapGet(fieldName: String, key: String): Expression = + FunctionExpression("map_get", evaluateMapGet, fieldName, key) /** * Accesses a value from a map (object) field using the provided [keyExpression]. * + * ```kotlin + * // Get the value from the 'address' map field, using the key from the 'keyField' field + * mapGet(field("address"), field("keyField")) + * ``` + * * @param mapExpression The expression representing the map. * @param keyExpression The key to access in the map. - * @return A new [Expr] representing the value associated with the given key in the map. + * @return A new [Expression] representing the value associated with the given key in the map. */ @JvmStatic - fun mapGet(mapExpression: Expr, keyExpression: Expr): Expr = - FunctionExpr("map_get", evaluateMapGet, mapExpression, keyExpression) + fun mapGet(mapExpression: Expression, keyExpression: Expression): Expression = + FunctionExpression("map_get", evaluateMapGet, mapExpression, keyExpression) /** * Accesses a value from a map (object) field using the provided [keyExpression]. * + * ```kotlin + * // Get the value from the 'address' map field, using the key from the 'keyField' field + * mapGet("address", field("keyField")) + * ``` + * * @param fieldName The field name of the map field. * @param keyExpression The key to access in the map. - * @return A new [Expr] representing the value associated with the given key in the map. + * @return A new [Expression] representing the value associated with the given key in the map. */ @JvmStatic - fun mapGet(fieldName: String, keyExpression: Expr): Expr = - FunctionExpr("map_get", evaluateMapGet, fieldName, keyExpression) + fun mapGet(fieldName: String, keyExpression: Expression): Expression = + FunctionExpression("map_get", evaluateMapGet, fieldName, keyExpression) /** * Creates an expression that merges multiple maps into a single map. If multiple maps have the * same key, the later value is used. * + * ```kotlin + * // Merges the map in the settings field with, a map literal, and a map in + * // that is conditionally returned by another expression + * mapMerge( + * field("settings"), + * map(mapOf("enabled" to true)), + * conditional( + * field("isAdmin").equal(true), + * map(mapOf("admin" to true)), + * map(emptyMap()) + * ) + * ) + * ``` + * * @param firstMap First map expression that will be merged. * @param secondMap Second map expression that will be merged. * @param otherMaps Additional maps to merge. - * @return A new [Expr] representing the mapMerge operation. + * @return A new [Expression] representing the mapMerge operation. */ @JvmStatic - fun mapMerge(firstMap: Expr, secondMap: Expr, vararg otherMaps: Expr): Expr = - FunctionExpr("map_merge", notImplemented, firstMap, secondMap, *otherMaps) + fun mapMerge( + firstMap: Expression, + secondMap: Expression, + vararg otherMaps: Expression + ): Expression = FunctionExpression("map_merge", notImplemented, firstMap, secondMap, *otherMaps) /** * Creates an expression that merges multiple maps into a single map. If multiple maps have the * same key, the later value is used. * + * ```kotlin + * // Merges the map in the settings field with, a map literal, and a map in + * // that is conditionally returned by another expression + * mapMerge( + * "settings", + * map(mapOf("enabled" to true)), + * conditional( + * field("isAdmin").equal(true), + * map(mapOf("admin" to true)), + * map(emptyMap()) + * ) + * ) + * ``` + * * @param firstMapFieldName First map field name that will be merged. * @param secondMap Second map expression that will be merged. * @param otherMaps Additional maps to merge. - * @return A new [Expr] representing the mapMerge operation. + * @return A new [Expression] representing the mapMerge operation. */ @JvmStatic - fun mapMerge(firstMapFieldName: String, secondMap: Expr, vararg otherMaps: Expr): Expr = - FunctionExpr("map_merge", notImplemented, firstMapFieldName, secondMap, *otherMaps) + fun mapMerge( + firstMapFieldName: String, + secondMap: Expression, + vararg otherMaps: Expression + ): Expression = + FunctionExpression("map_merge", notImplemented, firstMapFieldName, secondMap, *otherMaps) /** * Creates an expression that removes a key from the map produced by evaluating an expression. * + * ```kotlin + * // Removes the key 'baz' from the input map. + * mapRemove(map(mapOf("foo" to "bar", "baz" to true)), constant("baz")) + * ``` + * * @param mapExpr An expression that evaluates to a map. * @param key The name of the key to remove from the input map. - * @return A new [Expr] that evaluates to a modified map. + * @return A new [Expression] that evaluates to a modified map. */ @JvmStatic - fun mapRemove(mapExpr: Expr, key: Expr): Expr = - FunctionExpr("map_remove", notImplemented, mapExpr, key) + fun mapRemove(mapExpr: Expression, key: Expression): Expression = + FunctionExpression("map_remove", notImplemented, mapExpr, key) /** * Creates an expression that removes a key from the map produced by evaluating an expression. * + * ```kotlin + * // Removes the key 'city' field from the map in the address field of the input document. + * mapRemove("address", constant("city")) + * ``` + * * @param mapField The name of a field containing a map value. * @param key The name of the key to remove from the input map. - * @return A new [Expr] that evaluates to a modified map. + * @return A new [Expression] that evaluates to a modified map. */ @JvmStatic - fun mapRemove(mapField: String, key: Expr): Expr = - FunctionExpr("map_remove", notImplemented, mapField, key) + fun mapRemove(mapField: String, key: Expression): Expression = + FunctionExpression("map_remove", notImplemented, mapField, key) /** * Creates an expression that removes a key from the map produced by evaluating an expression. * + * ```kotlin + * // Removes the key 'baz' from the input map. + * mapRemove(map(mapOf("foo" to "bar", "baz" to true)), "baz") + * ``` + * * @param mapExpr An expression that evaluates to a map. * @param key The name of the key to remove from the input map. - * @return A new [Expr] that evaluates to a modified map. + * @return A new [Expression] that evaluates to a modified map. */ @JvmStatic - fun mapRemove(mapExpr: Expr, key: String): Expr = - FunctionExpr("map_remove", notImplemented, mapExpr, key) + fun mapRemove(mapExpr: Expression, key: String): Expression = + FunctionExpression("map_remove", notImplemented, mapExpr, key) /** * Creates an expression that removes a key from the map produced by evaluating an expression. * + * ```kotlin + * // Removes the key 'city' field from the map in the address field of the input document. + * mapRemove("address", "city") + * ``` + * * @param mapField The name of a field containing a map value. * @param key The name of the key to remove from the input map. - * @return A new [Expr] that evaluates to a modified map. + * @return A new [Expression] that evaluates to a modified map. */ @JvmStatic - fun mapRemove(mapField: String, key: String): Expr = - FunctionExpr("map_remove", notImplemented, mapField, key) + fun mapRemove(mapField: String, key: String): Expression = + FunctionExpression("map_remove", notImplemented, mapField, key) /** * Calculates the Cosine distance between two vector expressions. * - * @param vector1 The first vector (represented as an Expr) to compare against. - * @param vector2 The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * ```kotlin + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * cosineDistance(field("userVector"), field("itemVector")) + * ``` + * + * @param vector1 The first vector (represented as an Expression) to compare against. + * @param vector2 The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the cosine distance between the two vectors. */ @JvmStatic - fun cosineDistance(vector1: Expr, vector2: Expr): Expr = - FunctionExpr("cosine_distance", notImplemented, vector1, vector2) + fun cosineDistance(vector1: Expression, vector2: Expression): Expression = + FunctionExpression("cosine_distance", notImplemented, vector1, vector2) /** * Calculates the Cosine distance between vector expression and a vector literal. * - * @param vector1 The first vector (represented as an Expr) to compare against. + * ```kotlin + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance(field("location"), doubleArrayOf(37.7749, -122.4194)) + * ``` + * + * @param vector1 The first vector (represented as an Expression) to compare against. * @param vector2 The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * @return A new [Expression] representing the cosine distance between the two vectors. */ @JvmStatic - fun cosineDistance(vector1: Expr, vector2: DoubleArray): Expr = - FunctionExpr("cosine_distance", notImplemented, vector1, vector(vector2)) + fun cosineDistance(vector1: Expression, vector2: DoubleArray): Expression = + FunctionExpression("cosine_distance", notImplemented, vector1, vector(vector2)) /** * Calculates the Cosine distance between vector expression and a vector literal. * - * @param vector1 The first vector (represented as an [Expr]) to compare against. + * ```kotlin + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance(field("location"), VectorValue.from(listOf(37.7749, -122.4194))) + * ``` + * + * @param vector1 The first vector (represented as an [Expression]) to compare against. * @param vector2 The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * @return A new [Expression] representing the cosine distance between the two vectors. */ @JvmStatic - fun cosineDistance(vector1: Expr, vector2: VectorValue): Expr = - FunctionExpr("cosine_distance", notImplemented, vector1, vector2) + fun cosineDistance(vector1: Expression, vector2: VectorValue): Expression = + FunctionExpression("cosine_distance", notImplemented, vector1, vector2) /** * Calculates the Cosine distance between a vector field and a vector expression. * + * ```kotlin + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * cosineDistance("userVector", field("itemVector")) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. - * @param vector The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the cosine distance between the two vectors. */ @JvmStatic - fun cosineDistance(vectorFieldName: String, vector: Expr): Expr = - FunctionExpr("cosine_distance", notImplemented, vectorFieldName, vector) + fun cosineDistance(vectorFieldName: String, vector: Expression): Expression = + FunctionExpression("cosine_distance", notImplemented, vectorFieldName, vector) /** * Calculates the Cosine distance between a vector field and a vector literal. * + * ```kotlin + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance("location", doubleArrayOf(37.7749, -122.4194)) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. * @param vector The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * @return A new [Expression] representing the cosine distance between the two vectors. */ @JvmStatic - fun cosineDistance(vectorFieldName: String, vector: DoubleArray): Expr = - FunctionExpr("cosine_distance", notImplemented, vectorFieldName, vector(vector)) + fun cosineDistance(vectorFieldName: String, vector: DoubleArray): Expression = + FunctionExpression("cosine_distance", notImplemented, vectorFieldName, vector(vector)) /** * Calculates the Cosine distance between a vector field and a vector literal. * + * ```kotlin + * // Calculate the Cosine distance between the 'location' field and a target location + * cosineDistance("location", VectorValue.from(listOf(37.7749, -122.4194))) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. * @param vector The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * @return A new [Expression] representing the cosine distance between the two vectors. */ @JvmStatic - fun cosineDistance(vectorFieldName: String, vector: VectorValue): Expr = - FunctionExpr("cosine_distance", notImplemented, vectorFieldName, vector) + fun cosineDistance(vectorFieldName: String, vector: VectorValue): Expression = + FunctionExpression("cosine_distance", notImplemented, vectorFieldName, vector) /** * Calculates the dot product distance between two vector expressions. * - * @param vector1 The first vector (represented as an Expr) to compare against. - * @param vector2 The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * ```kotlin + * // Calculate the dot product between the 'userVector' field and the 'itemVector' field + * dotProduct(field("userVector"), field("itemVector")) + * ``` + * + * @param vector1 The first vector (represented as an Expression) to compare against. + * @param vector2 The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the dot product distance between the two vectors. */ @JvmStatic - fun dotProduct(vector1: Expr, vector2: Expr): Expr = - FunctionExpr("dot_product", notImplemented, vector1, vector2) + fun dotProduct(vector1: Expression, vector2: Expression): Expression = + FunctionExpression("dot_product", notImplemented, vector1, vector2) /** * Calculates the dot product distance between vector expression and a vector literal. * - * @param vector1 The first vector (represented as an Expr) to compare against. + * ```kotlin + * // Calculate the dot product between the 'vector' field and a constant vector + * dotProduct(field("vector"), doubleArrayOf(1.0, 2.0, 3.0)) + * ``` + * + * @param vector1 The first vector (represented as an Expression) to compare against. * @param vector2 The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * @return A new [Expression] representing the dot product distance between the two vectors. */ @JvmStatic - fun dotProduct(vector1: Expr, vector2: DoubleArray): Expr = - FunctionExpr("dot_product", notImplemented, vector1, vector(vector2)) + fun dotProduct(vector1: Expression, vector2: DoubleArray): Expression = + FunctionExpression("dot_product", notImplemented, vector1, vector(vector2)) /** * Calculates the dot product distance between vector expression and a vector literal. * - * @param vector1 The first vector (represented as an [Expr]) to compare against. + * ```kotlin + * // Calculate the dot product between the 'vector' field and a constant vector + * dotProduct(field("vector"), VectorValue.from(listOf(1.0, 2.0, 3.0))) + * ``` + * + * @param vector1 The first vector (represented as an [Expression]) to compare against. * @param vector2 The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * @return A new [Expression] representing the dot product distance between the two vectors. */ @JvmStatic - fun dotProduct(vector1: Expr, vector2: VectorValue): Expr = - FunctionExpr("dot_product", notImplemented, vector1, vector2) + fun dotProduct(vector1: Expression, vector2: VectorValue): Expression = + FunctionExpression("dot_product", notImplemented, vector1, vector2) /** * Calculates the dot product distance between a vector field and a vector expression. * + * ```kotlin + * // Calculate the dot product between the 'userVector' field and the 'itemVector' field + * dotProduct("userVector", field("itemVector")) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. - * @param vector The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the dot product distance between the two vectors. */ @JvmStatic - fun dotProduct(vectorFieldName: String, vector: Expr): Expr = - FunctionExpr("dot_product", notImplemented, vectorFieldName, vector) + fun dotProduct(vectorFieldName: String, vector: Expression): Expression = + FunctionExpression("dot_product", notImplemented, vectorFieldName, vector) /** * Calculates the dot product distance between vector field and a vector literal. * + * ```kotlin + * // Calculate the dot product between the 'vector' field and a constant vector + * dotProduct("vector", doubleArrayOf(1.0, 2.0, 3.0)) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. * @param vector The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * @return A new [Expression] representing the dot product distance between the two vectors. */ @JvmStatic - fun dotProduct(vectorFieldName: String, vector: DoubleArray): Expr = - FunctionExpr("dot_product", notImplemented, vectorFieldName, vector(vector)) + fun dotProduct(vectorFieldName: String, vector: DoubleArray): Expression = + FunctionExpression("dot_product", notImplemented, vectorFieldName, vector(vector)) /** * Calculates the dot product distance between a vector field and a vector literal. * + * ```kotlin + * // Calculate the dot product between the 'vector' field and a constant vector + * dotProduct("vector", VectorValue.from(listOf(1.0, 2.0, 3.0))) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. * @param vector The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * @return A new [Expression] representing the dot product distance between the two vectors. */ @JvmStatic - fun dotProduct(vectorFieldName: String, vector: VectorValue): Expr = - FunctionExpr("dot_product", notImplemented, vectorFieldName, vector) + fun dotProduct(vectorFieldName: String, vector: VectorValue): Expression = + FunctionExpression("dot_product", notImplemented, vectorFieldName, vector) /** * Calculates the Euclidean distance between two vector expressions. * - * @param vector1 The first vector (represented as an Expr) to compare against. - * @param vector2 The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * ```kotlin + * // Calculate the Euclidean distance between the 'userVector' field and the 'itemVector' field + * euclideanDistance(field("userVector"), field("itemVector")) + * ``` + * + * @param vector1 The first vector (represented as an Expression) to compare against. + * @param vector2 The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ @JvmStatic - fun euclideanDistance(vector1: Expr, vector2: Expr): Expr = - FunctionExpr("euclidean_distance", notImplemented, vector1, vector2) + fun euclideanDistance(vector1: Expression, vector2: Expression): Expression = + FunctionExpression("euclidean_distance", notImplemented, vector1, vector2) /** * Calculates the Euclidean distance between vector expression and a vector literal. * - * @param vector1 The first vector (represented as an Expr) to compare against. + * ```kotlin + * // Calculate the Euclidean distance between the 'vector' field and a constant vector + * euclideanDistance(field("vector"), doubleArrayOf(1.0, 2.0, 3.0)) + * ``` + * + * @param vector1 The first vector (represented as an Expression) to compare against. * @param vector2 The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ @JvmStatic - fun euclideanDistance(vector1: Expr, vector2: DoubleArray): Expr = - FunctionExpr("euclidean_distance", notImplemented, vector1, vector(vector2)) + fun euclideanDistance(vector1: Expression, vector2: DoubleArray): Expression = + FunctionExpression("euclidean_distance", notImplemented, vector1, vector(vector2)) /** * Calculates the Euclidean distance between vector expression and a vector literal. * - * @param vector1 The first vector (represented as an [Expr]) to compare against. + * ```kotlin + * // Calculate the Euclidean distance between the 'vector' field and a constant vector + * euclideanDistance(field("vector"), VectorValue.from(listOf(1.0, 2.0, 3.0))) + * ``` + * + * @param vector1 The first vector (represented as an [Expression]) to compare against. * @param vector2 The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ @JvmStatic - fun euclideanDistance(vector1: Expr, vector2: VectorValue): Expr = - FunctionExpr("euclidean_distance", notImplemented, vector1, vector2) + fun euclideanDistance(vector1: Expression, vector2: VectorValue): Expression = + FunctionExpression("euclidean_distance", notImplemented, vector1, vector2) /** * Calculates the Euclidean distance between a vector field and a vector expression. * + * ```kotlin + * // Calculate the Euclidean distance between the 'userVector' field and the 'itemVector' field + * euclideanDistance("userVector", field("itemVector")) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. - * @param vector The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ @JvmStatic - fun euclideanDistance(vectorFieldName: String, vector: Expr): Expr = - FunctionExpr("euclidean_distance", notImplemented, vectorFieldName, vector) + fun euclideanDistance(vectorFieldName: String, vector: Expression): Expression = + FunctionExpression("euclidean_distance", notImplemented, vectorFieldName, vector) /** * Calculates the Euclidean distance between a vector field and a vector literal. * + * ```kotlin + * // Calculate the Euclidean distance between the 'vector' field and a constant vector + * euclideanDistance("vector", doubleArrayOf(1.0, 2.0, 3.0)) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. * @param vector The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ @JvmStatic - fun euclideanDistance(vectorFieldName: String, vector: DoubleArray): Expr = - FunctionExpr("euclidean_distance", notImplemented, vectorFieldName, vector(vector)) + fun euclideanDistance(vectorFieldName: String, vector: DoubleArray): Expression = + FunctionExpression("euclidean_distance", notImplemented, vectorFieldName, vector(vector)) /** * Calculates the Euclidean distance between a vector field and a vector literal. * + * ```kotlin + * // Calculate the Euclidean distance between the 'vector' field and a constant vector + * euclideanDistance("vector", VectorValue.from(listOf(1.0, 2.0, 3.0))) + * ``` + * * @param vectorFieldName The name of the field containing the first vector. * @param vector The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ @JvmStatic - fun euclideanDistance(vectorFieldName: String, vector: VectorValue): Expr = - FunctionExpr("euclidean_distance", notImplemented, vectorFieldName, vector) + fun euclideanDistance(vectorFieldName: String, vector: VectorValue): Expression = + FunctionExpression("euclidean_distance", notImplemented, vectorFieldName, vector) /** * Creates an expression that calculates the length (dimension) of a Firestore Vector. * + * ```kotlin + * // Get the vector length (dimension) of the field 'embedding'. + * vectorLength(field("embedding")) + * ``` + * * @param vectorExpression The expression representing the Firestore Vector. - * @return A new [Expr] representing the length (dimension) of the vector. + * @return A new [Expression] representing the length (dimension) of the vector. */ @JvmStatic - fun vectorLength(vectorExpression: Expr): Expr = - FunctionExpr("vector_length", notImplemented, vectorExpression) + fun vectorLength(vectorExpression: Expression): Expression = + FunctionExpression("vector_length", notImplemented, vectorExpression) /** * Creates an expression that calculates the length (dimension) of a Firestore Vector. * + * ```kotlin + * // Get the vector length (dimension) of the field 'embedding'. + * vectorLength("embedding") + * ``` + * * @param fieldName The name of the field containing the Firestore Vector. - * @return A new [Expr] representing the length (dimension) of the vector. + * @return A new [Expression] representing the length (dimension) of the vector. + */ + @JvmStatic + fun vectorLength(fieldName: String): Expression = + FunctionExpression("vector_length", notImplemented, fieldName) + + /** + * Creates an expression that evaluates to the current server timestamp. + * + * ```kotlin + * // Get the current server timestamp + * currentTimestamp() + * ``` + * + * @return A new [Expression] representing the current server timestamp. */ @JvmStatic - fun vectorLength(fieldName: String): Expr = - FunctionExpr("vector_length", notImplemented, fieldName) + fun currentTimestamp(): Expression = FunctionExpression("current_timestamp", notImplemented) /** * Creates an expression that interprets an expression as the number of microseconds since the * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * + * ```kotlin + * // Interpret the 'microseconds' field as microseconds since epoch. + * unixMicrosToTimestamp(field("microseconds")) + * ``` + * * @param expr The expression representing the number of microseconds since epoch. - * @return A new [Expr] representing the timestamp. + * @return A new [Expression] representing the timestamp. */ @JvmStatic - fun unixMicrosToTimestamp(expr: Expr): Expr = - FunctionExpr("unix_micros_to_timestamp", evaluateUnixMicrosToTimestamp, expr) + fun unixMicrosToTimestamp(expr: Expression): Expression = + FunctionExpression("unix_micros_to_timestamp", evaluateUnixMicrosToTimestamp, expr) /** * Creates an expression that interprets a field's value as the number of microseconds since the * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * + * ```kotlin + * // Interpret the 'microseconds' field as microseconds since epoch. + * unixMicrosToTimestamp("microseconds") + * ``` + * * @param fieldName The name of the field containing the number of microseconds since epoch. - * @return A new [Expr] representing the timestamp. + * @return A new [Expression] representing the timestamp. */ @JvmStatic - fun unixMicrosToTimestamp(fieldName: String): Expr = - FunctionExpr("unix_micros_to_timestamp", evaluateUnixMicrosToTimestamp, fieldName) + fun unixMicrosToTimestamp(fieldName: String): Expression = + FunctionExpression("unix_micros_to_timestamp", evaluateUnixMicrosToTimestamp, fieldName) /** * Creates an expression that converts a timestamp expression to the number of microseconds * since the Unix epoch (1970-01-01 00:00:00 UTC). * + * ```kotlin + * // Convert the 'timestamp' field to microseconds since epoch. + * timestampToUnixMicros(field("timestamp")) + * ``` + * * @param expr The expression representing the timestamp. - * @return A new [Expr] representing the number of microseconds since epoch. + * @return A new [Expression] representing the number of microseconds since epoch. */ @JvmStatic - fun timestampToUnixMicros(expr: Expr): Expr = - FunctionExpr("timestamp_to_unix_micros", evaluateTimestampToUnixMicros, expr) + fun timestampToUnixMicros(expr: Expression): Expression = + FunctionExpression("timestamp_to_unix_micros", evaluateTimestampToUnixMicros, expr) /** * Creates an expression that converts a timestamp field to the number of microseconds since the * Unix epoch (1970-01-01 00:00:00 UTC). * + * ```kotlin + * // Convert the 'timestamp' field to microseconds since epoch. + * timestampToUnixMicros("timestamp") + * ``` + * * @param fieldName The name of the field that contains the timestamp. - * @return A new [Expr] representing the number of microseconds since epoch. + * @return A new [Expression] representing the number of microseconds since epoch. */ @JvmStatic - fun timestampToUnixMicros(fieldName: String): Expr = - FunctionExpr("timestamp_to_unix_micros", evaluateTimestampToUnixMicros, fieldName) + fun timestampToUnixMicros(fieldName: String): Expression = + FunctionExpression("timestamp_to_unix_micros", evaluateTimestampToUnixMicros, fieldName) /** * Creates an expression that interprets an expression as the number of milliseconds since the * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * + * ```kotlin + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * unixMillisToTimestamp(field("milliseconds")) + * ``` + * * @param expr The expression representing the number of milliseconds since epoch. - * @return A new [Expr] representing the timestamp. + * @return A new [Expression] representing the timestamp. */ @JvmStatic - fun unixMillisToTimestamp(expr: Expr): Expr = - FunctionExpr("unix_millis_to_timestamp", evaluateUnixMillisToTimestamp, expr) + fun unixMillisToTimestamp(expr: Expression): Expression = + FunctionExpression("unix_millis_to_timestamp", evaluateUnixMillisToTimestamp, expr) /** * Creates an expression that interprets a field's value as the number of milliseconds since the * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * + * ```kotlin + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * unixMillisToTimestamp("milliseconds") + * ``` + * * @param fieldName The name of the field containing the number of milliseconds since epoch. - * @return A new [Expr] representing the timestamp. + * @return A new [Expression] representing the timestamp. */ @JvmStatic - fun unixMillisToTimestamp(fieldName: String): Expr = - FunctionExpr("unix_millis_to_timestamp", evaluateUnixMillisToTimestamp, fieldName) + fun unixMillisToTimestamp(fieldName: String): Expression = + FunctionExpression("unix_millis_to_timestamp", evaluateUnixMillisToTimestamp, fieldName) /** * Creates an expression that converts a timestamp expression to the number of milliseconds * since the Unix epoch (1970-01-01 00:00:00 UTC). * + * ```kotlin + * // Convert the 'timestamp' field to milliseconds since epoch. + * timestampToUnixMillis(field("timestamp")) + * ``` + * * @param expr The expression representing the timestamp. - * @return A new [Expr] representing the number of milliseconds since epoch. + * @return A new [Expression] representing the number of milliseconds since epoch. */ @JvmStatic - fun timestampToUnixMillis(expr: Expr): Expr = - FunctionExpr("timestamp_to_unix_millis", evaluateTimestampToUnixMillis, expr) + fun timestampToUnixMillis(expr: Expression): Expression = + FunctionExpression("timestamp_to_unix_millis", evaluateTimestampToUnixMillis, expr) /** * Creates an expression that converts a timestamp field to the number of milliseconds since the * Unix epoch (1970-01-01 00:00:00 UTC). * + * ```kotlin + * // Convert the 'timestamp' field to milliseconds since epoch. + * timestampToUnixMillis("timestamp") + * ``` + * * @param fieldName The name of the field that contains the timestamp. - * @return A new [Expr] representing the number of milliseconds since epoch. + * @return A new [Expression] representing the number of milliseconds since epoch. */ @JvmStatic - fun timestampToUnixMillis(fieldName: String): Expr = - FunctionExpr("timestamp_to_unix_millis", evaluateTimestampToUnixMillis, fieldName) + fun timestampToUnixMillis(fieldName: String): Expression = + FunctionExpression("timestamp_to_unix_millis", evaluateTimestampToUnixMillis, fieldName) /** * Creates an expression that interprets an expression as the number of seconds since the Unix * epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * + * ```kotlin + * // Interpret the 'seconds' field as seconds since epoch. + * unixSecondsToTimestamp(field("seconds")) + * ``` + * * @param expr The expression representing the number of seconds since epoch. - * @return A new [Expr] representing the timestamp. + * @return A new [Expression] representing the timestamp. */ @JvmStatic - fun unixSecondsToTimestamp(expr: Expr): Expr = - FunctionExpr("unix_seconds_to_timestamp", evaluateUnixSecondsToTimestamp, expr) + fun unixSecondsToTimestamp(expr: Expression): Expression = + FunctionExpression("unix_seconds_to_timestamp", evaluateUnixSecondsToTimestamp, expr) /** * Creates an expression that interprets a field's value as the number of seconds since the Unix * epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * + * ```kotlin + * // Interpret the 'seconds' field as seconds since epoch. + * unixSecondsToTimestamp("seconds") + * ``` + * * @param fieldName The name of the field containing the number of seconds since epoch. - * @return A new [Expr] representing the timestamp. + * @return A new [Expression] representing the timestamp. */ @JvmStatic - fun unixSecondsToTimestamp(fieldName: String): Expr = - FunctionExpr("unix_seconds_to_timestamp", evaluateUnixSecondsToTimestamp, fieldName) + fun unixSecondsToTimestamp(fieldName: String): Expression = + FunctionExpression("unix_seconds_to_timestamp", evaluateUnixSecondsToTimestamp, fieldName) /** * Creates an expression that converts a timestamp expression to the number of seconds since the * Unix epoch (1970-01-01 00:00:00 UTC). * + * ```kotlin + * // Convert the 'timestamp' field to seconds since epoch. + * timestampToUnixSeconds(field("timestamp")) + * ``` + * * @param expr The expression representing the timestamp. - * @return A new [Expr] representing the number of seconds since epoch. + * @return A new [Expression] representing the number of seconds since epoch. */ @JvmStatic - fun timestampToUnixSeconds(expr: Expr): Expr = - FunctionExpr("timestamp_to_unix_seconds", evaluateTimestampToUnixSeconds, expr) + fun timestampToUnixSeconds(expr: Expression): Expression = + FunctionExpression("timestamp_to_unix_seconds", evaluateTimestampToUnixSeconds, expr) /** * Creates an expression that converts a timestamp field to the number of seconds since the Unix * epoch (1970-01-01 00:00:00 UTC). * + * ```kotlin + * // Convert the 'timestamp' field to seconds since epoch. + * timestampToUnixSeconds("timestamp") + * ``` + * * @param fieldName The name of the field that contains the timestamp. - * @return A new [Expr] representing the number of seconds since epoch. + * @return A new [Expression] representing the number of seconds since epoch. */ @JvmStatic - fun timestampToUnixSeconds(fieldName: String): Expr = - FunctionExpr("timestamp_to_unix_seconds", evaluateTimestampToUnixSeconds, fieldName) + fun timestampToUnixSeconds(fieldName: String): Expression = + FunctionExpression("timestamp_to_unix_seconds", evaluateTimestampToUnixSeconds, fieldName) /** * Creates an expression that adds a specified amount of time to a timestamp. * + * ```kotlin + * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. + * timestampAdd(field("timestamp"), field("unit"), field("amount")) + * ``` + * * @param timestamp The expression representing the timestamp. * @param unit The expression representing the unit of time to add. Valid units include * "microsecond", "millisecond", "second", "minute", "hour" and "day". * @param amount The expression representing the amount of time to add. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampAdd(timestamp: Expr, unit: Expr, amount: Expr): Expr = - FunctionExpr("timestamp_add", evaluateTimestampAdd, timestamp, unit, amount) + fun timestampAdd(timestamp: Expression, unit: Expression, amount: Expression): Expression = + FunctionExpression("timestamp_add", evaluateTimestampAdd, timestamp, unit, amount) /** * Creates an expression that adds a specified amount of time to a timestamp. * + * ```kotlin + * // Add 1 day to the 'timestamp' field. + * timestampAdd(field("timestamp"), "day", 1) + * ``` + * * @param timestamp The expression representing the timestamp. * @param unit The unit of time to add. Valid units include "microsecond", "millisecond", * "second", "minute", "hour" and "day". * @param amount The amount of time to add. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampAdd(timestamp: Expr, unit: String, amount: Long): Expr = - FunctionExpr("timestamp_add", evaluateTimestampAdd, timestamp, unit, amount) + fun timestampAdd(timestamp: Expression, unit: String, amount: Long): Expression = + FunctionExpression("timestamp_add", evaluateTimestampAdd, timestamp, unit, amount) /** * Creates an expression that adds a specified amount of time to a timestamp. * + * ```kotlin + * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. + * timestampAdd("timestamp", field("unit"), field("amount")) + * ``` + * * @param fieldName The name of the field that contains the timestamp. * @param unit The expression representing the unit of time to add. Valid units include * "microsecond", "millisecond", "second", "minute", "hour" and "day". * @param amount The expression representing the amount of time to add. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampAdd(fieldName: String, unit: Expr, amount: Expr): Expr = - FunctionExpr("timestamp_add", evaluateTimestampAdd, fieldName, unit, amount) + fun timestampAdd(fieldName: String, unit: Expression, amount: Expression): Expression = + FunctionExpression("timestamp_add", evaluateTimestampAdd, fieldName, unit, amount) /** * Creates an expression that adds a specified amount of time to a timestamp. * + * ```kotlin + * // Add 1 day to the 'timestamp' field. + * timestampAdd("timestamp", "day", 1) + * ``` + * * @param fieldName The name of the field that contains the timestamp. * @param unit The unit of time to add. Valid units include "microsecond", "millisecond", * "second", "minute", "hour" and "day". * @param amount The amount of time to add. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampAdd(fieldName: String, unit: String, amount: Long): Expr = - FunctionExpr("timestamp_add", evaluateTimestampAdd, fieldName, unit, amount) + fun timestampAdd(fieldName: String, unit: String, amount: Long): Expression = + FunctionExpression("timestamp_add", evaluateTimestampAdd, fieldName, unit, amount) /** * Creates an expression that subtracts a specified amount of time to a timestamp. * + * ```kotlin + * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. + * timestampSubtract(field("timestamp"), field("unit"), field("amount")) + * ``` + * * @param timestamp The expression representing the timestamp. * @param unit The expression representing the unit of time to subtract. Valid units include * "microsecond", "millisecond", "second", "minute", "hour" and "day". * @param amount The expression representing the amount of time to subtract. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampSub(timestamp: Expr, unit: Expr, amount: Expr): Expr = - FunctionExpr("timestamp_sub", evaluateTimestampSub, timestamp, unit, amount) + fun timestampSubtract(timestamp: Expression, unit: Expression, amount: Expression): Expression = + FunctionExpression("timestamp_subtract", evaluateTimestampSub, timestamp, unit, amount) /** * Creates an expression that subtracts a specified amount of time to a timestamp. * + * ```kotlin + * // Subtract 1 day from the 'timestamp' field. + * timestampSubtract(field("timestamp"), "day", 1) + * ``` + * * @param timestamp The expression representing the timestamp. * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", * "second", "minute", "hour" and "day". * @param amount The amount of time to subtract. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampSub(timestamp: Expr, unit: String, amount: Long): Expr = - FunctionExpr("timestamp_sub", evaluateTimestampSub, timestamp, unit, amount) + fun timestampSubtract(timestamp: Expression, unit: String, amount: Long): Expression = + FunctionExpression("timestamp_subtract", evaluateTimestampSub, timestamp, unit, amount) /** * Creates an expression that subtracts a specified amount of time to a timestamp. * + * ```kotlin + * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. + * timestampSubtract("timestamp", field("unit"), field("amount")) + * ``` + * * @param fieldName The name of the field that contains the timestamp. * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", * "second", "minute", "hour" and "day". * @param amount The amount of time to subtract. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampSub(fieldName: String, unit: Expr, amount: Expr): Expr = - FunctionExpr("timestamp_sub", evaluateTimestampSub, fieldName, unit, amount) + fun timestampSubtract(fieldName: String, unit: Expression, amount: Expression): Expression = + FunctionExpression("timestamp_subtract", evaluateTimestampSub, fieldName, unit, amount) /** * Creates an expression that subtracts a specified amount of time to a timestamp. * + * ```kotlin + * // Subtract 1 day from the 'timestamp' field. + * timestampSubtract("timestamp", "day", 1) + * ``` + * * @param fieldName The name of the field that contains the timestamp. * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", * "second", "minute", "hour" and "day". * @param amount The amount of time to subtract. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ @JvmStatic - fun timestampSub(fieldName: String, unit: String, amount: Long): Expr = - FunctionExpr("timestamp_sub", evaluateTimestampSub, fieldName, unit, amount) + fun timestampSubtract(fieldName: String, unit: String, amount: Long): Expression = + FunctionExpression("timestamp_subtract", evaluateTimestampSub, fieldName, unit, amount) /** * Creates an expression that checks if two expressions are equal. * + * ```kotlin + * // Check if the 'age' field is equal to an expression + * equal(field("age"), field("minAge").add(10)) + * ``` + * * @param left The first expression to compare. * @param right The second expression to compare to. - * @return A new [BooleanExpr] representing the equality comparison. + * @return A new [BooleanExpression] representing the equality comparison. */ @JvmStatic - fun eq(left: Expr, right: Expr): BooleanExpr = BooleanExpr("eq", evaluateEq, left, right) + fun equal(left: Expression, right: Expression): BooleanExpression = + BooleanExpression("equal", evaluateEq, left, right) /** * Creates an expression that checks if an expression is equal to a value. * + * ```kotlin + * // Check if the 'age' field is equal to 21 + * equal(field("age"), 21) + * ``` + * * @param left The first expression to compare. * @param right The value to compare to. - * @return A new [BooleanExpr] representing the equality comparison. + * @return A new [BooleanExpression] representing the equality comparison. */ @JvmStatic - fun eq(left: Expr, right: Any): BooleanExpr = BooleanExpr("eq", evaluateEq, left, right) + fun equal(left: Expression, right: Any): BooleanExpression = + BooleanExpression("equal", evaluateEq, left, right) /** * Creates an expression that checks if a field's value is equal to an expression. * + * ```kotlin + * // Check if the 'age' field is equal to the 'limit' field + * equal("age", field("limit")) + * ``` + * * @param fieldName The field name to compare. * @param expression The expression to compare to. - * @return A new [BooleanExpr] representing the equality comparison. + * @return A new [BooleanExpression] representing the equality comparison. */ @JvmStatic - fun eq(fieldName: String, expression: Expr): BooleanExpr = - BooleanExpr("eq", evaluateEq, fieldName, expression) + fun equal(fieldName: String, expression: Expression): BooleanExpression = + BooleanExpression("equal", evaluateEq, fieldName, expression) /** * Creates an expression that checks if a field's value is equal to another value. * + * ```kotlin + * // Check if the 'city' field is equal to string constant "London" + * equal("city", "London") + * ``` + * * @param fieldName The field name to compare. * @param value The value to compare to. - * @return A new [BooleanExpr] representing the equality comparison. + * @return A new [BooleanExpression] representing the equality comparison. */ @JvmStatic - fun eq(fieldName: String, value: Any): BooleanExpr = - BooleanExpr("eq", evaluateEq, fieldName, value) + fun equal(fieldName: String, value: Any): BooleanExpression = + BooleanExpression("equal", evaluateEq, fieldName, value) /** * Creates an expression that checks if two expressions are not equal. * + * ```kotlin + * // Check if the 'status' field is not equal to the value of the 'otherStatus' field + * notEqual(field("status"), field("otherStatus")) + * ``` + * * @param left The first expression to compare. * @param right The second expression to compare to. - * @return A new [BooleanExpr] representing the inequality comparison. + * @return A new [BooleanExpression] representing the inequality comparison. */ @JvmStatic - fun neq(left: Expr, right: Expr): BooleanExpr = BooleanExpr("neq", evaluateNeq, left, right) + fun notEqual(left: Expression, right: Expression): BooleanExpression = + BooleanExpression("not_equal", evaluateNeq, left, right) /** * Creates an expression that checks if an expression is not equal to a value. * + * ```kotlin + * // Check if the 'status' field is not equal to "completed" + * notEqual(field("status"), "completed") + * ``` + * * @param left The first expression to compare. * @param right The value to compare to. - * @return A new [BooleanExpr] representing the inequality comparison. + * @return A new [BooleanExpression] representing the inequality comparison. */ @JvmStatic - fun neq(left: Expr, right: Any): BooleanExpr = BooleanExpr("neq", evaluateNeq, left, right) + fun notEqual(left: Expression, right: Any): BooleanExpression = + BooleanExpression("not_equal", evaluateNeq, left, right) /** * Creates an expression that checks if a field's value is not equal to an expression. * + * ```kotlin + * // Check if the 'status' field is not equal to the value of the 'otherStatus' field + * notEqual("status", field("otherStatus")) + * ``` + * * @param fieldName The field name to compare. * @param expression The expression to compare to. - * @return A new [BooleanExpr] representing the inequality comparison. + * @return A new [BooleanExpression] representing the inequality comparison. */ @JvmStatic - fun neq(fieldName: String, expression: Expr): BooleanExpr = - BooleanExpr("neq", evaluateNeq, fieldName, expression) + fun notEqual(fieldName: String, expression: Expression): BooleanExpression = + BooleanExpression("not_equal", evaluateNeq, fieldName, expression) /** * Creates an expression that checks if a field's value is not equal to another value. * + * ```kotlin + * // Check if the 'status' field is not equal to "completed" + * notEqual("status", "completed") + * + * // Check if the 'country' field is not equal to "USA" + * notEqual("country", "USA") + * ``` + * * @param fieldName The field name to compare. * @param value The value to compare to. - * @return A new [BooleanExpr] representing the inequality comparison. + * @return A new [BooleanExpression] representing the inequality comparison. */ @JvmStatic - fun neq(fieldName: String, value: Any): BooleanExpr = - BooleanExpr("neq", evaluateNeq, fieldName, value) + fun notEqual(fieldName: String, value: Any): BooleanExpression = + BooleanExpression("not_equal", evaluateNeq, fieldName, value) /** * Creates an expression that checks if the first expression is greater than the second * expression. * + * ```kotlin + * // Check if the 'age' field is greater than the 'limit' field + * greaterThan(field("age"), field("limit")) + * ``` + * * @param left The first expression to compare. * @param right The second expression to compare to. - * @return A new [BooleanExpr] representing the greater than comparison. + * @return A new [BooleanExpression] representing the greater than comparison. */ @JvmStatic - fun gt(left: Expr, right: Expr): BooleanExpr = BooleanExpr("gt", evaluateGt, left, right) + fun greaterThan(left: Expression, right: Expression): BooleanExpression = + BooleanExpression("greater_than", evaluateGt, left, right) /** * Creates an expression that checks if an expression is greater than a value. * + * ```kotlin + * // Check if the 'price' field is greater than 100 + * greaterThan(field("price"), 100) + * ``` + * * @param left The first expression to compare. * @param right The value to compare to. - * @return A new [BooleanExpr] representing the greater than comparison. + * @return A new [BooleanExpression] representing the greater than comparison. */ @JvmStatic - fun gt(left: Expr, right: Any): BooleanExpr = BooleanExpr("gt", evaluateGt, left, right) + fun greaterThan(left: Expression, right: Any): BooleanExpression = + BooleanExpression("greater_than", evaluateGt, left, right) /** * Creates an expression that checks if a field's value is greater than an expression. * + * ```kotlin + * // Check if the 'age' field is greater than the 'limit' field + * greaterThan("age", field("limit")) + * ``` + * * @param fieldName The field name to compare. * @param expression The expression to compare to. - * @return A new [BooleanExpr] representing the greater than comparison. + * @return A new [BooleanExpression] representing the greater than comparison. */ @JvmStatic - fun gt(fieldName: String, expression: Expr): BooleanExpr = - BooleanExpr("gt", evaluateGt, fieldName, expression) + fun greaterThan(fieldName: String, expression: Expression): BooleanExpression = + BooleanExpression("greater_than", evaluateGt, fieldName, expression) /** * Creates an expression that checks if a field's value is greater than another value. * + * ```kotlin + * // Check if the 'price' field is greater than 100 + * greaterThan("price", 100) + * ``` + * * @param fieldName The field name to compare. * @param value The value to compare to. - * @return A new [BooleanExpr] representing the greater than comparison. + * @return A new [BooleanExpression] representing the greater than comparison. */ @JvmStatic - fun gt(fieldName: String, value: Any): BooleanExpr = - BooleanExpr("gt", evaluateGt, fieldName, value) + fun greaterThan(fieldName: String, value: Any): BooleanExpression = + BooleanExpression("greater_than", evaluateGt, fieldName, value) /** * Creates an expression that checks if the first expression is greater than or equal to the * second expression. * + * ```kotlin + * // Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 + * greaterThanOrEqual(field("quantity"), field("requirement").add(1)) + * ``` + * * @param left The first expression to compare. * @param right The second expression to compare to. - * @return A new [BooleanExpr] representing the greater than or equal to comparison. + * @return A new [BooleanExpression] representing the greater than or equal to comparison. */ @JvmStatic - fun gte(left: Expr, right: Expr): BooleanExpr = BooleanExpr("gte", evaluateGte, left, right) + fun greaterThanOrEqual(left: Expression, right: Expression): BooleanExpression = + BooleanExpression("greater_than_or_equal", evaluateGte, left, right) /** * Creates an expression that checks if an expression is greater than or equal to a value. * + * ```kotlin + * // Check if the 'score' field is greater than or equal to 80 + * greaterThanOrEqual(field("score"), 80) + * ``` + * * @param left The first expression to compare. * @param right The value to compare to. - * @return A new [BooleanExpr] representing the greater than or equal to comparison. + * @return A new [BooleanExpression] representing the greater than or equal to comparison. */ @JvmStatic - fun gte(left: Expr, right: Any): BooleanExpr = BooleanExpr("gte", evaluateGte, left, right) + fun greaterThanOrEqual(left: Expression, right: Any): BooleanExpression = + BooleanExpression("greater_than_or_equal", evaluateGte, left, right) /** * Creates an expression that checks if a field's value is greater than or equal to an * expression. * + * ```kotlin + * // Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 + * greaterThanOrEqual("quantity", field("requirement").add(1)) + * ``` + * * @param fieldName The field name to compare. * @param expression The expression to compare to. - * @return A new [BooleanExpr] representing the greater than or equal to comparison. + * @return A new [BooleanExpression] representing the greater than or equal to comparison. */ @JvmStatic - fun gte(fieldName: String, expression: Expr): BooleanExpr = - BooleanExpr("gte", evaluateGte, fieldName, expression) + fun greaterThanOrEqual(fieldName: String, expression: Expression): BooleanExpression = + BooleanExpression("greater_than_or_equal", evaluateGte, fieldName, expression) /** * Creates an expression that checks if a field's value is greater than or equal to another * value. * + * ```kotlin + * // Check if the 'score' field is greater than or equal to 80 + * greaterThanOrEqual("score", 80) + * ``` + * * @param fieldName The field name to compare. * @param value The value to compare to. - * @return A new [BooleanExpr] representing the greater than or equal to comparison. + * @return A new [BooleanExpression] representing the greater than or equal to comparison. */ @JvmStatic - fun gte(fieldName: String, value: Any): BooleanExpr = - BooleanExpr("gte", evaluateGte, fieldName, value) + fun greaterThanOrEqual(fieldName: String, value: Any): BooleanExpression = + BooleanExpression("greater_than_or_equal", evaluateGte, fieldName, value) /** * Creates an expression that checks if the first expression is less than the second expression. * + * ```kotlin + * // Check if the 'age' field is less than 'limit' + * lessThan(field("age"), field("limit")) + * ``` + * * @param left The first expression to compare. * @param right The second expression to compare to. - * @return A new [BooleanExpr] representing the less than comparison. + * @return A new [BooleanExpression] representing the less than comparison. */ @JvmStatic - fun lt(left: Expr, right: Expr): BooleanExpr = BooleanExpr("lt", evaluateLt, left, right) + fun lessThan(left: Expression, right: Expression): BooleanExpression = + BooleanExpression("less_than", evaluateLt, left, right) /** * Creates an expression that checks if an expression is less than a value. * + * ```kotlin + * // Check if the 'price' field is less than 50 + * lessThan(field("price"), 50) + * ``` + * * @param left The first expression to compare. * @param right The value to compare to. - * @return A new [BooleanExpr] representing the less than comparison. + * @return A new [BooleanExpression] representing the less than comparison. */ @JvmStatic - fun lt(left: Expr, right: Any): BooleanExpr = BooleanExpr("lt", evaluateLt, left, right) + fun lessThan(left: Expression, right: Any): BooleanExpression = + BooleanExpression("less_than", evaluateLt, left, right) /** * Creates an expression that checks if a field's value is less than an expression. * + * ```kotlin + * // Check if the 'age' field is less than 'limit' + * lessThan("age", field("limit")) + * ``` + * * @param fieldName The field name to compare. * @param expression The expression to compare to. - * @return A new [BooleanExpr] representing the less than comparison. + * @return A new [BooleanExpression] representing the less than comparison. */ @JvmStatic - fun lt(fieldName: String, expression: Expr): BooleanExpr = - BooleanExpr("lt", evaluateLt, fieldName, expression) + fun lessThan(fieldName: String, expression: Expression): BooleanExpression = + BooleanExpression("less_than", evaluateLt, fieldName, expression) /** * Creates an expression that checks if a field's value is less than another value. * + * ```kotlin + * // Check if the 'price' field is less than 50 + * lessThan("price", 50) + * ``` + * * @param fieldName The field name to compare. * @param value The value to compare to. - * @return A new [BooleanExpr] representing the less than comparison. + * @return A new [BooleanExpression] representing the less than comparison. */ @JvmStatic - fun lt(fieldName: String, value: Any): BooleanExpr = - BooleanExpr("lt", evaluateLt, fieldName, value) + fun lessThan(fieldName: String, value: Any): BooleanExpression = + BooleanExpression("less_than", evaluateLt, fieldName, value) /** * Creates an expression that checks if the first expression is less than or equal to the second * expression. * + * ```kotlin + * // Check if the 'quantity' field is less than or equal to 20 + * lessThanOrEqual(field("quantity"), constant(20)) + * ``` + * * @param left The first expression to compare. * @param right The second expression to compare to. - * @return A new [BooleanExpr] representing the less than or equal to comparison. + * @return A new [BooleanExpression] representing the less than or equal to comparison. */ @JvmStatic - fun lte(left: Expr, right: Expr): BooleanExpr = BooleanExpr("lte", evaluateLte, left, right) + fun lessThanOrEqual(left: Expression, right: Expression): BooleanExpression = + BooleanExpression("less_than_or_equal", evaluateLte, left, right) /** * Creates an expression that checks if an expression is less than or equal to a value. * + * ```kotlin + * // Check if the 'score' field is less than or equal to 70 + * lessThanOrEqual(field("score"), 70) + * ``` + * * @param left The first expression to compare. * @param right The value to compare to. - * @return A new [BooleanExpr] representing the less than or equal to comparison. + * @return A new [BooleanExpression] representing the less than or equal to comparison. */ @JvmStatic - fun lte(left: Expr, right: Any): BooleanExpr = BooleanExpr("lte", evaluateLte, left, right) + fun lessThanOrEqual(left: Expression, right: Any): BooleanExpression = + BooleanExpression("less_than_or_equal", evaluateLte, left, right) /** * Creates an expression that checks if a field's value is less than or equal to an expression. * + * ```kotlin + * // Check if the 'quantity' field is less than or equal to 20 + * lessThanOrEqual("quantity", constant(20)) + * ``` + * * @param fieldName The field name to compare. * @param expression The expression to compare to. - * @return A new [BooleanExpr] representing the less than or equal to comparison. + * @return A new [BooleanExpression] representing the less than or equal to comparison. */ @JvmStatic - fun lte(fieldName: String, expression: Expr): BooleanExpr = - BooleanExpr("lte", evaluateLte, fieldName, expression) + fun lessThanOrEqual(fieldName: String, expression: Expression): BooleanExpression = + BooleanExpression("less_than_or_equal", evaluateLte, fieldName, expression) /** * Creates an expression that checks if a field's value is less than or equal to another value. * + * ```kotlin + * // Check if the 'score' field is less than or equal to 70 + * lessThanOrEqual("score", 70) + * ``` + * * @param fieldName The field name to compare. * @param value The value to compare to. - * @return A new [BooleanExpr] representing the less than or equal to comparison. + * @return A new [BooleanExpression] representing the less than or equal to comparison. + */ + @JvmStatic + fun lessThanOrEqual(fieldName: String, value: Any): BooleanExpression = + BooleanExpression("less_than_or_equal", evaluateLte, fieldName, value) + + /** + * Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed. + * + * ```kotlin + * // Concatenate the 'firstName' and 'lastName' fields with a space in between. + * concat(field("firstName"), " ", field("lastName")) + * ``` + * + * @param first The first expression to concatenate. + * @param second The second expression to concatenate. + * @param others Additional expressions to concatenate. + * @return A new [Expression] representing the concatenation. */ @JvmStatic - fun lte(fieldName: String, value: Any): BooleanExpr = - BooleanExpr("lte", evaluateLte, fieldName, value) + fun concat(first: Expression, second: Expression, vararg others: Any): Expression = + FunctionExpression("concat", notImplemented, first, second, *others) + + /** + * Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed. + * + * ```kotlin + * // Concatenate a field with a literal string. + * concat(field("firstName"), "Doe") + * ``` + * + * @param first The first expression to concatenate. + * @param second The second value to concatenate. + * @param others Additional values to concatenate. + * @return A new [Expression] representing the concatenation. + */ + @JvmStatic + fun concat(first: Expression, second: Any, vararg others: Any): Expression = + FunctionExpression("concat", notImplemented, first, second, *others) + + /** + * Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed. + * + * ```kotlin + * // Concatenate a field name with an expression. + * concat("firstName", field("lastName")) + * ``` + * + * @param first The name of the field containing the first value to concatenate. + * @param second The second expression to concatenate. + * @param others Additional expressions to concatenate. + * @return A new [Expression] representing the concatenation. + */ + @JvmStatic + fun concat(first: String, second: Expression, vararg others: Any): Expression = + FunctionExpression("concat", notImplemented, first, second, *others) + + /** + * Creates an expression that concatenates strings, arrays, or blobs. Types cannot be mixed. + * + * ```kotlin + * // Concatenate a field name with a literal string. + * concat("firstName", "Doe") + * ``` + * + * @param first The name of the field containing the first value to concatenate. + * @param second The second value to concatenate. + * @param others Additional values to concatenate. + * @return A new [Expression] representing the concatenation. + */ + @JvmStatic + fun concat(first: String, second: Any, vararg others: Any): Expression = + FunctionExpression("concat", notImplemented, first, second, *others) /** * Creates an expression that creates a Firestore array value from an input array. * + * ```kotlin + * // Create an array of numbers + * array(1, 2, 3) + * + * // Create an array containing a field value and a constant + * array(field("quantity"), 10) + * ``` + * * @param elements The input array to evaluate in the expression. - * @return A new [Expr] representing the array function. + * @return A new [Expression] representing the array function. */ @JvmStatic - fun array(vararg elements: Any?): Expr = - FunctionExpr("array", evaluateArray, elements.map(::toExprOrConstant).toTypedArray()) + fun array(vararg elements: Any?): Expression = + FunctionExpression( + "array", + evaluateArray, + elements.map(::toExprOrConstant).toTypedArray() + ) /** * Creates an expression that creates a Firestore array value from an input array. * * @param elements The input array to evaluate in the expression. - * @return A new [Expr] representing the array function. + * @return A new [Expression] representing the array function. */ @JvmStatic - fun array(elements: List): Expr = - FunctionExpr("array", evaluateArray, elements.map(::toExprOrConstant).toTypedArray()) + fun array(elements: List): Expression = + FunctionExpression("array", evaluateArray, elements.map(::toExprOrConstant).toTypedArray()) /** * Creates an expression that concatenates an array with other arrays. * + * ```kotlin + * // Combine the 'items' array with another array field. + * arrayConcat(field("items"), field("otherItems")) + * ``` + * * @param firstArray The first array expression to concatenate to. * @param secondArray An expression that evaluates to array to concatenate. * @param otherArrays Optional additional array expressions or array literals to concatenate. - * @return A new [Expr] representing the arrayConcat operation. + * @return A new [Expression] representing the arrayConcat operation. */ @JvmStatic - fun arrayConcat(firstArray: Expr, secondArray: Expr, vararg otherArrays: Any): Expr = - FunctionExpr("array_concat", notImplemented, firstArray, secondArray, *otherArrays) + fun arrayConcat( + firstArray: Expression, + secondArray: Expression, + vararg otherArrays: Any + ): Expression = + FunctionExpression("array_concat", notImplemented, firstArray, secondArray, *otherArrays) /** * Creates an expression that concatenates an array with other arrays. * + * ```kotlin + * // Combine the 'items' array with another array field. + * arrayConcat(field("items"), field("otherItems")) + * ``` + * * @param firstArray The first array expression to concatenate to. * @param secondArray An array expression or array literal to concatenate. * @param otherArrays Optional additional array expressions or array literals to concatenate. - * @return A new [Expr] representing the arrayConcat operation. + * @return A new [Expression] representing the arrayConcat operation. */ @JvmStatic - fun arrayConcat(firstArray: Expr, secondArray: Any, vararg otherArrays: Any): Expr = - FunctionExpr("array_concat", notImplemented, firstArray, secondArray, *otherArrays) + fun arrayConcat(firstArray: Expression, secondArray: Any, vararg otherArrays: Any): Expression = + FunctionExpression("array_concat", notImplemented, firstArray, secondArray, *otherArrays) /** * Creates an expression that concatenates a field's array value with other arrays. * + * ```kotlin + * // Combine the 'items' array with another array field. + * arrayConcat("items", field("otherItems")) + * ``` + * * @param firstArrayField The name of field that contains first array to concatenate to. * @param secondArray An expression that evaluates to array to concatenate. * @param otherArrays Optional additional array expressions or array literals to concatenate. - * @return A new [Expr] representing the arrayConcat operation. + * @return A new [Expression] representing the arrayConcat operation. */ @JvmStatic - fun arrayConcat(firstArrayField: String, secondArray: Expr, vararg otherArrays: Any): Expr = - FunctionExpr("array_concat", notImplemented, firstArrayField, secondArray, *otherArrays) + fun arrayConcat( + firstArrayField: String, + secondArray: Expression, + vararg otherArrays: Any + ): Expression = + FunctionExpression("array_concat", notImplemented, firstArrayField, secondArray, *otherArrays) /** * Creates an expression that concatenates a field's array value with other arrays. * + * ```kotlin + * // Combine the 'items' array with a literal array. + * arrayConcat("items", listOf("a", "b")) + * ``` + * * @param firstArrayField The name of field that contains first array to concatenate to. * @param secondArray An array expression or array literal to concatenate. * @param otherArrays Optional additional array expressions or array literals to concatenate. - * @return A new [Expr] representing the arrayConcat operation. + * @return A new [Expression] representing the arrayConcat operation. */ @JvmStatic - fun arrayConcat(firstArrayField: String, secondArray: Any, vararg otherArrays: Any): Expr = - FunctionExpr("array_concat", notImplemented, firstArrayField, secondArray, *otherArrays) + fun arrayConcat( + firstArrayField: String, + secondArray: Any, + vararg otherArrays: Any + ): Expression = + FunctionExpression("array_concat", notImplemented, firstArrayField, secondArray, *otherArrays) /** * Reverses the order of elements in the [array]. * + * ```kotlin + * // Reverse the value of the 'myArray' field. + * arrayReverse(field("myArray")) + * ``` + * * @param array The array expression to reverse. - * @return A new [Expr] representing the arrayReverse operation. + * @return A new [Expression] representing the arrayReverse operation. */ @JvmStatic - fun arrayReverse(array: Expr): Expr = FunctionExpr("array_reverse", notImplemented, array) + fun arrayReverse(array: Expression): Expression = + FunctionExpression("array_reverse", notImplemented, array) /** * Reverses the order of elements in the array field. * + * ```kotlin + * // Reverse the value of the 'myArray' field. + * arrayReverse("myArray") + * ``` + * * @param arrayFieldName The name of field that contains the array to reverse. - * @return A new [Expr] representing the arrayReverse operation. + * @return A new [Expression] representing the arrayReverse operation. */ @JvmStatic - fun arrayReverse(arrayFieldName: String): Expr = - FunctionExpr("array_reverse", notImplemented, arrayFieldName) + fun arrayReverse(arrayFieldName: String): Expression = + FunctionExpression("array_reverse", notImplemented, arrayFieldName) + + /** + * Creates an expression that returns the sum of the elements in an array. + * + * ```kotlin + * // Get the sum of elements in the 'scores' array. + * arraySum(field("scores")) + * ``` + * + * @param array The array expression to sum. + * @return A new [Expression] representing the sum of the array elements. + */ + @JvmStatic + fun arraySum(array: Expression): Expression = FunctionExpression("sum", notImplemented, array) + + /** + * Creates an expression that returns the sum of the elements in an array field. + * + * ```kotlin + * // Get the sum of elements in the 'scores' array. + * arraySum("scores") + * ``` + * + * @param arrayFieldName The name of the field containing the array to sum. + * @return A new [Expression] representing the sum of the array elements. + */ + @JvmStatic + fun arraySum(arrayFieldName: String): Expression = + FunctionExpression("sum", notImplemented, arrayFieldName) /** * Creates an expression that checks if the array contains a specific [element]. * * @param array The array expression to check. * @param element The element to search for in the array. - * @return A new [BooleanExpr] representing the arrayContains operation. + * @return A new [BooleanExpression] representing the arrayContains operation. */ @JvmStatic - fun arrayContains(array: Expr, element: Expr): BooleanExpr = - BooleanExpr("array_contains", evaluateArrayContains, array, element) + fun arrayContains(array: Expression, element: Expression): BooleanExpression = + BooleanExpression("array_contains", evaluateArrayContains, array, element) /** * Creates an expression that checks if the array field contains a specific [element]. * + * ```kotlin + * // Check if the 'sizes' array contains the value from the 'selectedSize' field + * arrayContains("sizes", field("selectedSize")) + * ``` + * * @param arrayFieldName The name of field that contains array to check. * @param element The element to search for in the array. - * @return A new [BooleanExpr] representing the arrayContains operation. + * @return A new [BooleanExpression] representing the arrayContains operation. */ @JvmStatic - fun arrayContains(arrayFieldName: String, element: Expr) = - BooleanExpr("array_contains", evaluateArrayContains, arrayFieldName, element) + fun arrayContains(arrayFieldName: String, element: Expression) = + BooleanExpression("array_contains", evaluateArrayContains, arrayFieldName, element) /** * Creates an expression that checks if the [array] contains a specific [element]. * + * ```kotlin + * // Check if the 'sizes' array contains the value from the 'selectedSize' field + * arrayContains(field("sizes"), field("selectedSize")) + * + * // Check if the 'colors' array contains "red" + * arrayContains(field("colors"), "red") + * ``` + * * @param array The array expression to check. * @param element The element to search for in the array. - * @return A new [BooleanExpr] representing the arrayContains operation. + * @return A new [BooleanExpression] representing the arrayContains operation. */ @JvmStatic - fun arrayContains(array: Expr, element: Any): BooleanExpr = - BooleanExpr("array_contains", evaluateArrayContains, array, element) + fun arrayContains(array: Expression, element: Any): BooleanExpression = + BooleanExpression("array_contains", evaluateArrayContains, array, element) /** * Creates an expression that checks if the array field contains a specific [element]. * + * ```kotlin + * // Check if the 'colors' array contains "red" + * arrayContains("colors", "red") + * ``` + * * @param arrayFieldName The name of field that contains array to check. * @param element The element to search for in the array. - * @return A new [BooleanExpr] representing the arrayContains operation. + * @return A new [BooleanExpression] representing the arrayContains operation. */ @JvmStatic fun arrayContains(arrayFieldName: String, element: Any) = - BooleanExpr("array_contains", evaluateArrayContains, arrayFieldName, element) + BooleanExpression("array_contains", evaluateArrayContains, arrayFieldName, element) /** * Creates an expression that checks if [array] contains all the specified [values]. * + * ```kotlin + * // Check if the 'tags' array contains both the value in field "tag1" and the literal value "tag2" + * arrayContainsAll(field("tags"), listOf(field("tag1"), "tag2")) + * ``` + * * @param array The array expression to check. * @param values The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAll operation. + * @return A new [BooleanExpression] representing the arrayContainsAll operation. */ @JvmStatic - fun arrayContainsAll(array: Expr, values: List) = arrayContainsAll(array, array(values)) + fun arrayContainsAll(array: Expression, values: List) = + arrayContainsAll(array, array(values)) /** * Creates an expression that checks if [array] contains all elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'tags' array contains both of the values from field "tag1" and the literal value "tag2" + * arrayContainsAll(field("tags"), array(field("tag1"), "tag2")) + * ``` + * * @param array The array expression to check. * @param arrayExpression The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAll operation. + * @return A new [BooleanExpression] representing the arrayContainsAll operation. */ @JvmStatic - fun arrayContainsAll(array: Expr, arrayExpression: Expr) = - BooleanExpr("array_contains_all", evaluateArrayContainsAll, array, arrayExpression) + fun arrayContainsAll(array: Expression, arrayExpression: Expression) = + BooleanExpression("array_contains_all", evaluateArrayContainsAll, array, arrayExpression) /** * Creates an expression that checks if array field contains all the specified [values]. * + * ```kotlin + * // Check if the 'tags' array contains both "internal" and "public" + * arrayContainsAll("tags", listOf("internal", "public")) + * ``` + * * @param arrayFieldName The name of field that contains array to check. * @param values The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAll operation. + * @return A new [BooleanExpression] representing the arrayContainsAll operation. */ @JvmStatic fun arrayContainsAll(arrayFieldName: String, values: List) = - BooleanExpr("array_contains_all", evaluateArrayContainsAll, arrayFieldName, array(values)) + BooleanExpression( + "array_contains_all", + evaluateArrayContainsAll, + arrayFieldName, + array(values) + ) /** * Creates an expression that checks if array field contains all elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'permissions' array contains all the required permissions + * arrayContainsAll("permissions", field("requiredPermissions")) + * ``` + * * @param arrayFieldName The name of field that contains array to check. * @param arrayExpression The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAll operation. + * @return A new [BooleanExpression] representing the arrayContainsAll operation. */ @JvmStatic - fun arrayContainsAll(arrayFieldName: String, arrayExpression: Expr) = - BooleanExpr("array_contains_all", evaluateArrayContainsAll, arrayFieldName, arrayExpression) + fun arrayContainsAll(arrayFieldName: String, arrayExpression: Expression) = + BooleanExpression( + "array_contains_all", + evaluateArrayContainsAll, + arrayFieldName, + arrayExpression + ) /** * Creates an expression that checks if [array] contains any of the specified [values]. * + * ```kotlin + * // Check if the 'categories' array contains either values from field "cate1" or "cate2" + * arrayContainsAny(field("categories"), listOf(field("cate1"), field("cate2"))) + * ``` + * * @param array The array expression to check. * @param values The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAny operation. + * @return A new [BooleanExpression] representing the arrayContainsAny operation. */ @JvmStatic - fun arrayContainsAny(array: Expr, values: List) = - BooleanExpr("array_contains_any", evaluateArrayContainsAny, array, array(values)) + fun arrayContainsAny(array: Expression, values: List) = + BooleanExpression("array_contains_any", evaluateArrayContainsAny, array, array(values)) /** * Creates an expression that checks if [array] contains any elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * arrayContainsAny(field("groups"), array(field("userGroup"), "guest")) + * ``` + * * @param array The array expression to check. * @param arrayExpression The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAny operation. + * @return A new [BooleanExpression] representing the arrayContainsAny operation. */ @JvmStatic - fun arrayContainsAny(array: Expr, arrayExpression: Expr) = - BooleanExpr("array_contains_any", evaluateArrayContainsAny, array, arrayExpression) + fun arrayContainsAny(array: Expression, arrayExpression: Expression) = + BooleanExpression("array_contains_any", evaluateArrayContainsAny, array, arrayExpression) /** * Creates an expression that checks if array field contains any of the specified [values]. * + * ```kotlin + * // Check if the 'roles' array contains "admin" or "editor" + * arrayContainsAny("roles", listOf("admin", "editor")) + * ``` + * * @param arrayFieldName The name of field that contains array to check. * @param values The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAny operation. + * @return A new [BooleanExpression] representing the arrayContainsAny operation. */ @JvmStatic fun arrayContainsAny(arrayFieldName: String, values: List) = - BooleanExpr("array_contains_any", evaluateArrayContainsAny, arrayFieldName, array(values)) + BooleanExpression( + "array_contains_any", + evaluateArrayContainsAny, + arrayFieldName, + array(values) + ) /** * Creates an expression that checks if array field contains any elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'userGroups' array contains any of the 'targetGroups' + * arrayContainsAny("userGroups", field("targetGroups")) + * ``` + * * @param arrayFieldName The name of field that contains array to check. * @param arrayExpression The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAny operation. + * @return A new [BooleanExpression] representing the arrayContainsAny operation. */ @JvmStatic - fun arrayContainsAny(arrayFieldName: String, arrayExpression: Expr) = - BooleanExpr("array_contains_any", evaluateArrayContainsAny, arrayFieldName, arrayExpression) + fun arrayContainsAny(arrayFieldName: String, arrayExpression: Expression) = + BooleanExpression( + "array_contains_any", + evaluateArrayContainsAny, + arrayFieldName, + arrayExpression + ) /** * Creates an expression that calculates the length of an [array] expression. * + * ```kotlin + * // Get the number of items in the 'cart' array + * arrayLength(field("cart")) + * ``` + * * @param array The array expression to calculate the length of. - * @return A new [Expr] representing the length of the array. + * @return A new [Expression] representing the length of the array. */ @JvmStatic - fun arrayLength(array: Expr): Expr = FunctionExpr("array_length", evaluateArrayLength, array) + fun arrayLength(array: Expression): Expression = + FunctionExpression("array_length", evaluateArrayLength, array) /** * Creates an expression that calculates the length of an array field. * + * ```kotlin + * // Get the number of items in the 'cart' array + * arrayLength("cart") + * ``` + * * @param arrayFieldName The name of the field containing an array to calculate the length of. - * @return A new [Expr] representing the length of the array. + * @return A new [Expression] representing the length of the array. */ @JvmStatic - fun arrayLength(arrayFieldName: String): Expr = - FunctionExpr("array_length", evaluateArrayLength, arrayFieldName) + fun arrayLength(arrayFieldName: String): Expression = + FunctionExpression("array_length", evaluateArrayLength, arrayFieldName) /** * Creates an expression that indexes into an array from the beginning or end and return the * element. If the offset exceeds the array length, an error is returned. A negative offset, * starts from the end. * - * @param array An [Expr] evaluating to an array. - * @param offset An Expr evaluating to the index of the element to return. - * @return A new [Expr] representing the arrayOffset operation. + * ```kotlin + * // Return the value in the tags field array at index specified by field 'favoriteTag'. + * arrayGet(field("tags"), field("favoriteTag")) + * ``` + * + * @param array An [Expression] evaluating to an array. + * @param offset An Expression evaluating to the index of the element to return. + * @return A new [Expression] representing the arrayOffset operation. */ @JvmStatic - fun arrayGet(array: Expr, offset: Expr): Expr = - FunctionExpr("array_get", notImplemented, array, offset) + fun arrayGet(array: Expression, offset: Expression): Expression = + FunctionExpression("array_get", notImplemented, array, offset) /** * Creates an expression that indexes into an array from the beginning or end and return the * element. If the offset exceeds the array length, an error is returned. A negative offset, * starts from the end. * - * @param array An [Expr] evaluating to an array. + * ```kotlin + * // Return the value in the 'tags' field array at index `1`. + * arrayGet(field("tags"), 1) + * ``` + * + * @param array An [Expression] evaluating to an array. * @param offset The index of the element to return. - * @return A new [Expr] representing the arrayOffset operation. + * @return A new [Expression] representing the arrayOffset operation. */ @JvmStatic - fun arrayGet(array: Expr, offset: Int): Expr = - FunctionExpr("array_get", notImplemented, array, constant(offset)) + fun arrayGet(array: Expression, offset: Int): Expression = + FunctionExpression("array_get", notImplemented, array, constant(offset)) /** * Creates an expression that indexes into an array from the beginning or end and return the * element. If the offset exceeds the array length, an error is returned. A negative offset, * starts from the end. * + * ```kotlin + * // Return the value in the tags field array at index specified by field 'favoriteTag'. + * arrayGet("tags", field("favoriteTag")) + * ``` + * * @param arrayFieldName The name of an array field. - * @param offset An Expr evaluating to the index of the element to return. - * @return A new [Expr] representing the arrayOffset operation. + * @param offset An Expression evaluating to the index of the element to return. + * @return A new [Expression] representing the arrayOffset operation. */ @JvmStatic - fun arrayGet(arrayFieldName: String, offset: Expr): Expr = - FunctionExpr("array_get", notImplemented, arrayFieldName, offset) + fun arrayGet(arrayFieldName: String, offset: Expression): Expression = + FunctionExpression("array_get", notImplemented, arrayFieldName, offset) /** * Creates an expression that indexes into an array from the beginning or end and return the * element. If the offset exceeds the array length, an error is returned. A negative offset, * starts from the end. * + * ```kotlin + * // Return the value in the 'tags' field array at index `1`. + * arrayGet("tags", 1) + * ``` + * * @param arrayFieldName The name of an array field. * @param offset The index of the element to return. - * @return A new [Expr] representing the arrayOffset operation. + * @return A new [Expression] representing the arrayOffset operation. */ @JvmStatic - fun arrayGet(arrayFieldName: String, offset: Int): Expr = - FunctionExpr("array_get", notImplemented, arrayFieldName, constant(offset)) + fun arrayGet(arrayFieldName: String, offset: Int): Expression = + FunctionExpression("array_get", notImplemented, arrayFieldName, constant(offset)) /** * Creates a conditional expression that evaluates to a [thenExpr] expression if a condition is @@ -3086,203 +4586,419 @@ abstract class Expr internal constructor() : Canonicalizable { * @param condition The condition to evaluate. * @param thenExpr The expression to evaluate if the condition is true. * @param elseExpr The expression to evaluate if the condition is false. - * @return A new [Expr] representing the conditional operation. + * @return A new [Expression] representing the conditional operation. */ @JvmStatic - fun cond(condition: BooleanExpr, thenExpr: Expr, elseExpr: Expr): Expr = - FunctionExpr("cond", evaluateCond, condition, thenExpr, elseExpr) + fun conditional( + condition: BooleanExpression, + thenExpr: Expression, + elseExpr: Expression + ): Expression = FunctionExpression("conditional", evaluateCond, condition, thenExpr, elseExpr) /** * Creates a conditional expression that evaluates to a [thenValue] if a condition is true or an * [elseValue] if the condition is false. * + * ```kotlin + * // If the 'quantity' field is greater than 10, return "High", otherwise return "Low" + * conditional(field("quantity").greaterThan(10), "High", "Low") + * ``` + * * @param condition The condition to evaluate. * @param thenValue Value if the condition is true. * @param elseValue Value if the condition is false. - * @return A new [Expr] representing the conditional operation. + * @return A new [Expression] representing the conditional operation. */ @JvmStatic - fun cond(condition: BooleanExpr, thenValue: Any, elseValue: Any): Expr = - FunctionExpr("cond", evaluateCond, condition, thenValue, elseValue) + fun conditional(condition: BooleanExpression, thenValue: Any, elseValue: Any): Expression = + FunctionExpression("conditional", evaluateCond, condition, thenValue, elseValue) /** * Creates an expression that checks if a field exists. * * @param value An expression evaluates to the name of the field to check. - * @return A new [Expr] representing the exists check. + * @return A new [Expression] representing the exists check. */ - @JvmStatic fun exists(value: Expr): BooleanExpr = BooleanExpr("exists", evaluateExists, value) + @JvmStatic + fun exists(value: Expression): BooleanExpression = + BooleanExpression("exists", evaluateExists, value) /** * Creates an expression that checks if a field exists. * * @param fieldName The field name to check. - * @return A new [Expr] representing the exists check. + * @return A new [Expression] representing the exists check. + */ + @JvmStatic + fun exists(fieldName: String): BooleanExpression = + BooleanExpression("exists", evaluateExists, fieldName) + + /** + * Creates an expression that raises an error with the given message. This could be useful for + * debugging purposes. + * + * ```kotlin + * // Raise an error with the message "simulating an evaluation error". + * error("simulating an evaluation error") + * ``` + * + * @return A new [Expression] representing the error() operation. */ @JvmStatic - fun exists(fieldName: String): BooleanExpr = BooleanExpr("exists", evaluateExists, fieldName) + fun error(message: String): Expression = + FunctionExpression("error", notImplemented, constant(message)) /** * Creates an expression that returns the [catchExpr] argument if there is an error, else return * the result of the [tryExpr] argument evaluation. * + * ```kotlin + * // Returns the first item in the title field arrays, or returns + * // the entire title field if the array is empty or the field is another type. + * ifError(arrayGet(field("title"), 0), field("title")) + * ``` + * * @param tryExpr The try expression. * @param catchExpr The catch expression that will be evaluated and returned if the [tryExpr] * produces an error. - * @return A new [Expr] representing the ifError operation. + * @return A new [Expression] representing the ifError operation. */ @JvmStatic - fun ifError(tryExpr: Expr, catchExpr: Expr): Expr = - FunctionExpr("if_error", notImplemented, tryExpr, catchExpr) + fun ifError(tryExpr: Expression, catchExpr: Expression): Expression = + FunctionExpression("if_error", notImplemented, tryExpr, catchExpr) /** * Creates an expression that returns the [catchExpr] argument if there is an error, else return * the result of the [tryExpr] argument evaluation. * - * This overload will return [BooleanExpr] when both parameters are also [BooleanExpr]. + * This overload will return [BooleanExpression] when both parameters are also + * [BooleanExpression]. + * + * ```kotlin + * // Returns the result of the boolean expression, or false if it errors. + * ifError(field("is_premium"), false) + * ``` * * @param tryExpr The try boolean expression. * @param catchExpr The catch boolean expression that will be evaluated and returned if the * [tryExpr] produces an error. - * @return A new [BooleanExpr] representing the ifError operation. + * @return A new [BooleanExpression] representing the ifError operation. */ @JvmStatic - fun ifError(tryExpr: BooleanExpr, catchExpr: BooleanExpr): BooleanExpr = - BooleanExpr("if_error", notImplemented, tryExpr, catchExpr) + fun ifError(tryExpr: BooleanExpression, catchExpr: BooleanExpression): BooleanExpression = + BooleanExpression("if_error", notImplemented, tryExpr, catchExpr) /** * Creates an expression that checks if a given expression produces an error. * + * ```kotlin + * // Check if the result of a calculation is an error + * isError(arrayContains(field("title"), 1)) + * ``` + * * @param expr The expression to check. - * @return A new [BooleanExpr] representing the `isError` check. + * @return A new [BooleanExpression] representing the `isError` check. */ - @JvmStatic fun isError(expr: Expr): BooleanExpr = BooleanExpr("is_error", evaluateIsError, expr) + @JvmStatic + fun isError(expr: Expression): BooleanExpression = + BooleanExpression("is_error", evaluateIsError, expr) /** * Creates an expression that returns the [catchValue] argument if there is an error, else * return the result of the [tryExpr] argument evaluation. * + * ```kotlin + * // Returns the first item in the title field arrays, or returns "Default Title" + * ifError(arrayGet(field("title"), 0), "Default Title") + * ``` + * * @param tryExpr The try expression. * @param catchValue The value that will be returned if the [tryExpr] produces an error. - * @return A new [Expr] representing the ifError operation. + * @return A new [Expression] representing the ifError operation. + */ + @JvmStatic + fun ifError(tryExpr: Expression, catchValue: Any): Expression = + FunctionExpression("if_error", notImplemented, tryExpr, catchValue) + + /** + * Creates an expression that returns the [elseExpr] argument if [ifExpr] is absent, else return + * the result of the [ifExpr] argument evaluation. + * + * ```kotlin + * // Returns the value of the optional field 'optional_field', or returns 'default_value' + * // if the field is absent. + * ifAbsent(field("optional_field"), "default_value") + * ``` + * + * @param ifExpr The expression to check for absence. + * @param elseExpr The expression that will be evaluated and returned if [ifExpr] is absent. + * @return A new [Expression] representing the ifAbsent operation. + */ + @JvmStatic + fun ifAbsent(ifExpr: Expression, elseExpr: Expression): Expression = + FunctionExpression("if_absent", notImplemented, ifExpr, elseExpr) + + /** + * Creates an expression that returns the [elseValue] argument if [ifExpr] is absent, else + * return the result of the [ifExpr] argument evaluation. + * + * ```kotlin + * // Returns the value of the optional field 'optional_field', or returns 'default_value' + * // if the field is absent. + * ifAbsent(field("optional_field"), "default_value") + * ``` + * + * @param ifExpr The expression to check for absence. + * @param elseValue The value that will be returned if [ifExpr] is absent. + * @return A new [Expression] representing the ifAbsent operation. + */ + @JvmStatic + fun ifAbsent(ifExpr: Expression, elseValue: Any): Expression = + FunctionExpression("if_absent", notImplemented, ifExpr, elseValue) + + /** + * Creates an expression that returns the [elseExpr] argument if [ifFieldName] is absent, else + * return the value of the field. + * + * ```kotlin + * // Returns the value of the optional field 'optional_field', or returns the value of + * // 'default_field' if 'optional_field' is absent. + * ifAbsent("optional_field", field("default_field")) + * ``` + * + * @param ifFieldName The field to check for absence. + * @param elseExpr The expression that will be evaluated and returned if [ifFieldName] is + * absent. + * @return A new [Expression] representing the ifAbsent operation. + */ + @JvmStatic + fun ifAbsent(ifFieldName: String, elseExpr: Expression): Expression = + FunctionExpression("if_absent", notImplemented, ifFieldName, elseExpr) + + /** + * Creates an expression that returns the [elseValue] argument if [ifFieldName] is absent, else + * return the value of the field. + * + * ```kotlin + * // Returns the value of the optional field 'optional_field', or returns 'default_value' + * // if the field is absent. + * ifAbsent("optional_field", "default_value") + * ``` + * + * @param ifFieldName The field to check for absence. + * @param elseValue The value that will be returned if [ifFieldName] is absent. + * @return A new [Expression] representing the ifAbsent operation. + */ + @JvmStatic + fun ifAbsent(ifFieldName: String, elseValue: Any): Expression = + FunctionExpression("if_absent", notImplemented, ifFieldName, elseValue) + + /** + * Creates an expression that returns the collection ID from a path. + * + * ```kotlin + * // Get the collection ID from the 'path' field + * collectionId(field("path")) + * ``` + * + * @param path An expression the evaluates to a path. + * @return A new [Expression] representing the collectionId operation. */ @JvmStatic - fun ifError(tryExpr: Expr, catchValue: Any): Expr = - FunctionExpr("if_error", notImplemented, tryExpr, catchValue) + fun collectionId(path: Expression): Expression = + FunctionExpression("collection_id", notImplemented, path) + + /** + * Creates an expression that returns the collection ID from a path. + * + * ```kotlin + * // Get the collection ID from a path field + * collectionId("pathField") + * ``` + * + * @param pathField The string representation of the path. + * @return A new [Expression] representing the collectionId operation. + */ + @JvmStatic fun collectionId(pathField: String): Expression = collectionId(field(pathField)) /** * Creates an expression that returns the document ID from a path. * + * ```kotlin + * // Get the document ID from the 'path' field + * documentId(field("path")) + * ``` + * * @param documentPath An expression the evaluates to document path. - * @return A new [Expr] representing the documentId operation. + * @return A new [Expression] representing the documentId operation. */ @JvmStatic - fun documentId(documentPath: Expr): Expr = - FunctionExpr("document_id", notImplemented, documentPath) + fun documentId(documentPath: Expression): Expression = + FunctionExpression("document_id", notImplemented, documentPath) /** * Creates an expression that returns the document ID from a path. * + * ```kotlin + * // Get the document ID from a path string + * documentId("projects/p/databases/d/documents/c/d") + * ``` + * * @param documentPath The string representation of the document path. - * @return A new [Expr] representing the documentId operation. + * @return A new [Expression] representing the documentId operation. */ - @JvmStatic fun documentId(documentPath: String): Expr = documentId(constant(documentPath)) + @JvmStatic fun documentId(documentPath: String): Expression = documentId(constant(documentPath)) /** * Creates an expression that returns the document ID from a [DocumentReference]. * * @param docRef The [DocumentReference]. - * @return A new [Expr] representing the documentId operation. + * @return A new [Expression] representing the documentId operation. */ - @JvmStatic fun documentId(docRef: DocumentReference): Expr = documentId(constant(docRef)) + @JvmStatic fun documentId(docRef: DocumentReference): Expression = documentId(constant(docRef)) } /** * Creates an expression that applies a bitwise AND operation with other expression. * + * ```kotlin + * // Bitwise AND the value of the 'flags' field with the value of the 'mask' field. + * field("flags").bitAnd(field("mask")) + * ``` + * * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise AND operation. + * @return A new [Expression] representing the bitwise AND operation. */ - fun bitAnd(bitsOther: Expr): Expr = Companion.bitAnd(this, bitsOther) + fun bitAnd(bitsOther: Expression): Expression = Companion.bitAnd(this, bitsOther) /** * Creates an expression that applies a bitwise AND operation with a constant. * + * ```kotlin + * // Bitwise AND the value of the 'flags' field with a constant mask. + * field("flags").bitAnd(byteArrayOf(0b00001111)) + * ``` + * * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise AND operation. + * @return A new [Expression] representing the bitwise AND operation. */ - fun bitAnd(bitsOther: ByteArray): Expr = Companion.bitAnd(this, bitsOther) + fun bitAnd(bitsOther: ByteArray): Expression = Companion.bitAnd(this, bitsOther) /** * Creates an expression that applies a bitwise OR operation with other expression. * + * ```kotlin + * // Bitwise OR the value of the 'flags' field with the value of the 'mask' field. + * field("flags").bitOr(field("mask")) + * ``` + * * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise OR operation. + * @return A new [Expression] representing the bitwise OR operation. */ - fun bitOr(bitsOther: Expr): Expr = Companion.bitOr(this, bitsOther) + fun bitOr(bitsOther: Expression): Expression = Companion.bitOr(this, bitsOther) /** * Creates an expression that applies a bitwise OR operation with a constant. * + * ```kotlin + * // Bitwise OR the value of the 'flags' field with a constant mask. + * field("flags").bitOr(byteArrayOf(0b00001111)) + * ``` + * * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise OR operation. + * @return A new [Expression] representing the bitwise OR operation. */ - fun bitOr(bitsOther: ByteArray): Expr = Companion.bitOr(this, bitsOther) + fun bitOr(bitsOther: ByteArray): Expression = Companion.bitOr(this, bitsOther) /** * Creates an expression that applies a bitwise XOR operation with an expression. * + * ```kotlin + * // Bitwise XOR the value of the 'flags' field with the value of the 'mask' field. + * field("flags").bitXor(field("mask")) + * ``` + * * @param bitsOther An expression that returns bits when evaluated. - * @return A new [Expr] representing the bitwise XOR operation. + * @return A new [Expression] representing the bitwise XOR operation. */ - fun bitXor(bitsOther: Expr): Expr = Companion.bitXor(this, bitsOther) + fun bitXor(bitsOther: Expression): Expression = Companion.bitXor(this, bitsOther) /** * Creates an expression that applies a bitwise XOR operation with a constant. * + * ```kotlin + * // Bitwise XOR the value of the 'flags' field with a constant mask. + * field("flags").bitXor(byteArrayOf(0b00001111)) + * ``` + * * @param bitsOther A constant byte array. - * @return A new [Expr] representing the bitwise XOR operation. + * @return A new [Expression] representing the bitwise XOR operation. */ - fun bitXor(bitsOther: ByteArray): Expr = Companion.bitXor(this, bitsOther) + fun bitXor(bitsOther: ByteArray): Expression = Companion.bitXor(this, bitsOther) /** * Creates an expression that applies a bitwise NOT operation to this expression. * - * @return A new [Expr] representing the bitwise NOT operation. + * ```kotlin + * // Bitwise NOT the value of the 'flags' field. + * field("flags").bitNot() + * ``` + * + * @return A new [Expression] representing the bitwise NOT operation. */ - fun bitNot(): Expr = Companion.bitNot(this) + fun bitNot(): Expression = Companion.bitNot(this) /** * Creates an expression that applies a bitwise left shift operation with an expression. * + * ```kotlin + * // Left shift the value of the 'bits' field by the value of the 'shift' field. + * field("bits").bitLeftShift(field("shift")) + * ``` + * * @param numberExpr The number of bits to shift. - * @return A new [Expr] representing the bitwise left shift operation. + * @return A new [Expression] representing the bitwise left shift operation. */ - fun bitLeftShift(numberExpr: Expr): Expr = Companion.bitLeftShift(this, numberExpr) + fun bitLeftShift(numberExpr: Expression): Expression = Companion.bitLeftShift(this, numberExpr) /** * Creates an expression that applies a bitwise left shift operation with a constant. * + * ```kotlin + * // Left shift the value of the 'bits' field by 2. + * field("bits").bitLeftShift(2) + * ``` + * * @param number The number of bits to shift. - * @return A new [Expr] representing the bitwise left shift operation. + * @return A new [Expression] representing the bitwise left shift operation. */ - fun bitLeftShift(number: Int): Expr = Companion.bitLeftShift(this, number) + fun bitLeftShift(number: Int): Expression = Companion.bitLeftShift(this, number) /** * Creates an expression that applies a bitwise right shift operation with an expression. * + * ```kotlin + * // Right shift the value of the 'bits' field by the value of the 'shift' field. + * field("bits").bitRightShift(field("shift")) + * ``` + * * @param numberExpr The number of bits to shift. - * @return A new [Expr] representing the bitwise right shift operation. + * @return A new [Expression] representing the bitwise right shift operation. */ - fun bitRightShift(numberExpr: Expr): Expr = Companion.bitRightShift(this, numberExpr) + fun bitRightShift(numberExpr: Expression): Expression = Companion.bitRightShift(this, numberExpr) /** * Creates an expression that applies a bitwise right shift operation with a constant. * + * ```kotlin + * // Right shift the value of the 'bits' field by 2. + * field("bits").bitRightShift(2) + * ``` + * * @param number The number of bits to shift. - * @return A new [Expr] representing the bitwise right shift operation. + * @return A new [Expression] representing the bitwise right shift operation. */ - fun bitRightShift(number: Int): Expr = Companion.bitRightShift(this, number) + fun bitRightShift(number: Int): Expression = Companion.bitRightShift(this, number) /** * Assigns an alias to this expression. @@ -3291,530 +5007,888 @@ abstract class Expr internal constructor() : Canonicalizable { * to calculated values. * * @param alias The alias to assign to this expression. - * @return A new [Selectable] (typically an [AliasedExpr]) that wraps this expression and + * @return A new [Selectable] (typically an [AliasedExpression]) that wraps this expression and * associates it with the provided alias. */ - open fun alias(alias: String): Selectable = AliasedExpr(alias, this) + open fun alias(alias: String): Selectable = AliasedExpression(alias, this) /** * Creates an expression that returns the document ID from this path expression. * - * @return A new [Expr] representing the documentId operation. + * ```kotlin + * // Get the document ID from the 'path' field + * field("path").documentId() + * ``` + * + * @return A new [Expression] representing the documentId operation. + */ + fun documentId(): Expression = Companion.documentId(this) + + /** + * Creates an expression that returns the collection ID from this path expression. + * + * ```kotlin + * // Get the collection ID from the 'path' field + * field("path").collectionId() + * ``` + * + * @return A new [Expression] representing the collectionId operation. */ - fun documentId(): Expr = Companion.documentId(this) + fun collectionId(): Expression = Companion.collectionId(this) + + /** + * Creates an expression that returns the absolute value of this expression. + * + * ```kotlin + * // Get the absolute value of the 'change' field. + * field("change").abs() + * ``` + * + * @return A new [Expression] representing the numeric result of the absolute value operation. + */ + fun abs(): Expression = Companion.abs(this) + + /** + * Creates an expression that returns Euler's number e raised to the power of this expression. + * + * ```kotlin + * // Compute e to the power of the 'value' field. + * field("value").exp() + * ``` + * + * @return A new [Expression] representing the numeric result of the exponentiation. + */ + fun exp(): Expression = Companion.exp(this) /** * Creates an expression that adds this numeric expression to another numeric expression. * + * ```kotlin + * // Add the value of the 'quantity' field and the 'reserve' field. + * field("quantity").add(field("reserve")) + * ``` + * * @param second Numeric expression to add. - * @return A new [Expr] representing the addition operation. + * @return A new [Expression] representing the addition operation. */ - fun add(second: Expr): Expr = Companion.add(this, second) + fun add(second: Expression): Expression = Companion.add(this, second) /** * Creates an expression that adds this numeric expression to a constants. * + * ```kotlin + * // Add 5 to the value of the 'quantity' field. + * field("quantity").add(5) + * ``` + * * @param second Constant to add. - * @return A new [Expr] representing the addition operation. + * @return A new [Expression] representing the addition operation. */ - fun add(second: Number): Expr = Companion.add(this, second) + fun add(second: Number): Expression = Companion.add(this, second) /** * Creates an expression that subtracts a constant from this numeric expression. * + * ```kotlin + * // Subtract the 'discount' field from the 'price' field + * field("price").subtract(field("discount")) + * ``` + * * @param subtrahend Numeric expression to subtract. - * @return A new [Expr] representing the subtract operation. + * @return A new [Expression] representing the subtract operation. */ - fun subtract(subtrahend: Expr): Expr = Companion.subtract(this, subtrahend) + fun subtract(subtrahend: Expression): Expression = Companion.subtract(this, subtrahend) /** * Creates an expression that subtracts a numeric expressions from this numeric expression. * + * ```kotlin + * // Subtract 10 from the 'price' field. + * field("price").subtract(10) + * ``` + * * @param subtrahend Constant to subtract. - * @return A new [Expr] representing the subtract operation. + * @return A new [Expression] representing the subtract operation. */ - fun subtract(subtrahend: Number): Expr = Companion.subtract(this, subtrahend) + fun subtract(subtrahend: Number): Expression = Companion.subtract(this, subtrahend) /** * Creates an expression that multiplies this numeric expression with another numeric expression. * + * ```kotlin + * // Multiply the 'quantity' field by the 'price' field + * field("quantity").multiply(field("price")) + * ``` + * * @param second Numeric expression to multiply. - * @return A new [Expr] representing the multiplication operation. + * @return A new [Expression] representing the multiplication operation. */ - fun multiply(second: Expr): Expr = Companion.multiply(this, second) + fun multiply(second: Expression): Expression = Companion.multiply(this, second) /** * Creates an expression that multiplies this numeric expression with a constant. * + * ```kotlin + * // Multiply the 'quantity' field by 1.1. + * field("quantity").multiply(1.1) + * ``` + * * @param second Constant to multiply. - * @return A new [Expr] representing the multiplication operation. + * @return A new [Expression] representing the multiplication operation. */ - fun multiply(second: Number): Expr = Companion.multiply(this, second) + fun multiply(second: Number): Expression = Companion.multiply(this, second) /** * Creates an expression that divides this numeric expression by another numeric expression. * + * ```kotlin + * // Divide the 'total' field by the 'count' field + * field("total").divide(field("count")) + * ``` + * * @param divisor Numeric expression to divide this numeric expression by. - * @return A new [Expr] representing the division operation. + * @return A new [Expression] representing the division operation. */ - fun divide(divisor: Expr): Expr = Companion.divide(this, divisor) + fun divide(divisor: Expression): Expression = Companion.divide(this, divisor) /** * Creates an expression that divides this numeric expression by a constant. * + * ```kotlin + * // Divide the 'value' field by 10 + * field("value").divide(10) + * ``` + * * @param divisor Constant to divide this expression by. - * @return A new [Expr] representing the division operation. + * @return A new [Expression] representing the division operation. */ - fun divide(divisor: Number): Expr = Companion.divide(this, divisor) + fun divide(divisor: Number): Expression = Companion.divide(this, divisor) /** * Creates an expression that calculates the modulo (remainder) of dividing this numeric * expressions by another numeric expression. * + * ```kotlin + * // Calculate the remainder of dividing the 'value' field by the 'divisor' field + * field("value").mod(field("divisor")) + * ``` + * * @param divisor The numeric expression to divide this expression by. - * @return A new [Expr] representing the modulo operation. + * @return A new [Expression] representing the modulo operation. */ - fun mod(divisor: Expr): Expr = Companion.mod(this, divisor) + fun mod(divisor: Expression): Expression = Companion.mod(this, divisor) /** * Creates an expression that calculates the modulo (remainder) of dividing this numeric * expressions by a constant. * + * ```kotlin + * // Calculate the remainder of dividing the 'value' field by 3. + * field("value").mod(3) + * ``` + * * @param divisor The constant to divide this expression by. - * @return A new [Expr] representing the modulo operation. + * @return A new [Expression] representing the modulo operation. */ - fun mod(divisor: Number): Expr = Companion.mod(this, divisor) + fun mod(divisor: Number): Expression = Companion.mod(this, divisor) /** * Creates an expression that rounds this numeric expression to nearest integer. * + * ```kotlin + * // Round the value of the 'price' field. + * field("price").round() + * ``` + * * Rounds away from zero in halfway cases. * - * @return A new [Expr] representing an integer result from the round operation. + * @return A new [Expression] representing an integer result from the round operation. */ - fun round(): Expr = Companion.round(this) + fun round(): Expression = Companion.round(this) /** * Creates an expression that rounds off this numeric expression to [decimalPlace] decimal places * if [decimalPlace] is positive, rounds off digits to the left of the decimal point if * [decimalPlace] is negative. Rounds away from zero in halfway cases. * + * ```kotlin + * // Round the value of the 'price' field to 2 decimal places. + * field("price").roundToPrecision(2) + * ``` + * * @param decimalPlace The number of decimal places to round. - * @return A new [Expr] representing the round operation. + * @return A new [Expression] representing the round operation. */ - fun roundToPrecision(decimalPlace: Int): Expr = Companion.roundToPrecision(this, decimalPlace) + fun roundToPrecision(decimalPlace: Int): Expression = + Companion.roundToPrecision(this, decimalPlace) /** * Creates an expression that rounds off this numeric expression to [decimalPlace] decimal places * if [decimalPlace] is positive, rounds off digits to the left of the decimal point if * [decimalPlace] is negative. Rounds away from zero in halfway cases. * + * ```kotlin + * // Round the value of the 'price' field to the number of decimal places specified in the + * // 'precision' field. + * field("price").roundToPrecision(field("precision")) + * ``` + * * @param decimalPlace The number of decimal places to round. - * @return A new [Expr] representing the round operation. + * @return A new [Expression] representing the round operation. */ - fun roundToPrecision(decimalPlace: Expr): Expr = Companion.roundToPrecision(this, decimalPlace) + fun roundToPrecision(decimalPlace: Expression): Expression = + Companion.roundToPrecision(this, decimalPlace) /** * Creates an expression that returns the smallest integer that isn't less than this numeric * expression. * - * @return A new [Expr] representing an integer result from the ceil operation. + * ```kotlin + * // Compute the ceiling of the 'price' field. + * field("price").ceil() + * ``` + * + * @return A new [Expression] representing an integer result from the ceil operation. */ - fun ceil(): Expr = Companion.ceil(this) + fun ceil(): Expression = Companion.ceil(this) /** * Creates an expression that returns the largest integer that is not greater than this numeric * expression. * - * @return A new [Expr] representing an integer result from the floor operation. + * ```kotlin + * // Compute the floor of the 'price' field. + * field("price").floor() + * ``` + * + * @return A new [Expression] representing an integer result from the floor operation. */ - fun floor(): Expr = Companion.floor(this) + fun floor(): Expression = Companion.floor(this) /** * Creates an expression that returns this numeric expression raised to the power of the * [exponent]. Returns infinity on overflow and zero on underflow. * + * ```kotlin + * // Raise the value of the 'base' field to the power of 2. + * field("base").pow(2) + * ``` + * * @param exponent The numeric power to raise this numeric expression. - * @return A new [Expr] representing a numeric result from raising this numeric expression to the - * power of [exponent]. + * @return A new [Expression] representing a numeric result from raising this numeric expression + * to the power of [exponent]. */ - fun pow(exponent: Number): Expr = Companion.pow(this, exponent) + fun pow(exponent: Number): Expression = Companion.pow(this, exponent) /** * Creates an expression that returns this numeric expression raised to the power of the * [exponent]. Returns infinity on overflow and zero on underflow. * + * ```kotlin + * // Raise the value of the 'base' field to the power of the 'exponent' field. + * field("base").pow(field("exponent")) + * ``` + * * @param exponent The numeric power to raise this numeric expression. - * @return A new [Expr] representing a numeric result from raising this numeric expression to the - * power of [exponent]. + * @return A new [Expression] representing a numeric result from raising this numeric expression + * to the power of [exponent]. */ - fun pow(exponent: Expr): Expr = Companion.pow(this, exponent) + fun pow(exponent: Expression): Expression = Companion.pow(this, exponent) /** * Creates an expression that returns the square root of this numeric expression. * - * @return A new [Expr] representing the numeric result of the square root operation. + * ```kotlin + * // Compute the square root of the 'value' field. + * field("value").sqrt() + * ``` + * + * @return A new [Expression] representing the numeric result of the square root operation. + */ + fun sqrt(): Expression = Companion.sqrt(this) + + /** + * Creates an expression that returns the natural logarithm of this numeric expression. + * + * ```kotlin + * // compute the natural logarithm of the 'value' field. + * field("value").ln() + * ``` + * + * @return A new [Expression] representing the numeric result of the natural logarithm operation. + */ + fun ln(): Expression = Companion.ln(this) + + /** + * Creates an expression that returns the base-10 logarithm of this numeric expression. + * + * ```kotlin + * // compute the base-10 logarithm of the 'value' field. + * field("value").log10() + * ``` + * + * @return A new [Expression] representing the numeric result of the base-10 logarithm operation. */ - fun sqrt(): Expr = Companion.sqrt(this) + fun log10(): Expression = Companion.log10(this) /** * Creates an expression that checks if this expression, when evaluated, is equal to any of the * provided [values]. * + * ```kotlin + * // Check if the 'category' field is either "Electronics" or the value of the 'primaryType' field. + * field("category").equalAny(listOf("Electronics", field("primaryType"))) + * ``` + * * @param values The values to check against. - * @return A new [BooleanExpr] representing the 'IN' comparison. + * @return A new [BooleanExpression] representing the 'IN' comparison. */ - fun eqAny(values: List): BooleanExpr = Companion.eqAny(this, values) + fun equalAny(values: List): BooleanExpression = Companion.equalAny(this, values) /** * Creates an expression that checks if this expression, when evaluated, is equal to any of the * elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'category' field is in the 'availableCategories' array field. + * field("category").equalAny(field("availableCategories")) + * ``` + * * @param arrayExpression An expression that evaluates to an array, whose elements to check for * equality to the input. - * @return A new [BooleanExpr] representing the 'IN' comparison. + * @return A new [BooleanExpression] representing the 'IN' comparison. */ - fun eqAny(arrayExpression: Expr): BooleanExpr = Companion.eqAny(this, arrayExpression) + fun equalAny(arrayExpression: Expression): BooleanExpression = + Companion.equalAny(this, arrayExpression) /** * Creates an expression that checks if this expression, when evaluated, is not equal to all the * provided [values]. * + * ```kotlin + * // Check if the 'status' field is neither "pending" nor the value of the 'rejectedStatus' field. + * field("status").notEqualAny(listOf("pending", field("rejectedStatus"))) + * ``` + * * @param values The values to check against. - * @return A new [BooleanExpr] representing the 'NOT IN' comparison. + * @return A new [BooleanExpression] representing the 'NOT IN' comparison. */ - fun notEqAny(values: List): BooleanExpr = Companion.notEqAny(this, values) + fun notEqualAny(values: List): BooleanExpression = Companion.notEqualAny(this, values) /** * Creates an expression that checks if this expression, when evaluated, is not equal to all the * elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'status' field is not in the 'inactiveStatuses' array field. + * field("status").notEqualAny(field("inactiveStatuses")) + * ``` + * * @param arrayExpression An expression that evaluates to an array, whose elements to check for * equality to the input. - * @return A new [BooleanExpr] representing the 'NOT IN' comparison. + * @return A new [BooleanExpression] representing the 'NOT IN' comparison. */ - fun notEqAny(arrayExpression: Expr): BooleanExpr = Companion.notEqAny(this, arrayExpression) + fun notEqualAny(arrayExpression: Expression): BooleanExpression = + Companion.notEqualAny(this, arrayExpression) /** * Creates an expression that returns true if the result of this expression is absent. Otherwise, * returns false even if the value is null. * - * @return A new [BooleanExpr] representing the isAbsent operation. + * ```kotlin + * // Check if the field `value` is absent. + * field("value").isAbsent() + * ``` + * + * @return A new [BooleanExpression] representing the isAbsent operation. */ - fun isAbsent(): BooleanExpr = Companion.isAbsent(this) + fun isAbsent(): BooleanExpression = Companion.isAbsent(this) /** * Creates an expression that checks if this expression evaluates to 'NaN' (Not a Number). * - * @return A new [BooleanExpr] representing the isNan operation. + * ```kotlin + * // Check if the result of a calculation is NaN + * divide("value", 0).isNan() + * ``` + * + * @return A new [BooleanExpression] representing the isNan operation. */ - fun isNan(): BooleanExpr = Companion.isNan(this) + fun isNan(): BooleanExpression = Companion.isNan(this) /** * Creates an expression that checks if the results of this expression is NOT 'NaN' (Not a * Number). * - * @return A new [BooleanExpr] representing the isNotNan operation. + * ```kotlin + * // Check if the result of a calculation is NOT NaN + * divide("value", 0).isNotNan() + * ``` + * + * @return A new [BooleanExpression] representing the isNotNan operation. */ - fun isNotNan(): BooleanExpr = Companion.isNotNan(this) + fun isNotNan(): BooleanExpression = Companion.isNotNan(this) /** * Creates an expression that checks if the result of this expression is null. * - * @return A new [BooleanExpr] representing the isNull operation. + * ```kotlin + * // Check if the value of the 'name' field is null + * field("name").isNull() + * ``` + * + * @return A new [BooleanExpression] representing the isNull operation. */ - fun isNull(): BooleanExpr = Companion.isNull(this) + fun isNull(): BooleanExpression = Companion.isNull(this) /** * Creates an expression that checks if the result of this expression is not null. * - * @return A new [BooleanExpr] representing the isNotNull operation. - */ - fun isNotNull(): BooleanExpr = Companion.isNotNull(this) - - /** - * Creates an expression that replaces the first occurrence of a substring within this string - * expression. + * ```kotlin + * // Check if the value of the 'name' field is not null + * field("name").isNotNull() + * ``` * - * @param find The expression representing the substring to search for in this expressions. - * @param replace The expression representing the replacement for the first occurrence of [find]. - * @return A new [Expr] representing the string with the first occurrence replaced. + * @return A new [BooleanExpression] representing the isNotNull operation. */ - fun replaceFirst(find: Expr, replace: Expr) = Companion.replaceFirst(this, find, replace) + fun isNotNull(): BooleanExpression = Companion.isNotNull(this) /** - * Creates an expression that replaces the first occurrence of a substring within this string + * Creates an expression that calculates the length of a string, array, map, vector, or blob * expression. * - * @param find The substring to search for in this string expression. - * @param replace The replacement for the first occurrence of [find] with. - * @return A new [Expr] representing the string with the first occurrence replaced. + * ```kotlin + * // Get the length of the 'value' field where the value type can be any of a string, array, map, vector or blob. + * field("value").length() + * ``` + * + * @return A new [Expression] representing the length operation. */ - fun replaceFirst(find: String, replace: String) = Companion.replaceFirst(this, find, replace) + fun length(): Expression = Companion.length(this) /** - * Creates an expression that replaces all occurrences of a substring within this string - * expression. + * Creates an expression that calculates the character length of this string expression in UTF8. + * + * ```kotlin + * // Get the character length of the 'name' field in UTF-8. + * field("name").charLength() + * ``` * - * @param find The expression representing the substring to search for in this string expression. - * @param replace The expression representing the replacement for all occurrences of [find]. - * @return A new [Expr] representing the string with all occurrences replaced. + * @return A new [Expression] representing the charLength operation. */ - fun replaceAll(find: Expr, replace: Expr) = Companion.replaceAll(this, find, replace) + fun charLength(): Expression = Companion.charLength(this) /** - * Creates an expression that replaces all occurrences of a substring within this string - * expression. + * Creates an expression that calculates the length of a string in UTF-8 bytes, or just the length + * of a Blob. + * + * ```kotlin + * // Calculate the length of the 'myString' field in bytes. + * field("myString").byteLength() + * ``` * - * @param find The substring to search for in this string expression. - * @param replace The replacement for all occurrences of [find] with. - * @return A new [Expr] representing the string with all occurrences replaced. + * @return A new [Expression] representing the length of the string in bytes. */ - fun replaceAll(find: String, replace: String) = Companion.replaceAll(this, find, replace) + fun byteLength(): Expression = Companion.byteLength(this) /** - * Creates an expression that calculates the character length of this string expression in UTF8. + * Creates an expression that performs a case-sensitive wildcard string comparison. + * + * ```kotlin + * // Check if the 'title' field contains the string "guide" + * field("title").like("%guide%") + * ``` * - * @return A new [Expr] representing the charLength operation. + * @param pattern The pattern to search for. You can use "%" as a wildcard character. + * @return A new [BooleanExpression] representing the like operation. */ - fun charLength(): Expr = Companion.charLength(this) + fun like(pattern: Expression): BooleanExpression = Companion.like(this, pattern) /** - * Creates an expression that calculates the length of a string in UTF-8 bytes, or just the length - * of a Blob. + * Creates an expression that joins the elements of an array into a string. * - * @return A new [Expr] representing the length of the string in bytes. + * ```kotlin + * // Join the elements of the 'tags' field with a comma and space. + * field("tags").join(", ") + * ``` + * + * @param delimiter The string to use as a delimiter. + * @return A new [Expression] representing the join operation. */ - fun byteLength(): Expr = Companion.byteLength(this) + fun join(delimiter: String): Expression = Companion.join(this, delimiter) /** - * Creates an expression that performs a case-sensitive wildcard string comparison. + * Creates an expression that joins the elements of an array into a string. * - * @param pattern The pattern to search for. You can use "%" as a wildcard character. - * @return A new [BooleanExpr] representing the like operation. + * ```kotlin + * // Join the elements of the 'tags' field with the delimiter from the 'separator' field. + * field("tags").join(field("separator")) + * ``` + * + * @param delimiterExpression The expression that evaluates to the delimiter string. + * @return A new [Expression] representing the join operation. */ - fun like(pattern: Expr): BooleanExpr = Companion.like(this, pattern) + fun join(delimiterExpression: Expression): Expression = Companion.join(this, delimiterExpression) /** * Creates an expression that performs a case-sensitive wildcard string comparison. * + * ```kotlin + * // Check if the 'title' field contains the string "guide" + * field("title").like("%guide%") + * ``` + * * @param pattern The pattern to search for. You can use "%" as a wildcard character. - * @return A new [BooleanExpr] representing the like operation. + * @return A new [BooleanExpression] representing the like operation. */ - fun like(pattern: String): BooleanExpr = Companion.like(this, pattern) + fun like(pattern: String): BooleanExpression = Companion.like(this, pattern) /** * Creates an expression that checks if this string expression contains a specified regular * expression as a substring. * + * ```kotlin + * // Check if the 'description' field contains "example" (case-insensitive) + * field("description").regexContains("(?i)example") + * ``` + * * @param pattern The regular expression to use for the search. - * @return A new [BooleanExpr] representing the contains regular expression comparison. + * @return A new [BooleanExpression] representing the contains regular expression comparison. */ - fun regexContains(pattern: Expr): BooleanExpr = Companion.regexContains(this, pattern) + fun regexContains(pattern: Expression): BooleanExpression = Companion.regexContains(this, pattern) /** * Creates an expression that checks if this string expression contains a specified regular * expression as a substring. * + * ```kotlin + * // Check if the 'description' field contains "example" (case-insensitive) + * field("description").regexContains("(?i)example") + * ``` + * * @param pattern The regular expression to use for the search. - * @return A new [BooleanExpr] representing the contains regular expression comparison. + * @return A new [BooleanExpression] representing the contains regular expression comparison. */ - fun regexContains(pattern: String): BooleanExpr = Companion.regexContains(this, pattern) + fun regexContains(pattern: String): BooleanExpression = Companion.regexContains(this, pattern) /** * Creates an expression that checks if this string expression matches a specified regular * expression. * + * ```kotlin + * // Check if the 'email' field matches a valid email pattern + * field("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}") + * ``` + * * @param pattern The regular expression to use for the match. - * @return A new [BooleanExpr] representing the regular expression match comparison. + * @return A new [BooleanExpression] representing the regular expression match comparison. */ - fun regexMatch(pattern: Expr): BooleanExpr = Companion.regexMatch(this, pattern) + fun regexMatch(pattern: Expression): BooleanExpression = Companion.regexMatch(this, pattern) /** * Creates an expression that checks if this string expression matches a specified regular * expression. * + * ```kotlin + * // Check if the 'email' field matches a valid email pattern + * field("email").regexMatch("[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}") + * ``` + * * @param pattern The regular expression to use for the match. - * @return A new [BooleanExpr] representing the regular expression match comparison. + * @return A new [BooleanExpression] representing the regular expression match comparison. */ - fun regexMatch(pattern: String): BooleanExpr = Companion.regexMatch(this, pattern) + fun regexMatch(pattern: String): BooleanExpression = Companion.regexMatch(this, pattern) /** * Creates an expression that returns the largest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the larger value between the 'timestamp' field and the current timestamp. + * field("timestamp").logicalMaximum(currentTimestamp()) + * ``` + * * @param others Expressions or literals. - * @return A new [Expr] representing the logical maximum operation. + * @return A new [Expression] representing the logical maximum operation. */ - fun logicalMaximum(vararg others: Expr): Expr = Companion.logicalMaximum(this, *others) + fun logicalMaximum(vararg others: Expression): Expression = + Companion.logicalMaximum(this, *others) /** * Creates an expression that returns the largest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the larger value between the 'timestamp' field and the current timestamp. + * field("timestamp").logicalMaximum(currentTimestamp()) + * ``` + * * @param others Expressions or literals. - * @return A new [Expr] representing the logical maximum operation. + * @return A new [Expression] representing the logical maximum operation. */ - fun logicalMaximum(vararg others: Any): Expr = Companion.logicalMaximum(this, *others) + fun logicalMaximum(vararg others: Any): Expression = Companion.logicalMaximum(this, *others) /** * Creates an expression that returns the smallest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the smaller value between the 'timestamp' field and the current timestamp. + * field("timestamp").logicalMinimum(currentTimestamp()) + * ``` + * * @param others Expressions or literals. - * @return A new [Expr] representing the logical minimum operation. + * @return A new [Expression] representing the logical minimum operation. */ - fun logicalMinimum(vararg others: Expr): Expr = Companion.logicalMinimum(this, *others) + fun logicalMinimum(vararg others: Expression): Expression = + Companion.logicalMinimum(this, *others) /** * Creates an expression that returns the smallest value between multiple input expressions or * literal values. Based on Firestore's value type ordering. * + * ```kotlin + * // Returns the smaller value between the 'timestamp' field and the current timestamp. + * field("timestamp").logicalMinimum(currentTimestamp()) + * ``` + * * @param others Expressions or literals. - * @return A new [Expr] representing the logical minimum operation. + * @return A new [Expression] representing the logical minimum operation. */ - fun logicalMinimum(vararg others: Any): Expr = Companion.logicalMinimum(this, *others) + fun logicalMinimum(vararg others: Any): Expression = Companion.logicalMinimum(this, *others) /** * Creates an expression that reverses this string expression. * - * @return A new [Expr] representing the reversed string. - */ - fun reverse(): Expr = Companion.reverse(this) - - /** - * Creates an expression that reverses this string expression. + * ```kotlin + * // Reverse the value of the 'myString' field. + * field("myString").reverse() + * ``` * - * @return A new [Expr] representing the reversed string. + * @return A new [Expression] representing the reversed string. */ - fun strReverse(): Expr = Companion.strReverse(this) + fun reverse(): Expression = Companion.reverse(this) /** * Creates an expression that checks if this string expression contains a specified substring. * + * ```kotlin + * // Check if the 'description' field contains the value of the 'keyword' field. + * field("description").stringContains(field("keyword")) + * ``` + * * @param substring The expression representing the substring to search for. - * @return A new [BooleanExpr] representing the contains comparison. + * @return A new [BooleanExpression] representing the contains comparison. */ - fun strContains(substring: Expr): BooleanExpr = Companion.strContains(this, substring) + fun stringContains(substring: Expression): BooleanExpression = + Companion.stringContains(this, substring) /** * Creates an expression that checks if this string expression contains a specified substring. * + * ```kotlin + * // Check if the 'description' field contains "example". + * field("description").stringContains("example") + * ``` + * * @param substring The substring to search for. - * @return A new [BooleanExpr] representing the contains comparison. + * @return A new [BooleanExpression] representing the contains comparison. */ - fun strContains(substring: String): BooleanExpr = Companion.strContains(this, substring) + fun stringContains(substring: String): BooleanExpression = + Companion.stringContains(this, substring) /** * Creates an expression that checks if this string expression starts with a given [prefix]. * + * ```kotlin + * // Check if the 'fullName' field starts with the value of the 'firstName' field + * field("fullName").startsWith(field("firstName")) + * ``` + * * @param prefix The prefix string expression to check for. - * @return A new [BooleanExpr] representing the 'starts with' comparison. + * @return A new [BooleanExpression] representing the 'starts with' comparison. */ - fun startsWith(prefix: Expr): BooleanExpr = Companion.startsWith(this, prefix) + fun startsWith(prefix: Expression): BooleanExpression = Companion.startsWith(this, prefix) /** * Creates an expression that checks if this string expression starts with a given [prefix]. * + * ```kotlin + * // Check if the 'name' field starts with "Mr." + * field("name").startsWith("Mr.") + * ``` + * * @param prefix The prefix string to check for. - * @return A new [BooleanExpr] representing the 'starts with' comparison. + * @return A new [BooleanExpression] representing the 'starts with' comparison. */ - fun startsWith(prefix: String): BooleanExpr = Companion.startsWith(this, prefix) + fun startsWith(prefix: String): BooleanExpression = Companion.startsWith(this, prefix) /** * Creates an expression that checks if this string expression ends with a given [suffix]. * + * ```kotlin + * // Check if the 'url' field ends with the value of the 'extension' field + * field("url").endsWith(field("extension")) + * ``` + * * @param suffix The suffix string expression to check for. - * @return A new [BooleanExpr] representing the 'ends with' comparison. + * @return A new [BooleanExpression] representing the 'ends with' comparison. */ - fun endsWith(suffix: Expr): BooleanExpr = Companion.endsWith(this, suffix) + fun endsWith(suffix: Expression): BooleanExpression = Companion.endsWith(this, suffix) /** * Creates an expression that checks if this string expression ends with a given [suffix]. * + * ```kotlin + * // Check if the 'filename' field ends with ".txt" + * field("filename").endsWith(".txt") + * ``` + * * @param suffix The suffix string to check for. - * @return A new [BooleanExpr] representing the 'ends with' comparison. + * @return A new [BooleanExpression] representing the 'ends with' comparison. */ fun endsWith(suffix: String) = Companion.endsWith(this, suffix) + /** + * Creates an expression that performs a reverse operation on this string expression. + * + * ```kotlin + * // reverse the field "filename": "abc.txt" => "txt.cba" + * field("filename").stringReverse() + * ``` + * @return A new [Expression] representing the 'stringReverse' operation. + */ + fun stringReverse() = Companion.stringReverse(this) + /** * Creates an expression that returns a substring of the given string. * + * ```kotlin + * // Get a substring of the 'message' field starting at index 5 with length 10. + * field("message").substring(constant(5), constant(10)) + * ``` + * * @param start The starting index of the substring. * @param length The length of the substring. - * @return A new [Expr] representing the substring. + * @return A new [Expression] representing the substring. */ - fun substr(start: Expr, length: Expr): Expr = Companion.substr(this, start, length) + fun substring(start: Expression, length: Expression): Expression = + Companion.substring(this, start, length) /** * Creates an expression that returns a substring of the given string. * + * ```kotlin + * // Get a substring of the 'message' field starting at index 5 with length 10. + * field("message").substring(5, 10) + * ``` + * * @param start The starting index of the substring. * @param length The length of the substring. - * @return A new [Expr] representing the substring. + * @return A new [Expression] representing the substring. */ - fun substr(start: Int, length: Int): Expr = - Companion.substr(this, constant(start), constant(length)) + fun substring(start: Int, length: Int): Expression = + Companion.substring(this, constant(start), constant(length)) /** * Creates an expression that converts this string expression to lowercase. * - * @return A new [Expr] representing the lowercase string. + * ```kotlin + * // Convert the 'name' field to lowercase + * field("name").toLower() + * ``` + * + * @return A new [Expression] representing the lowercase string. */ fun toLower() = Companion.toLower(this) /** * Creates an expression that converts this string expression to uppercase. * - * @return A new [Expr] representing the uppercase string. + * ```kotlin + * // Convert the 'title' field to uppercase + * field("title").toUpper() + * ``` + * + * @return A new [Expression] representing the uppercase string. */ fun toUpper() = Companion.toUpper(this) /** * Creates an expression that removes leading and trailing whitespace from this string expression. * - * @return A new [Expr] representing the trimmed string. + * ```kotlin + * // Trim whitespace from the 'userInput' field + * field("userInput").trim() + * ``` + * + * @return A new [Expression] representing the trimmed string. */ fun trim() = Companion.trim(this) /** * Creates an expression that concatenates string expressions together. * + * ```kotlin + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * field("firstName").stringConcat(constant(" "), field("lastName")) + * ``` + * * @param stringExpressions The string expressions to concatenate. - * @return A new [Expr] representing the concatenated string. + * @return A new [Expression] representing the concatenated string. */ - fun strConcat(vararg stringExpressions: Expr): Expr = - Companion.strConcat(this, *stringExpressions) + fun stringConcat(vararg stringExpressions: Expression): Expression = + Companion.stringConcat(this, *stringExpressions) /** * Creates an expression that concatenates this string expression with string constants. * + * ```kotlin + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * field("firstName").stringConcat(" ", "lastName") + * ``` + * * @param strings The string constants to concatenate. - * @return A new [Expr] representing the concatenated string. + * @return A new [Expression] representing the concatenated string. */ - fun strConcat(vararg strings: String): Expr = Companion.strConcat(this, *strings) + fun stringConcat(vararg strings: String): Expression = Companion.stringConcat(this, *strings) /** * Creates an expression that concatenates string expressions and string constants together. * + * ```kotlin + * // Combine the 'firstName', " ", and 'lastName' fields into a single string + * field("firstName").stringConcat(" ", field("lastName")) + * ``` + * * @param strings The string expressions or string constants to concatenate. - * @return A new [Expr] representing the concatenated string. + * @return A new [Expression] representing the concatenated string. */ - fun strConcat(vararg strings: Any): Expr = Companion.strConcat(this, *strings) + fun stringConcat(vararg strings: Any): Expression = Companion.stringConcat(this, *strings) /** * Accesses a map (object) value using the provided [keyExpression]. * + * ```kotlin + * // Get the value from the 'address' map field, using the key from the 'keyField' field + * field("address").mapGet(field("keyField")) + * ``` + * * @param keyExpression The name of the key to remove from this map expression. - * @return A new [Expr] representing the value associated with the given key in the map. + * @return A new [Expression] representing the value associated with the given key in the map. */ - fun mapGet(keyExpression: Expr) = Companion.mapGet(this, keyExpression) + fun mapGet(keyExpression: Expression) = Companion.mapGet(this, keyExpression) /** * Accesses a map (object) value using the provided [key]. * + * ```kotlin + * // Get the 'city' value from the 'address' map field + * field("address").mapGet("city") + * ``` + * * @param key The key to access in the map. - * @return A new [Expr] representing the value associated with the given key in the map. + * @return A new [Expression] representing the value associated with the given key in the map. */ fun mapGet(key: String) = Companion.mapGet(this, key) @@ -3822,105 +5896,178 @@ abstract class Expr internal constructor() : Canonicalizable { * Creates an expression that merges multiple maps into a single map. If multiple maps have the * same key, the later value is used. * + * ```kotlin + * // Merges the map in the settings field with, a map literal, and a map in + * // that is conditionally returned by another expression + * field("settings").mapMerge( + * map(mapOf("enabled" to true)), + * conditional( + * field("isAdmin").equal(true), + * map(mapOf("admin" to true)), + * map(emptyMap()) + * ) + * ) + * ``` + * * @param mapExpr Map expression that will be merged. * @param otherMaps Additional maps to merge. - * @return A new [Expr] representing the mapMerge operation. + * @return A new [Expression] representing the mapMerge operation. */ - fun mapMerge(mapExpr: Expr, vararg otherMaps: Expr) = + fun mapMerge(mapExpr: Expression, vararg otherMaps: Expression) = Companion.mapMerge(this, mapExpr, *otherMaps) /** * Creates an expression that removes a key from this map expression. * + * ```kotlin + * // Removes the key 'baz' from the input map. + * map(mapOf("foo" to "bar", "baz" to true)).mapRemove(constant("baz")) + * ``` + * * @param keyExpression The name of the key to remove from this map expression. - * @return A new [Expr] that evaluates to a modified map. + * @return A new [Expression] that evaluates to a modified map. */ - fun mapRemove(keyExpression: Expr) = Companion.mapRemove(this, keyExpression) + fun mapRemove(keyExpression: Expression) = Companion.mapRemove(this, keyExpression) /** * Creates an expression that removes a key from this map expression. * + * ```kotlin + * // Removes the key 'baz' from the input map. + * map(mapOf("foo" to "bar", "baz" to true)).mapRemove("baz") + * ``` + * * @param key The name of the key to remove from this map expression. - * @return A new [Expr] that evaluates to a modified map. + * @return A new [Expression] that evaluates to a modified map. */ fun mapRemove(key: String) = Companion.mapRemove(this, key) /** * Calculates the Cosine distance between this and another vector expressions. * - * @param vector The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * ```kotlin + * // Calculate the cosine distance between the 'userVector' field and the 'itemVector' field + * field("userVector").cosineDistance(field("itemVector")) + * ``` + * + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the cosine distance between the two vectors. */ - fun cosineDistance(vector: Expr): Expr = Companion.cosineDistance(this, vector) + fun cosineDistance(vector: Expression): Expression = Companion.cosineDistance(this, vector) /** * Calculates the Cosine distance between this vector expression and a vector literal. * + * ```kotlin + * // Calculate the Cosine distance between the 'location' field and a target location + * field("location").cosineDistance(doubleArrayOf(37.7749, -122.4194)) + * ``` + * * @param vector The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * @return A new [Expression] representing the cosine distance between the two vectors. */ - fun cosineDistance(vector: DoubleArray): Expr = Companion.cosineDistance(this, vector) + fun cosineDistance(vector: DoubleArray): Expression = Companion.cosineDistance(this, vector) /** * Calculates the Cosine distance between this vector expression and a vector literal. * + * ```kotlin + * // Calculate the Cosine distance between the 'location' field and a target location + * field("location").cosineDistance(VectorValue.from(listOf(37.7749, -122.4194))) + * ``` + * * @param vector The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the cosine distance between the two vectors. + * @return A new [Expression] representing the cosine distance between the two vectors. */ - fun cosineDistance(vector: VectorValue): Expr = Companion.cosineDistance(this, vector) + fun cosineDistance(vector: VectorValue): Expression = Companion.cosineDistance(this, vector) /** * Calculates the dot product distance between this and another vector expression. * - * @param vector The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * ```kotlin + * // Calculate the dot product between the 'userVector' field and the 'itemVector' field + * field("userVector").dotProduct(field("itemVector")) + * ``` + * + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the dot product distance between the two vectors. */ - fun dotProduct(vector: Expr): Expr = Companion.dotProduct(this, vector) + fun dotProduct(vector: Expression): Expression = Companion.dotProduct(this, vector) /** * Calculates the dot product distance between this vector expression and a vector literal. * + * ```kotlin + * // Calculate the dot product between the 'vector' field and a constant vector + * field("vector").dotProduct(doubleArrayOf(1.0, 2.0, 3.0)) + * ``` + * * @param vector The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * @return A new [Expression] representing the dot product distance between the two vectors. */ - fun dotProduct(vector: DoubleArray): Expr = Companion.dotProduct(this, vector) + fun dotProduct(vector: DoubleArray): Expression = Companion.dotProduct(this, vector) /** * Calculates the dot product distance between this vector expression and a vector literal. * + * ```kotlin + * // Calculate the dot product between the 'vector' field and a constant vector + * field("vector").dotProduct(VectorValue.from(listOf(1.0, 2.0, 3.0))) + * ``` + * * @param vector The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the dot product distance between the two vectors. + * @return A new [Expression] representing the dot product distance between the two vectors. */ - fun dotProduct(vector: VectorValue): Expr = Companion.dotProduct(this, vector) + fun dotProduct(vector: VectorValue): Expression = Companion.dotProduct(this, vector) /** * Calculates the Euclidean distance between this and another vector expression. * - * @param vector The other vector (represented as an Expr) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * ```kotlin + * // Calculate the Euclidean distance between the 'userVector' field and the 'itemVector' field + * field("userVector").euclideanDistance(field("itemVector")) + * ``` + * + * @param vector The other vector (represented as an Expression) to compare against. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ - fun euclideanDistance(vector: Expr): Expr = Companion.euclideanDistance(this, vector) + fun euclideanDistance(vector: Expression): Expression = Companion.euclideanDistance(this, vector) /** * Calculates the Euclidean distance between this vector expression and a vector literal. * + * ```kotlin + * // Calculate the Euclidean distance between the 'vector' field and a constant vector + * field("vector").euclideanDistance(doubleArrayOf(1.0, 2.0, 3.0)) + * ``` + * * @param vector The other vector (as an array of doubles) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ - fun euclideanDistance(vector: DoubleArray): Expr = Companion.euclideanDistance(this, vector) + fun euclideanDistance(vector: DoubleArray): Expression = Companion.euclideanDistance(this, vector) /** * Calculates the Euclidean distance between this vector expression and a vector literal. * + * ```kotlin + * // Calculate the Euclidean distance between the 'vector' field and a constant vector + * field("vector").euclideanDistance(VectorValue.from(listOf(1.0, 2.0, 3.0))) + * ``` + * * @param vector The other vector (represented as an [VectorValue]) to compare against. - * @return A new [Expr] representing the Euclidean distance between the two vectors. + * @return A new [Expression] representing the Euclidean distance between the two vectors. */ - fun euclideanDistance(vector: VectorValue): Expr = Companion.euclideanDistance(this, vector) + fun euclideanDistance(vector: VectorValue): Expression = Companion.euclideanDistance(this, vector) /** * Creates an expression that calculates the length (dimension) of a Firestore Vector. * - * @return A new [Expr] representing the length (dimension) of the vector. + * ```kotlin + * // Get the vector length (dimension) of the field 'embedding'. + * field("embedding").vectorLength() + * ``` + * + * @return A new [Expression] representing the length (dimension) of the vector. */ fun vectorLength() = Companion.vectorLength(this) @@ -3928,7 +6075,12 @@ abstract class Expr internal constructor() : Canonicalizable { * Creates an expression that interprets this expression as the number of microseconds since the * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * - * @return A new [Expr] representing the timestamp. + * ```kotlin + * // Interpret the 'microseconds' field as microseconds since epoch. + * field("microseconds").unixMicrosToTimestamp() + * ``` + * + * @return A new [Expression] representing the timestamp. */ fun unixMicrosToTimestamp() = Companion.unixMicrosToTimestamp(this) @@ -3936,7 +6088,12 @@ abstract class Expr internal constructor() : Canonicalizable { * Creates an expression that converts this timestamp expression to the number of microseconds * since the Unix epoch (1970-01-01 00:00:00 UTC). * - * @return A new [Expr] representing the number of microseconds since epoch. + * ```kotlin + * // Convert the 'timestamp' field to microseconds since epoch. + * field("timestamp").timestampToUnixMicros() + * ``` + * + * @return A new [Expression] representing the number of microseconds since epoch. */ fun timestampToUnixMicros() = Companion.timestampToUnixMicros(this) @@ -3944,7 +6101,12 @@ abstract class Expr internal constructor() : Canonicalizable { * Creates an expression that interprets this expression as the number of milliseconds since the * Unix epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * - * @return A new [Expr] representing the timestamp. + * ```kotlin + * // Interpret the 'milliseconds' field as milliseconds since epoch. + * field("milliseconds").unixMillisToTimestamp() + * ``` + * + * @return A new [Expression] representing the timestamp. */ fun unixMillisToTimestamp() = Companion.unixMillisToTimestamp(this) @@ -3952,7 +6114,12 @@ abstract class Expr internal constructor() : Canonicalizable { * Creates an expression that converts this timestamp expression to the number of milliseconds * since the Unix epoch (1970-01-01 00:00:00 UTC). * - * @return A new [Expr] representing the number of milliseconds since epoch. + * ```kotlin + * // Convert the 'timestamp' field to milliseconds since epoch. + * field("timestamp").timestampToUnixMillis() + * ``` + * + * @return A new [Expression] representing the number of milliseconds since epoch. */ fun timestampToUnixMillis() = Companion.timestampToUnixMillis(this) @@ -3960,7 +6127,12 @@ abstract class Expr internal constructor() : Canonicalizable { * Creates an expression that interprets this expression as the number of seconds since the Unix * epoch (1970-01-01 00:00:00 UTC) and returns a timestamp. * - * @return A new [Expr] representing the timestamp. + * ```kotlin + * // Interpret the 'seconds' field as seconds since epoch. + * field("seconds").unixSecondsToTimestamp() + * ``` + * + * @return A new [Expression] representing the timestamp. */ fun unixSecondsToTimestamp() = Companion.unixSecondsToTimestamp(this) @@ -3968,66 +6140,135 @@ abstract class Expr internal constructor() : Canonicalizable { * Creates an expression that converts this timestamp expression to the number of seconds since * the Unix epoch (1970-01-01 00:00:00 UTC). * - * @return A new [Expr] representing the number of seconds since epoch. + * ```kotlin + * // Convert the 'timestamp' field to seconds since epoch. + * field("timestamp").timestampToUnixSeconds() + * ``` + * + * @return A new [Expression] representing the number of seconds since epoch. */ fun timestampToUnixSeconds() = Companion.timestampToUnixSeconds(this) /** * Creates an expression that adds a specified amount of time to this timestamp expression. * + * ```kotlin + * // Add some duration determined by field 'unit' and 'amount' to the 'timestamp' field. + * field("timestamp").timestampAdd(field("unit"), field("amount")) + * ``` + * * @param unit The expression representing the unit of time to add. Valid units include * "microsecond", "millisecond", "second", "minute", "hour" and "day". * @param amount The expression representing the amount of time to add. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ - fun timestampAdd(unit: Expr, amount: Expr): Expr = Companion.timestampAdd(this, unit, amount) + fun timestampAdd(unit: Expression, amount: Expression): Expression = + Companion.timestampAdd(this, unit, amount) /** * Creates an expression that adds a specified amount of time to this timestamp expression. * + * ```kotlin + * // Add 1 day to the 'timestamp' field. + * field("timestamp").timestampAdd("day", 1) + * ``` + * * @param unit The unit of time to add. Valid units include "microsecond", "millisecond", * "second", "minute", "hour" and "day". * @param amount The amount of time to add. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ - fun timestampAdd(unit: String, amount: Long): Expr = Companion.timestampAdd(this, unit, amount) + fun timestampAdd(unit: String, amount: Long): Expression = + Companion.timestampAdd(this, unit, amount) /** * Creates an expression that subtracts a specified amount of time to this timestamp expression. * + * ```kotlin + * // Subtract some duration determined by field 'unit' and 'amount' from the 'timestamp' field. + * field("timestamp").timestampSubtract(field("unit"), field("amount")) + * ``` + * * @param unit The expression representing the unit of time to subtract. Valid units include * "microsecond", "millisecond", "second", "minute", "hour" and "day". * @param amount The expression representing the amount of time to subtract. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. */ - fun timestampSub(unit: Expr, amount: Expr): Expr = Companion.timestampSub(this, unit, amount) + fun timestampSubtract(unit: Expression, amount: Expression): Expression = + Companion.timestampSubtract(this, unit, amount) /** * Creates an expression that subtracts a specified amount of time to this timestamp expression. * + * ```kotlin + * // Subtract 1 day from the 'timestamp' field. + * field("timestamp").timestampSubtract("day", 1) + * ``` + * * @param unit The unit of time to subtract. Valid units include "microsecond", "millisecond", * "second", "minute", "hour" and "day". * @param amount The amount of time to subtract. - * @return A new [Expr] representing the resulting timestamp. + * @return A new [Expression] representing the resulting timestamp. + */ + fun timestampSubtract(unit: String, amount: Long): Expression = + Companion.timestampSubtract(this, unit, amount) + + /** + * Creates an expression that concatenates this expression's value with others. The values must be + * all strings, all arrays, or all blobs. Types cannot be mixed. + * + * ```kotlin + * // Concatenate a field with another field. + * field("firstName").concat(field("lastName")) + * ``` + * + * @param second The second expression to concatenate. + * @param others Additional expressions to concatenate. + * @return A new [Expression] representing the concatenation. + */ + fun concat(second: Expression, vararg others: Any) = Companion.concat(this, second, *others) + + /** + * Creates an expression that concatenates this expression's value with others. The values must be + * all strings, all arrays, or all blobs. Types cannot be mixed. + * + * ```kotlin + * // Concatenate a field with a literal string. + * field("firstName").concat("lastName") + * ``` + * + * @param second The second value to concatenate. + * @param others Additional values to concatenate. + * @return A new [Expression] representing the concatenation. */ - fun timestampSub(unit: String, amount: Long): Expr = Companion.timestampSub(this, unit, amount) + fun concat(second: Any, vararg others: Any) = Companion.concat(this, second, *others) /** * Creates an expression that concatenates a field's array value with other arrays. * + * ```kotlin + * // Combine the 'items' array with another array field. + * field("items").arrayConcat(field("otherItems")) + * ``` + * * @param secondArray An expression that evaluates to array to concatenate. * @param otherArrays Optional additional array expressions or array literals to concatenate. - * @return A new [Expr] representing the arrayConcat operation. + * @return A new [Expression] representing the arrayConcat operation. */ - fun arrayConcat(secondArray: Expr, vararg otherArrays: Any) = + fun arrayConcat(secondArray: Expression, vararg otherArrays: Any) = Companion.arrayConcat(this, secondArray, *otherArrays) /** * Creates an expression that concatenates a field's array value with other arrays. * + * ```kotlin + * // Combine the 'items' array with a literal array. + * field("items").arrayConcat(listOf("a", "b")) + * ``` + * * @param secondArray An array expression or array literal to concatenate. * @param otherArrays Optional additional array expressions or array literals to concatenate. - * @return A new [Expr] representing the arrayConcat operation. + * @return A new [Expression] representing the arrayConcat operation. */ fun arrayConcat(secondArray: Any, vararg otherArrays: Any) = Companion.arrayConcat(this, secondArray, *otherArrays) @@ -4035,64 +6276,119 @@ abstract class Expr internal constructor() : Canonicalizable { /** * Reverses the order of elements in the array. * - * @return A new [Expr] representing the arrayReverse operation. + * ```kotlin + * // Reverse the value of the 'myArray' field. + * field("myArray").arrayReverse() + * ``` + * + * @return A new [Expression] representing the arrayReverse operation. */ fun arrayReverse() = Companion.arrayReverse(this) + /** + * Creates an expression that returns the sum of the elements in this array expression. + * + * ```kotlin + * // Get the sum of elements in the 'scores' array. + * field("scores").arraySum() + * ``` + * + * @return A new [Expression] representing the sum of the array elements. + */ + fun arraySum(): Expression = Companion.arraySum(this) + /** * Creates an expression that checks if array contains a specific [element]. * + * ```kotlin + * // Check if the 'sizes' array contains the value from the 'selectedSize' field + * field("sizes").arrayContains(field("selectedSize")) + * ``` + * * @param element The element to search for in the array. - * @return A new [BooleanExpr] representing the arrayContains operation. + * @return A new [BooleanExpression] representing the arrayContains operation. */ - fun arrayContains(element: Expr): BooleanExpr = Companion.arrayContains(this, element) + fun arrayContains(element: Expression): BooleanExpression = Companion.arrayContains(this, element) /** * Creates an expression that checks if array contains a specific [element]. * + * ```kotlin + * // Check if the 'colors' array contains "red" + * field("colors").arrayContains("red") + * ``` + * * @param element The element to search for in the array. - * @return A new [BooleanExpr] representing the arrayContains operation. + * @return A new [BooleanExpression] representing the arrayContains operation. */ - fun arrayContains(element: Any): BooleanExpr = Companion.arrayContains(this, element) + fun arrayContains(element: Any): BooleanExpression = Companion.arrayContains(this, element) /** * Creates an expression that checks if array contains all the specified [values]. * + * ```kotlin + * // Check if the 'tags' array contains both the value in field "tag1" and the literal value "tag2" + * field("tags").arrayContainsAll(listOf(field("tag1"), "tag2")) + * ``` + * * @param values The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAll operation. + * @return A new [BooleanExpression] representing the arrayContainsAll operation. */ - fun arrayContainsAll(values: List): BooleanExpr = Companion.arrayContainsAll(this, values) + fun arrayContainsAll(values: List): BooleanExpression = + Companion.arrayContainsAll(this, values) /** * Creates an expression that checks if array contains all elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'tags' array contains both of the values from field "tag1" and the literal value "tag2" + * field("tags").arrayContainsAll(array(field("tag1"), "tag2")) + * ``` + * * @param arrayExpression The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAll operation. + * @return A new [BooleanExpression] representing the arrayContainsAll operation. */ - fun arrayContainsAll(arrayExpression: Expr): BooleanExpr = + fun arrayContainsAll(arrayExpression: Expression): BooleanExpression = Companion.arrayContainsAll(this, arrayExpression) /** * Creates an expression that checks if array contains any of the specified [values]. * + * ```kotlin + * // Check if the 'categories' array contains either values from field "cate1" or "cate2" + * field("categories").arrayContainsAny(listOf(field("cate1"), field("cate2"))) + * ``` + * * @param values The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAny operation. + * @return A new [BooleanExpression] representing the arrayContainsAny operation. */ - fun arrayContainsAny(values: List): BooleanExpr = Companion.arrayContainsAny(this, values) + fun arrayContainsAny(values: List): BooleanExpression = + Companion.arrayContainsAny(this, values) /** * Creates an expression that checks if array contains any elements of [arrayExpression]. * + * ```kotlin + * // Check if the 'groups' array contains either the value from the 'userGroup' field + * // or the value "guest" + * field("groups").arrayContainsAny(array(field("userGroup"), "guest")) + * ``` + * * @param arrayExpression The elements to check for in the array. - * @return A new [BooleanExpr] representing the arrayContainsAny operation. + * @return A new [BooleanExpression] representing the arrayContainsAny operation. */ - fun arrayContainsAny(arrayExpression: Expr): BooleanExpr = + fun arrayContainsAny(arrayExpression: Expression): BooleanExpression = Companion.arrayContainsAny(this, arrayExpression) /** * Creates an expression that calculates the length of an array expression. * - * @return A new [Expr] representing the length of the array. + * ```kotlin + * // Get the number of items in the 'cart' array + * field("cart").arrayLength() + * ``` + * + * @return A new [Expression] representing the length of the array. */ fun arrayLength() = Companion.arrayLength(this) @@ -4101,18 +6397,28 @@ abstract class Expr internal constructor() : Canonicalizable { * element. If the offset exceeds the array length, an error is returned. A negative offset, * starts from the end. * - * @param offset An Expr evaluating to the index of the element to return. - * @return A new [Expr] representing the arrayOffset operation. + * ```kotlin + * // Return the value in the tags field array at index specified by field 'favoriteTag'. + * field("tags").arrayGet(field("favoriteTag")) + * ``` + * + * @param offset An Expression evaluating to the index of the element to return. + * @return A new [Expression] representing the arrayOffset operation. */ - fun arrayGet(offset: Expr) = Companion.arrayGet(this, offset) + fun arrayGet(offset: Expression) = Companion.arrayGet(this, offset) /** * Creates an expression that indexes into an array from the beginning or end and return the * element. If the offset exceeds the array length, an error is returned. A negative offset, * starts from the end. * - * @param offset An Expr evaluating to the index of the element to return. - * @return A new [Expr] representing the arrayOffset operation. + * ```kotlin + * // Return the value in the 'tags' field array at index `1`. + * field("tags").arrayGet(1) + * ``` + * + * @param offset An Expression evaluating to the index of the element to return. + * @return A new [Expression] representing the arrayOffset operation. */ fun arrayGet(offset: Int) = Companion.arrayGet(this, offset) @@ -4124,6 +6430,14 @@ abstract class Expr internal constructor() : Canonicalizable { */ fun count(): AggregateFunction = AggregateFunction.count(this) + /** + * Creates an aggregation that counts the number of distinct values of an expression across + * multiple stage inputs. + * + * @return A new [AggregateFunction] representing the count distinct aggregation. + */ + fun countDistinct(): AggregateFunction = AggregateFunction.countDistinct(this) + /** * Creates an aggregation that calculates the sum of this numeric expression across multiple stage * inputs. @@ -4138,7 +6452,7 @@ abstract class Expr internal constructor() : Canonicalizable { * * @return A new [AggregateFunction] representing the average aggregation. */ - fun avg(): AggregateFunction = AggregateFunction.avg(this) + fun average(): AggregateFunction = AggregateFunction.average(this) /** * Creates an aggregation that finds the minimum value of this expression across multiple stage @@ -4173,134 +6487,242 @@ abstract class Expr internal constructor() : Canonicalizable { /** * Creates an expression that checks if this and [other] expression are equal. * + * ```kotlin + * // Check if the 'age' field is equal to an expression + * field("age").equal(field("minAge").add(10)) + * ``` + * * @param other The expression to compare to. - * @return A new [BooleanExpr] representing the equality comparison. + * @return A new [BooleanExpression] representing the equality comparison. */ - fun eq(other: Expr): BooleanExpr = Companion.eq(this, other) + fun equal(other: Expression): BooleanExpression = Companion.equal(this, other) /** * Creates an expression that checks if this expression is equal to a [value]. * + * ```kotlin + * // Check if the 'age' field is equal to 21 + * field("age").equal(21) + * ``` + * * @param value The value to compare to. - * @return A new [BooleanExpr] representing the equality comparison. + * @return A new [BooleanExpression] representing the equality comparison. */ - fun eq(value: Any): BooleanExpr = Companion.eq(this, value) + fun equal(value: Any): BooleanExpression = Companion.equal(this, value) /** * Creates an expression that checks if this expressions is not equal to the [other] expression. * + * ```kotlin + * // Check if the 'status' field is not equal to the value of the 'otherStatus' field + * field("status").notEqual(field("otherStatus")) + * ``` + * * @param other The expression to compare to. - * @return A new [BooleanExpr] representing the inequality comparison. + * @return A new [BooleanExpression] representing the inequality comparison. */ - fun neq(other: Expr): BooleanExpr = Companion.neq(this, other) + fun notEqual(other: Expression): BooleanExpression = Companion.notEqual(this, other) /** * Creates an expression that checks if this expression is not equal to a [value]. * + * ```kotlin + * // Check if the 'status' field is not equal to "completed" + * field("status").notEqual("completed") + * ``` + * * @param value The value to compare to. - * @return A new [BooleanExpr] representing the inequality comparison. + * @return A new [BooleanExpression] representing the inequality comparison. */ - fun neq(value: Any): BooleanExpr = Companion.neq(this, value) + fun notEqual(value: Any): BooleanExpression = Companion.notEqual(this, value) /** * Creates an expression that checks if this expression is greater than the [other] expression. * + * ```kotlin + * // Check if the 'age' field is greater than the 'limit' field + * field("age").greaterThan(field("limit")) + * ``` + * * @param other The expression to compare to. - * @return A new [BooleanExpr] representing the greater than comparison. + * @return A new [BooleanExpression] representing the greater than comparison. */ - fun gt(other: Expr): BooleanExpr = Companion.gt(this, other) + fun greaterThan(other: Expression): BooleanExpression = Companion.greaterThan(this, other) /** * Creates an expression that checks if this expression is greater than a [value]. * + * ```kotlin + * // Check if the 'price' field is greater than 100 + * field("price").greaterThan(100) + * ``` + * * @param value The value to compare to. - * @return A new [BooleanExpr] representing the greater than comparison. + * @return A new [BooleanExpression] representing the greater than comparison. */ - fun gt(value: Any): BooleanExpr = Companion.gt(this, value) + fun greaterThan(value: Any): BooleanExpression = Companion.greaterThan(this, value) /** * Creates an expression that checks if this expression is greater than or equal to the [other] * expression. * + * ```kotlin + * // Check if the 'quantity' field is greater than or equal to field 'requirement' plus 1 + * field("quantity").greaterThanOrEqual(field("requirement").add(1)) + * ``` + * * @param other The expression to compare to. - * @return A new [BooleanExpr] representing the greater than or equal to comparison. + * @return A new [BooleanExpression] representing the greater than or equal to comparison. */ - fun gte(other: Expr): BooleanExpr = Companion.gte(this, other) + fun greaterThanOrEqual(other: Expression): BooleanExpression = + Companion.greaterThanOrEqual(this, other) /** * Creates an expression that checks if this expression is greater than or equal to a [value]. * + * ```kotlin + * // Check if the 'score' field is greater than or equal to 80 + * field("score").greaterThanOrEqual(80) + * ``` + * * @param value The value to compare to. - * @return A new [BooleanExpr] representing the greater than or equal to comparison. + * @return A new [BooleanExpression] representing the greater than or equal to comparison. */ - fun gte(value: Any): BooleanExpr = Companion.gte(this, value) + fun greaterThanOrEqual(value: Any): BooleanExpression = Companion.greaterThanOrEqual(this, value) /** * Creates an expression that checks if this expression is less than the [other] expression. * + * ```kotlin + * // Check if the 'age' field is less than 'limit' + * field("age").lessThan(field("limit")) + * ``` + * * @param other The expression to compare to. - * @return A new [BooleanExpr] representing the less than comparison. + * @return A new [BooleanExpression] representing the less than comparison. */ - fun lt(other: Expr): BooleanExpr = Companion.lt(this, other) + fun lessThan(other: Expression): BooleanExpression = Companion.lessThan(this, other) /** * Creates an expression that checks if this expression is less than a value. * + * ```kotlin + * // Check if the 'price' field is less than 50 + * field("price").lessThan(50) + * ``` + * * @param value The value to compare to. - * @return A new [BooleanExpr] representing the less than comparison. + * @return A new [BooleanExpression] representing the less than comparison. */ - fun lt(value: Any): BooleanExpr = Companion.lt(this, value) + fun lessThan(value: Any): BooleanExpression = Companion.lessThan(this, value) /** * Creates an expression that checks if this expression is less than or equal to the [other] * expression. * + * ```kotlin + * // Check if the 'quantity' field is less than or equal to 20 + * field("quantity").lessThanOrEqual(constant(20)) + * ``` + * * @param other The expression to compare to. - * @return A new [BooleanExpr] representing the less than or equal to comparison. + * @return A new [BooleanExpression] representing the less than or equal to comparison. */ - fun lte(other: Expr): BooleanExpr = Companion.lte(this, other) + fun lessThanOrEqual(other: Expression): BooleanExpression = Companion.lessThanOrEqual(this, other) /** * Creates an expression that checks if this expression is less than or equal to a [value]. * + * ```kotlin + * // Check if the 'score' field is less than or equal to 70 + * field("score").lessThanOrEqual(70) + * ``` + * * @param value The value to compare to. - * @return A new [BooleanExpr] representing the less than or equal to comparison. + * @return A new [BooleanExpression] representing the less than or equal to comparison. */ - fun lte(value: Any): BooleanExpr = Companion.lte(this, value) + fun lessThanOrEqual(value: Any): BooleanExpression = Companion.lessThanOrEqual(this, value) /** * Creates an expression that checks if this expression evaluates to a name of the field that * exists. * - * @return A new [Expr] representing the exists check. + * @return A new [Expression] representing the exists check. */ - fun exists(): BooleanExpr = Companion.exists(this) + fun exists(): BooleanExpression = Companion.exists(this) /** * Creates an expression that returns the [catchExpr] argument if there is an error, else return * the result of this expression. * + * ```kotlin + * // Returns the first item in the title field arrays, or returns + * // the entire title field if the array is empty or the field is another type. + * arrayGet(field("title"), 0).ifError(field("title")) + * ``` + * * @param catchExpr The catch expression that will be evaluated and returned if the this * expression produces an error. - * @return A new [Expr] representing the ifError operation. + * @return A new [Expression] representing the ifError operation. */ - fun ifError(catchExpr: Expr): Expr = Companion.ifError(this, catchExpr) + fun ifError(catchExpr: Expression): Expression = Companion.ifError(this, catchExpr) /** * Creates an expression that returns the [catchValue] argument if there is an error, else return * the result of this expression. * + * ```kotlin + * // Returns the first item in the title field arrays, or returns "Default Title" + * arrayGet(field("title"), 0).ifError("Default Title") + * ``` + * * @param catchValue The value that will be returned if this expression produces an error. - * @return A new [Expr] representing the ifError operation. + * @return A new [Expression] representing the ifError operation. + */ + fun ifError(catchValue: Any): Expression = Companion.ifError(this, catchValue) + + /** + * Creates an expression that returns the [elseExpr] argument if this expression is absent, else + * return the result of this expression. + * + * ```kotlin + * // Returns the value of the optional field 'optional_field', or returns 'default_value' + * // if the field is absent. + * field("optional_field").ifAbsent("default_value") + * ``` + * + * @param elseExpr The expression that will be evaluated and returned if this expression is + * absent. + * @return A new [Expression] representing the ifAbsent operation. + */ + fun ifAbsent(elseExpr: Expression): Expression = Companion.ifAbsent(this, elseExpr) + + /** + * Creates an expression that returns the [elseValue] argument if this expression is absent, else + * return the result of this expression. + * + * ```kotlin + * // Returns the value of the optional field 'optional_field', or returns 'default_value' + * // if the field is absent. + * field("optional_field").ifAbsent("default_value") + * ``` + * + * @param elseValue The value that will be returned if this expression is absent. + * @return A new [Expression] representing the ifAbsent operation. */ - fun ifError(catchValue: Any): Expr = Companion.ifError(this, catchValue) + fun ifAbsent(elseValue: Any): Expression = Companion.ifAbsent(this, elseValue) /** * Creates an expression that checks if this expression produces an error. * - * @return A new [BooleanExpr] representing the `isError` check. + * ```kotlin + * // Check if the result of a calculation is an error + * arrayContains(field("title"), 1).isError() + * ``` + * + * @return A new [BooleanExpression] representing the `isError` check. */ - fun isError(): BooleanExpr = Companion.isError(this) + fun isError(): BooleanExpression = Companion.isError(this) internal abstract fun toProto(userDataReader: UserDataReader): Value @@ -4308,9 +6730,9 @@ abstract class Expr internal constructor() : Canonicalizable { } /** Expressions that have an alias are [Selectable] */ -abstract class Selectable : Expr() { +abstract class Selectable : Expression() { internal abstract val alias: String - internal abstract val expr: Expr + internal abstract val expr: Expression internal companion object { fun toSelectable(o: Any): Selectable { @@ -4325,15 +6747,15 @@ abstract class Selectable : Expr() { } /** Represents an expression that will be given the alias in the output document. */ -class AliasedExpr internal constructor(override val alias: String, override val expr: Expr) : - Selectable() { +class AliasedExpression +internal constructor(override val alias: String, override val expr: Expression) : Selectable() { override fun toProto(userDataReader: UserDataReader): Value = expr.toProto(userDataReader) override fun evaluateFunction(context: EvaluationContext) = expr.evaluateFunction(context) override fun canonicalId() = expr.canonicalId() override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is AliasedExpr) return false + if (other !is AliasedExpression) return false if (alias != other.alias) return false if (expr != other.expr) return false return true @@ -4352,7 +6774,7 @@ class AliasedExpr internal constructor(override val alias: String, override val * [Field] references are used to access document field values in expressions and to specify fields * for sorting, filtering, and projecting data in Firestore pipelines. * - * You can create a [Field] instance using the static [Expr.field] method: + * You can create a [Field] instance using the static [Expression.field] method: */ class Field internal constructor(internal val fieldPath: ModelFieldPath) : Selectable() { companion object { @@ -4362,7 +6784,7 @@ class Field internal constructor(internal val fieldPath: ModelFieldPath) : Selec * * @return An [Field] representing the document ID. */ - @JvmField val DOCUMENT_ID: Field = Field(KEY_PATH) + @JvmField internal val DOCUMENT_ID: Field = Field(KEY_PATH) @JvmField internal val UPDATE_TIME: Field = Field(UPDATE_TIME_PATH) @@ -4371,7 +6793,7 @@ class Field internal constructor(internal val fieldPath: ModelFieldPath) : Selec override val alias: String = fieldPath.canonicalString() - override val expr: Expr = this + override val expr: Expression = this override fun toProto(userDataReader: UserDataReader) = toProto() @@ -4431,19 +6853,19 @@ class Field internal constructor(internal val fieldPath: ModelFieldPath) : Selec * within pipeline execution. * * Typically, you would not use this class or its children directly. Use either the functions like - * [and], [eq], or the methods on [Expr] ([Expr.eq]), [Expr.lt], etc) to construct new - * [FunctionExpr] instances. + * [and], [equal], or the methods on [Expression] ([Expression.equal]), [Expression.lessThan], etc) + * to construct new [FunctionExpression] instances. */ -open class FunctionExpr +open class FunctionExpression internal constructor( internal val name: String, private val function: EvaluateFunction, - internal val params: Array, + internal val params: Array, private val options: InternalOptions = InternalOptions.EMPTY -) : Expr() { +) : Expression() { internal constructor( name: String, - params: List, + params: List, options: InternalOptions = InternalOptions.EMPTY ) : this(name, FunctionRegistry.functions[name] ?: notImplemented, params.toTypedArray(), options) internal constructor( @@ -4453,25 +6875,25 @@ internal constructor( internal constructor( name: String, function: EvaluateFunction, - param: Expr + param: Expression ) : this(name, function, arrayOf(param)) internal constructor( name: String, function: EvaluateFunction, - param: Expr, + param: Expression, vararg params: Any ) : this(name, function, arrayOf(param, *toArrayOfExprOrConstant(params))) internal constructor( name: String, function: EvaluateFunction, - param1: Expr, - param2: Expr + param1: Expression, + param2: Expression ) : this(name, function, arrayOf(param1, param2)) internal constructor( name: String, function: EvaluateFunction, - param1: Expr, - param2: Expr, + param1: Expression, + param2: Expression, vararg params: Any ) : this(name, function, arrayOf(param1, param2, *toArrayOfExprOrConstant(params))) internal constructor( @@ -4506,7 +6928,7 @@ internal constructor( override fun equals(other: Any?): Boolean { if (this === other) return true - if (other !is FunctionExpr) return false + if (other !is FunctionExpression) return false if (name != other.name) return false if (!params.contentEquals(other.params)) return false if (options != other.options) return false @@ -4522,31 +6944,31 @@ internal constructor( } /** A class that represents a filter condition. */ -open class BooleanExpr -internal constructor(name: String, function: EvaluateFunction, params: Array) : - FunctionExpr(name, function, params, InternalOptions.EMPTY) { +open class BooleanExpression +internal constructor(name: String, function: EvaluateFunction, params: Array) : + FunctionExpression(name, function, params, InternalOptions.EMPTY) { internal constructor( name: String, function: EvaluateFunction, - param: Expr + param: Expression ) : this(name, function, arrayOf(param)) internal constructor( name: String, function: EvaluateFunction, - param1: Expr, + param1: Expression, param2: Any ) : this(name, function, arrayOf(param1, toExprOrConstant(param2))) internal constructor( name: String, function: EvaluateFunction, - param: Expr, + param: Expression, vararg params: Any ) : this(name, function, arrayOf(param, *toArrayOfExprOrConstant(params))) internal constructor( name: String, function: EvaluateFunction, - param1: Expr, - param2: Expr + param1: Expression, + param2: Expression ) : this(name, function, arrayOf(param1, param2)) internal constructor( name: String, @@ -4563,15 +6985,21 @@ internal constructor(name: String, function: EvaluateFunction, params: Array>(internal val name: String, internal val options options.forEach(builder::putOptions) return builder.build() } + + internal abstract fun canonicalId(): String + internal abstract fun args(userDataReader: UserDataReader): Sequence internal abstract fun self(options: InternalOptions): T @@ -132,6 +134,10 @@ private constructor( fun withArguments(vararg arguments: Any): RawStage = RawStage(name, arguments.map(GenericArg::from), options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = arguments.asSequence().map { it.toProto(userDataReader) } } @@ -145,7 +151,7 @@ internal sealed class GenericArg { is Map<*, *> -> MapArg(arg.asIterable().associate { (key, value) -> key as String to from(value) }) is List<*> -> ListArg(arg.map(::from)) - else -> ExprArg(Expr.toExprOrConstant(arg)) + else -> ExprArg(Expression.toExprOrConstant(arg)) } } abstract fun toProto(userDataReader: UserDataReader): Value @@ -154,7 +160,7 @@ internal sealed class GenericArg { override fun toProto(userDataReader: UserDataReader) = aggregate.toProto(userDataReader) } - data class ExprArg(val expr: Expr) : GenericArg() { + data class ExprArg(val expr: Expression) : GenericArg() { override fun toProto(userDataReader: UserDataReader) = expr.toProto(userDataReader) } @@ -178,6 +184,10 @@ internal class DatabaseSource internal constructor(options: InternalOptions = InternalOptions.EMPTY) : Stage("database", options) { override fun self(options: InternalOptions) = DatabaseSource(options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = emptySequence() override fun equals(other: Any?): Boolean { @@ -197,7 +207,7 @@ internal constructor( // We validate [firestore.databaseId] when adding to pipeline. internal val serializer: RemoteSerializer, options: InternalOptions -) : Stage("collection", options), Canonicalizable { +) : Stage("collection", options) { internal constructor( path: ResourcePath, @@ -287,7 +297,7 @@ class CollectionHints internal constructor(options: InternalOptions) : } class CollectionGroupSource(val collectionId: String, options: InternalOptions) : - Stage("collection_group", options), Canonicalizable { + Stage("collection_group", options) { internal constructor( collectionId: String, @@ -348,7 +358,7 @@ internal class DocumentsSource internal constructor( val documents: Array, options: InternalOptions = InternalOptions.EMPTY -) : Stage("documents", options), Canonicalizable { +) : Stage("documents", options) { private val docKeySet: HashSet by lazy { documents.map { it.canonicalString() }.toHashSet() } @@ -401,6 +411,10 @@ internal constructor( } } override fun self(options: InternalOptions) = AddFieldsStage(fields, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf(encodeValue(fields.associate { it.alias to it.toProto(userDataReader) })) @@ -438,7 +452,7 @@ internal constructor( class AggregateStage private constructor( private val accumulators: Map, - private val groups: Map, + private val groups: Map, options: InternalOptions = InternalOptions.EMPTY ) : Stage("aggregate", options) { private constructor(accumulators: Map) : this(accumulators, emptyMap()) @@ -476,7 +490,7 @@ private constructor( * @return [AggregateStage] with specified groups. */ fun withGroups(groupField: String, vararg additionalGroups: Any) = - withGroups(Expr.field(groupField), *additionalGroups) + withGroups(Expression.field(groupField), *additionalGroups) /** * Add one or more groups to [AggregateStage] @@ -497,6 +511,10 @@ private constructor( internal fun withOptions(options: AggregateOptions) = AggregateStage(accumulators, groups, options.options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf( encodeValue(accumulators.mapValues { entry -> entry.value.toProto(userDataReader) }), @@ -554,9 +572,9 @@ class AggregateOptions internal constructor(options: InternalOptions) : internal class WhereStage internal constructor( - internal val condition: Expr, + internal val condition: Expression, options: InternalOptions = InternalOptions.EMPTY -) : Stage("where", options), Canonicalizable { +) : Stage("where", options) { override fun canonicalId(): String { return "${name}(${condition.canonicalId()})" } @@ -594,15 +612,15 @@ internal constructor( */ class FindNearestStage internal constructor( - private val property: Expr, - private val vector: Expr, + private val property: Expression, + private val vector: Expression, private val distanceMeasure: DistanceMeasure, options: InternalOptions = InternalOptions.EMPTY ) : Stage("find_nearest", options) { private constructor( - property: Expr, - vector: Expr, + property: Expression, + vector: Expression, distanceMeasure: DistanceMeasure, options: FindNearestOptions ) : this(property, vector, distanceMeasure, options.options) @@ -643,7 +661,7 @@ internal constructor( vectorValue: DoubleArray, distanceMeasure: DistanceMeasure, options: FindNearestOptions = FindNearestOptions() - ) = FindNearestStage(vectorField, Expr.vector(vectorValue), distanceMeasure, options) + ) = FindNearestStage(vectorField, Expression.vector(vectorValue), distanceMeasure, options) /** * Create [FindNearestStage]. @@ -679,11 +697,12 @@ internal constructor( vectorValue: DoubleArray, distanceMeasure: DistanceMeasure, options: FindNearestOptions = FindNearestOptions() - ) = FindNearestStage(field(vectorField), Expr.vector(vectorValue), distanceMeasure, options) + ) = + FindNearestStage(field(vectorField), Expression.vector(vectorValue), distanceMeasure, options) internal fun of( vectorField: String, - vectorValue: Expr, + vectorValue: Expression, distanceMeasure: DistanceMeasure, options: FindNearestOptions = FindNearestOptions() ) = FindNearestStage(field(vectorField), vectorValue, distanceMeasure, options) @@ -707,6 +726,10 @@ internal constructor( override fun self(options: InternalOptions) = FindNearestStage(property, vector, distanceMeasure, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf( property.toProto(userDataReader), @@ -775,7 +798,7 @@ class FindNearestOptions private constructor(options: InternalOptions) : internal class LimitStage internal constructor(val limit: Int, options: InternalOptions = InternalOptions.EMPTY) : - Stage("limit", options), Canonicalizable { + Stage("limit", options) { override fun canonicalId(): String { return "${name}(${limit})" } @@ -812,6 +835,10 @@ internal class OffsetStage internal constructor(private val offset: Int, options: InternalOptions = InternalOptions.EMPTY) : Stage("offset", options) { override fun self(options: InternalOptions) = OffsetStage(offset, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf(encodeValue(offset)) @@ -846,6 +873,10 @@ private constructor(internal val fields: Array, options: Interna of(field(fieldName), *additionalSelections) } override fun self(options: InternalOptions) = SelectStage(fields, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf(encodeValue(fields.associate { it.alias to it.toProto(userDataReader) })) @@ -898,7 +929,7 @@ internal class SortStage internal constructor( val orders: Array, options: InternalOptions = InternalOptions.EMPTY -) : Stage("sort", options), Canonicalizable { +) : Stage("sort", options) { override fun canonicalId(): String { return "${name}(${orders.joinToString(",") { it.canonicalId() }})" } @@ -952,6 +983,10 @@ internal constructor( options: InternalOptions = InternalOptions.EMPTY ) : Stage("distinct", options) { override fun self(options: InternalOptions) = DistinctStage(groups, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf(encodeValue(groups.associate { it.alias to it.toProto(userDataReader) })) @@ -984,6 +1019,10 @@ internal constructor( } } override fun self(options: InternalOptions) = RemoveFieldsStage(fields, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = fields.asSequence().map(Field::toProto) @@ -1004,7 +1043,7 @@ internal constructor( internal class ReplaceStage internal constructor( - private val mapValue: Expr, + private val mapValue: Expression, private val mode: Mode, options: InternalOptions = InternalOptions.EMPTY ) : Stage("replace_with", options) { @@ -1017,6 +1056,10 @@ internal constructor( } } override fun self(options: InternalOptions) = ReplaceStage(mapValue, mode, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf(mapValue.toProto(userDataReader), mode.proto) @@ -1052,6 +1095,10 @@ private constructor( options: InternalOptions = InternalOptions.EMPTY ) : Stage("sample", options) { override fun self(options: InternalOptions) = SampleStage(size, mode, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + class Mode private constructor(internal val proto: Value) { private constructor(protoString: String) : this(encodeValue(protoString)) companion object { @@ -1113,6 +1160,10 @@ internal constructor( options: InternalOptions = InternalOptions.EMPTY ) : Stage("union", options) { override fun self(options: InternalOptions) = UnionStage(other, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf(Value.newBuilder().setPipelineValue(other.toPipelineProto()).build()) @@ -1146,10 +1197,10 @@ internal constructor( * Creates [UnnestStage] with input array and alias specified. * * For each document emitted by the prior stage, this stage will emit zero or more augmented - * documents. The input array is found in parameter [arrayWithAlias], which can be an [Expr] - * with an alias specified via [Expr.alias], or a [Field] that can also have alias specified. - * For each element of the input array, an augmented document will be produced. The element of - * input array will be stored in a field with name specified by the alias of the + * documents. The input array is found in parameter [arrayWithAlias], which can be an + * [Expression] with an alias specified via [Expression.alias], or a [Field] that can also have + * alias specified. For each element of the input array, an augmented document will be produced. + * The element of input array will be stored in a field with name specified by the alias of the * [arrayWithAlias] parameter. If the [arrayWithAlias] is a [Field] with no alias, then the * original array field will be replaced with the individual element. * @@ -1171,9 +1222,13 @@ internal constructor( */ @JvmStatic fun withField(arrayField: String, alias: String): UnnestStage = - UnnestStage(Expr.Companion.field(arrayField).alias(alias)) + UnnestStage(Expression.Companion.field(arrayField).alias(alias)) } override fun self(options: InternalOptions) = UnnestStage(selectable, options) + override fun canonicalId(): String { + TODO("Not yet implemented") + } + override fun args(userDataReader: UserDataReader): Sequence = sequenceOf(selectable.toProto(userDataReader), field(selectable.alias).toProto()) diff --git a/firebase-firestore/src/main/java/com/google/firebase/firestore/remote/RemoteSerializer.java b/firebase-firestore/src/main/java/com/google/firebase/firestore/remote/RemoteSerializer.java index ea4ecf8b80c..e7468a02a3b 100644 --- a/firebase-firestore/src/main/java/com/google/firebase/firestore/remote/RemoteSerializer.java +++ b/firebase-firestore/src/main/java/com/google/firebase/firestore/remote/RemoteSerializer.java @@ -57,9 +57,9 @@ import com.google.firebase.firestore.pipeline.CollectionGroupSource; import com.google.firebase.firestore.pipeline.CollectionSource; import com.google.firebase.firestore.pipeline.DocumentsSource; -import com.google.firebase.firestore.pipeline.Expr; +import com.google.firebase.firestore.pipeline.Expression; import com.google.firebase.firestore.pipeline.Field; -import com.google.firebase.firestore.pipeline.FunctionExpr; +import com.google.firebase.firestore.pipeline.FunctionExpression; import com.google.firebase.firestore.pipeline.InternalOptions; import com.google.firebase.firestore.pipeline.LimitStage; import com.google.firebase.firestore.pipeline.Ordering; @@ -728,24 +728,25 @@ private Stage decodeStage(com.google.firestore.v1.Pipeline.Stage protoStage) } } - private Expr decodeExpression(Value protoValue) { + private Expression decodeExpression(Value protoValue) { switch (protoValue.getValueTypeCase()) { case FIELD_REFERENCE_VALUE: return new Field(FieldPath.fromServerFormat(protoValue.getFieldReferenceValue())); case FUNCTION_VALUE: return decodeFunctionExpression(protoValue.getFunctionValue()); default: - return new Expr.Constant(protoValue); + return new Expression.Constant(protoValue); } } - private FunctionExpr decodeFunctionExpression(com.google.firestore.v1.Function protoFunction) { + private FunctionExpression decodeFunctionExpression( + com.google.firestore.v1.Function protoFunction) { String funcName = protoFunction.getName(); - List decodedArgs = new ArrayList<>(); + List decodedArgs = new ArrayList<>(); for (Value arg : protoFunction.getArgsList()) { decodedArgs.add(decodeExpression(arg)); } - return new FunctionExpr(funcName, decodedArgs, InternalOptions.EMPTY); + return new FunctionExpression(funcName, decodedArgs, InternalOptions.EMPTY); } private Ordering decodeOrdering(Value protoValue) { @@ -753,7 +754,7 @@ private Ordering decodeOrdering(Value protoValue) { protoValue.getValueTypeCase() == Value.ValueTypeCase.MAP_VALUE, "Invalid proto_value type for Ordering, expected map_value."); - Expr decodedExpr = null; + Expression decodedExpr = null; Ordering.Direction decodedDirection = null; for (Map.Entry entry : protoValue.getMapValue().getFieldsMap().entrySet()) { diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/local/LocalSerializerTest.java b/firebase-firestore/src/test/java/com/google/firebase/firestore/local/LocalSerializerTest.java index 93803338331..06714fb0ddf 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/local/LocalSerializerTest.java +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/local/LocalSerializerTest.java @@ -45,7 +45,7 @@ import com.google.firebase.firestore.model.mutation.MutationBatch; import com.google.firebase.firestore.model.mutation.PatchMutation; import com.google.firebase.firestore.model.mutation.SetMutation; -import com.google.firebase.firestore.pipeline.Expr; +import com.google.firebase.firestore.pipeline.Expression; import com.google.firebase.firestore.proto.WriteBatch; import com.google.firebase.firestore.remote.RemoteSerializer; import com.google.firebase.firestore.testutil.TestUtil; @@ -496,8 +496,8 @@ public void encodesTargetDataWithPipeline() { RealtimePipeline pipeline = db.realtimePipeline() .collection("rooms") - .where(Expr.field("name").eq("test room")) - .sort(Expr.field("age").descending()) + .where(Expression.field("name").equal("test room")) + .sort(Expression.field("age").descending()) .limit(10); TargetOrPipeline targetOrPipeline = new TargetOrPipeline.PipelineWrapper(pipeline); diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteSchemaTest.java b/firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteSchemaTest.java index 86a560fdc37..ceed4fa299b 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteSchemaTest.java +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/local/SQLiteSchemaTest.java @@ -580,7 +580,7 @@ public void rewritesCanonicalIds() { String expectedCanonicalId = targetData.getTarget().isTarget() ? targetData.getTarget().target().getCanonicalId() - : targetData.getTarget().pipeline().canonicalId(); + : targetData.getTarget().pipeline().toString(); assertEquals(expectedCanonicalId, actualCanonicalId); } catch (InvalidProtocolBufferException e) { fail("Failed to decode Target data"); diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArithmeticTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArithmeticTests.kt index ac5e65595d9..38014de8d0f 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArithmeticTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArithmeticTests.kt @@ -16,22 +16,22 @@ package com.google.firebase.firestore.pipeline import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.model.Values.encodeValue // Returns com.google.protobuf.Value -import com.google.firebase.firestore.pipeline.Expr.Companion.abs -import com.google.firebase.firestore.pipeline.Expr.Companion.add -import com.google.firebase.firestore.pipeline.Expr.Companion.ceil -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.divide -import com.google.firebase.firestore.pipeline.Expr.Companion.exp -import com.google.firebase.firestore.pipeline.Expr.Companion.floor -import com.google.firebase.firestore.pipeline.Expr.Companion.ln -import com.google.firebase.firestore.pipeline.Expr.Companion.log -import com.google.firebase.firestore.pipeline.Expr.Companion.log10 -import com.google.firebase.firestore.pipeline.Expr.Companion.mod -import com.google.firebase.firestore.pipeline.Expr.Companion.multiply -import com.google.firebase.firestore.pipeline.Expr.Companion.pow -import com.google.firebase.firestore.pipeline.Expr.Companion.round -import com.google.firebase.firestore.pipeline.Expr.Companion.sqrt -import com.google.firebase.firestore.pipeline.Expr.Companion.subtract +import com.google.firebase.firestore.pipeline.Expression.Companion.abs +import com.google.firebase.firestore.pipeline.Expression.Companion.add +import com.google.firebase.firestore.pipeline.Expression.Companion.ceil +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.divide +import com.google.firebase.firestore.pipeline.Expression.Companion.exp +import com.google.firebase.firestore.pipeline.Expression.Companion.floor +import com.google.firebase.firestore.pipeline.Expression.Companion.ln +import com.google.firebase.firestore.pipeline.Expression.Companion.log +import com.google.firebase.firestore.pipeline.Expression.Companion.log10 +import com.google.firebase.firestore.pipeline.Expression.Companion.mod +import com.google.firebase.firestore.pipeline.Expression.Companion.multiply +import com.google.firebase.firestore.pipeline.Expression.Companion.pow +import com.google.firebase.firestore.pipeline.Expression.Companion.round +import com.google.firebase.firestore.pipeline.Expression.Companion.sqrt +import com.google.firebase.firestore.pipeline.Expression.Companion.subtract import kotlin.math.E import org.junit.Test diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArrayTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArrayTests.kt index d08ac925dd4..5c774d1a615 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArrayTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ArrayTests.kt @@ -14,17 +14,18 @@ package com.google.firebase.firestore.pipeline +// use import com.google.common.truth.Truth.assertWithMessage import com.google.firebase.firestore.model.Values.encodeValue -import com.google.firebase.firestore.pipeline.Expr.Companion.array // For the helper & direct use -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContains -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAll -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAny -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayLength -import com.google.firebase.firestore.pipeline.Expr.Companion.constant // For the helper -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.map // For map literals -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue // For the helper +import com.google.firebase.firestore.pipeline.Expression.Companion.array // For the helper & direct +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContains +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAll +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAny +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayLength +import com.google.firebase.firestore.pipeline.Expression.Companion.constant // For the helper +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.map // For map literals +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue // For the helper import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -102,8 +103,9 @@ class ArrayTests { @Test fun `arrayContainsAll - large number of elements`() { val elements = (1..500).map { it.toLong() } - // Use the statically imported 'array' directly here as it takes List - // The elements.map { constant(it) } is correct as Expr.array(List) expects Expr elements + // Use the statically imported 'array' directly here as it takes List + // The elements.map { constant(it) } is correct as Expression.array(List) expects + // Expression elements val arrayToSearch = array(elements.map { constant(it) }) val valuesToFind = array(elements.map { constant(it) }) val expr = arrayContainsAll(arrayToSearch, valuesToFind) @@ -228,7 +230,7 @@ class ArrayTests { @Test fun `arrayContains - search value is map`() { val arrayToSearch = array(123L, mapOf("foo" to 123L), mapOf("bar" to 42L), mapOf("foo" to 42L)) - val valueToFind = map(mapOf("foo" to 42L)) // Use Expr.map directly + val valueToFind = map(mapOf("foo" to 42L)) // Use Expression.map directly val expr = arrayContains(arrayToSearch, valueToFind) assertEvaluatesTo(evaluate(expr), true, "arrayContains search for map") } diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CanonifyEqTest.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CanonifyEqTest.kt index a3149651dde..54a1c9182a1 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CanonifyEqTest.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CanonifyEqTest.kt @@ -17,7 +17,7 @@ package com.google.firebase.firestore.pipeline import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.field import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -29,9 +29,9 @@ internal class CanonifyEqTest { @Test fun `canonify simple where`() { - val pipeline = RealtimePipelineSource(db).collection("test").where(field("foo").eq(42L)) + val pipeline = RealtimePipelineSource(db).collection("test").where(field("foo").equal(42L)) assertThat(pipeline.canonicalId()) - .isEqualTo("collection(test)|where(fn(eq[fld(foo),cst(42)]))|sort(fld(__name__)asc)") + .isEqualTo("collection(test)|where(fn(equal[fld(foo),cst(42)]))|sort(fld(__name__)asc)") } @Test @@ -39,12 +39,12 @@ internal class CanonifyEqTest { val pipeline = RealtimePipelineSource(db) .collection("test") - .where(field("foo").eq("42L")) + .where(field("foo").equal("42L")) .limit(10) .sort(field("bar").descending()) assertThat(pipeline.canonicalId()) .isEqualTo( - "collection(test)|where(fn(eq[fld(foo),cst(42L)]))|sort(fld(__name__)asc)|limit(10)|sort(fld(bar)desc,fld(__name__)asc)" + "collection(test)|where(fn(equal[fld(foo),cst(42L)]))|sort(fld(__name__)asc)|limit(10)|sort(fld(bar)desc,fld(__name__)asc)" ) } @@ -56,36 +56,36 @@ internal class CanonifyEqTest { @Test fun `eq returns true for identical pipelines`() { - val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").eq(42L)) - val p2 = RealtimePipelineSource(db).collection("test").where(field("foo").eq(42L)) + val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").equal(42L)) + val p2 = RealtimePipelineSource(db).collection("test").where(field("foo").equal(42L)) assertThat(p1.equals(p2)).isTrue() } @Test fun `eq returns false for different stages`() { - val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").eq(42L)) + val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").equal(42L)) val p2 = RealtimePipelineSource(db).collection("test").limit(10) assertThat(p1.equals(p2)).isFalse() } @Test fun `eq returns false for different params in stage`() { - val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").eq(42L)) - val p2 = RealtimePipelineSource(db).collection("test").where(field("bar").eq(42L)) + val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").equal(42L)) + val p2 = RealtimePipelineSource(db).collection("test").where(field("bar").equal(42L)) assertThat(p1.equals(p2)).isFalse() } @Test fun `eq returns false for different stage order`() { - val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").eq(42L)).limit(10) - val p2 = RealtimePipelineSource(db).collection("test").limit(10).where(field("foo").eq(42L)) + val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").equal(42L)).limit(10) + val p2 = RealtimePipelineSource(db).collection("test").limit(10).where(field("foo").equal(42L)) assertThat(p1.equals(p2)).isFalse() } @Test fun `eq returns false for same canonicalId but different types`() { - val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").eq("42")) - val p2 = RealtimePipelineSource(db).collection("test").where(field("foo").eq(42)) + val p1 = RealtimePipelineSource(db).collection("test").where(field("foo").equal("42")) + val p2 = RealtimePipelineSource(db).collection("test").where(field("foo").equal(42)) assertThat(p1.canonicalId()).isEqualTo(p2.canonicalId()) assertThat(p1.equals(p2)).isFalse() } diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionGroupTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionGroupTests.kt index 06a84777375..f8dc7e5f35a 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionGroupTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionGroupTests.kt @@ -19,15 +19,14 @@ import com.google.firebase.firestore.FieldPath as PublicFieldPath import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil import com.google.firebase.firestore.model.MutableDocument -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContains -import com.google.firebase.firestore.pipeline.Expr.Companion.eqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.gt -import com.google.firebase.firestore.pipeline.Expr.Companion.neq +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContains +import com.google.firebase.firestore.pipeline.Expression.Companion.equalAny +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.greaterThan +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqual import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -159,7 +158,7 @@ internal class CollectionGroupTests { val pipeline = RealtimePipelineSource(db) .collectionGroup("users") - .where(eqAny(field("score"), array(90L, 97L))) + .where(equalAny(field("score"), array(90L, 97L))) val doc1 = doc("users/bob", 1000, mapOf("score" to 90L)) val doc2 = doc("users/alice", 1000, mapOf("score" to 50L)) @@ -182,7 +181,7 @@ internal class CollectionGroupTests { @Test fun `where inequality on values`(): Unit = runBlocking { val pipeline = - RealtimePipelineSource(db).collectionGroup("users").where(gt(field("score"), 80L)) + RealtimePipelineSource(db).collectionGroup("users").where(greaterThan(field("score"), 80L)) val doc1 = doc("users/bob", 1000, mapOf("score" to 90L)) val doc2 = doc("users/alice", 1000, mapOf("score" to 50L)) @@ -199,7 +198,7 @@ internal class CollectionGroupTests { @Test fun `where not equal on values`(): Unit = runBlocking { val pipeline = - RealtimePipelineSource(db).collectionGroup("users").where(neq(field("score"), 50L)) + RealtimePipelineSource(db).collectionGroup("users").where(notEqual(field("score"), 50L)) val doc1 = doc("users/bob", 1000, mapOf("score" to 90L)) val doc2 = doc("users/alice", 1000, mapOf("score" to 50L)) // This will be filtered out diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionTests.kt index 12d133335a1..9f1d2189164 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/CollectionTests.kt @@ -19,13 +19,12 @@ import com.google.firebase.firestore.FieldPath as PublicFieldPath import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil import com.google.firebase.firestore.model.MutableDocument -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.eqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.equalAny +import com.google.firebase.firestore.pipeline.Expression.Companion.field import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -159,7 +158,7 @@ internal class CollectionTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(eqAny(field("score"), array(constant(90L), constant(97L)))) + .where(equalAny(field("score"), array(constant(90L), constant(97L)))) val doc1 = doc("users/bob", 1000, mapOf("score" to 90L)) val doc2 = doc("users/alice", 1000, mapOf("score" to 50L)) @@ -172,7 +171,8 @@ internal class CollectionTests { @Test fun `where inequality on values`(): Unit = runBlocking { - val pipeline = RealtimePipelineSource(db).collection("/users").where(field("score").gt(80L)) + val pipeline = + RealtimePipelineSource(db).collection("/users").where(field("score").greaterThan(80L)) val doc1 = doc("users/bob", 1000, mapOf("score" to 90L)) val doc2 = doc("users/alice", 1000, mapOf("score" to 50L)) @@ -184,7 +184,8 @@ internal class CollectionTests { @Test fun `where not equal on values`(): Unit = runBlocking { - val pipeline = RealtimePipelineSource(db).collection("/users").where(field("score").neq(50L)) + val pipeline = + RealtimePipelineSource(db).collection("/users").where(field("score").notEqual(50L)) val doc1 = doc("users/bob", 1000, mapOf("score" to 90L)) val doc2 = doc("users/alice", 1000, mapOf("score" to 50L)) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComparisonTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComparisonTests.kt index 78fe34d83b6..7798d845af4 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComparisonTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComparisonTests.kt @@ -17,17 +17,17 @@ package com.google.firebase.firestore.pipeline import com.google.firebase.Timestamp // For creating Timestamp instances import com.google.firebase.firestore.GeoPoint // For creating GeoPoint instances import com.google.firebase.firestore.model.Values.NULL_VALUE -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.eq -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.gt -import com.google.firebase.firestore.pipeline.Expr.Companion.gte -import com.google.firebase.firestore.pipeline.Expr.Companion.lt -import com.google.firebase.firestore.pipeline.Expr.Companion.lte -import com.google.firebase.firestore.pipeline.Expr.Companion.map -import com.google.firebase.firestore.pipeline.Expr.Companion.neq -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.equal +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.greaterThan +import com.google.firebase.firestore.pipeline.Expression.Companion.greaterThanOrEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.lessThan +import com.google.firebase.firestore.pipeline.Expression.Companion.lessThanOrEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.map +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue import com.google.firebase.firestore.testutil.TestUtil // For test helpers like map, array, etc. import com.google.firebase.firestore.testutil.TestUtilKtx.doc // For creating MutableDocument import org.junit.Test @@ -38,9 +38,9 @@ import org.robolectric.RobolectricTestRunner internal object ComparisonTestData { private const val MAX_LONG_EXACTLY_REPRESENTABLE_AS_DOUBLE = 1L shl 53 - private val BOOLEAN_VALUES: List = listOf(constant(false), constant(true)) + private val BOOLEAN_VALUES: List = listOf(constant(false), constant(true)) - private val NUMERIC_VALUES: List = + private val NUMERIC_VALUES: List = listOf( constant(Double.NEGATIVE_INFINITY), constant(-Double.MAX_VALUE), @@ -63,7 +63,7 @@ internal object ComparisonTestData { val doubleNaN = constant(Double.NaN) - private val TIMESTAMP_VALUES: List = + private val TIMESTAMP_VALUES: List = listOf( constant(Timestamp(-42, 0)), constant(Timestamp(-42, 42000000)), @@ -73,7 +73,7 @@ internal object ComparisonTestData { constant(Timestamp(42, 42000000)) ) - private val STRING_VALUES: List = + private val STRING_VALUES: List = listOf( constant(""), constant("a"), @@ -83,7 +83,7 @@ internal object ComparisonTestData { constant("z") ) - private val BLOB_VALUES: List = + private val BLOB_VALUES: List = listOf( constant(TestUtil.blob()), // Empty constant(TestUtil.blob(0, 2, 56, 42)), @@ -93,7 +93,7 @@ internal object ComparisonTestData { // Note: TestUtil.ref uses a default project "project" and default database "(default)" // So TestUtil.ref("foo/bar") becomes "projects/project/databases/(default)/documents/foo/bar" - private val REF_VALUES: List = + private val REF_VALUES: List = listOf( constant(TestUtil.ref("foo/bar")), constant(TestUtil.ref("foo/bar/qux/a")), @@ -103,7 +103,7 @@ internal object ComparisonTestData { constant(TestUtil.ref("foo/baz")) ) - private val GEO_POINT_VALUES: List = + private val GEO_POINT_VALUES: List = listOf( constant(GeoPoint(-87.0, -92.0)), constant(GeoPoint(-87.0, 0.0)), @@ -116,7 +116,7 @@ internal object ComparisonTestData { constant(GeoPoint(42.0, 42.0)) ) - private val ARRAY_VALUES: List = + private val ARRAY_VALUES: List = listOf( array(), array(constant(true), constant(15L)), @@ -128,7 +128,7 @@ internal object ComparisonTestData { array(map(emptyMap())) ) - private val MAP_VALUES: List = + private val MAP_VALUES: List = listOf( map(emptyMap()), map(mapOf("ABA" to "qux")), @@ -140,7 +140,7 @@ internal object ComparisonTestData { // Combine all comparable, non-NaN, non-Null values from the categorized lists // This is useful for testing against Null or NaN. - val allSupportedComparableValues: List = + val allSupportedComparableValues: List = BOOLEAN_VALUES + NUMERIC_VALUES + // numericValuesForNanTest already excludes NaN TIMESTAMP_VALUES + @@ -152,13 +152,13 @@ internal object ComparisonTestData { MAP_VALUES // For tests specifically about numeric comparisons against NaN - val numericValuesForNanTest: List = NUMERIC_VALUES // This list already excludes NaN + val numericValuesForNanTest: List = NUMERIC_VALUES // This list already excludes NaN // --- Dynamically generated comparison pairs based on Firestore type ordering --- // Type Order: Null < Boolean < Number < Timestamp < String < Blob < Reference < GeoPoint < Array // < Map - private val allValueCategories: List> = + private val allValueCategories: List> = listOf( listOf(nullValue()), // Null first BOOLEAN_VALUES, @@ -172,7 +172,7 @@ internal object ComparisonTestData { MAP_VALUES ) - val equivalentValues: List> = buildList { + val equivalentValues: List> = buildList { // Self-equality for all defined values (except NaN, which is special) allSupportedComparableValues.forEach { add(it to it) } @@ -189,7 +189,7 @@ internal object ComparisonTestData { add(map(mapOf("a" to 1L, "b" to 2L)) to map(mapOf("b" to 2L, "a" to 1L))) } - val lessThanValues: List> = buildList { + val lessThanValues: List> = buildList { // Intra-type comparisons for (category in allValueCategories) { for (i in 0 until category.size - 1) { @@ -200,7 +200,7 @@ internal object ComparisonTestData { } } - val mixedTypeValues: List> = buildList { + val mixedTypeValues: List> = buildList { val categories = allValueCategories.filter { it.isNotEmpty() } for (i in categories.indices) { for (j in i + 1 until categories.size) { @@ -237,7 +237,7 @@ internal class ComparisonTests { @Test fun eq_equivalentValues_returnTrue() { ComparisonTestData.equivalentValues.forEach { (v1, v2) -> - val result = evaluate(eq(v1, v2)) + val result = evaluate(equal(v1, v2)) assertEvaluatesTo(result, true, "eq(%s, %s)", v1, v2) } } @@ -246,10 +246,10 @@ internal class ComparisonTests { fun eq_lessThanValues_returnFalse() { ComparisonTestData.lessThanValues.forEach { (v1, v2) -> // eq(v1, v2) - val result1 = evaluate(eq(v1, v2)) + val result1 = evaluate(equal(v1, v2)) assertEvaluatesTo(result1, false, "eq(%s, %s)", v1, v2) // eq(v2, v1) - val result2 = evaluate(eq(v2, v1)) + val result2 = evaluate(equal(v2, v1)) assertEvaluatesTo(result2, false, "eq(%s, %s)", v2, v1) } } @@ -259,7 +259,7 @@ internal class ComparisonTests { fun eq_greaterThanValues_returnFalse() { ComparisonTestData.lessThanValues.forEach { (less, greater) -> // eq(greater, less) - val result = evaluate(eq(greater, less)) + val result = evaluate(equal(greater, less)) assertEvaluatesTo(result, false, "eq(%s, %s)", greater, less) } } @@ -267,9 +267,9 @@ internal class ComparisonTests { @Test fun eq_mixedTypeValues_returnFalse() { ComparisonTestData.mixedTypeValues.forEach { (v1, v2) -> - val result1 = evaluate(eq(v1, v2)) + val result1 = evaluate(equal(v1, v2)) assertEvaluatesTo(result1, false, "eq(%s, %s)", v1, v2) - val result2 = evaluate(eq(v2, v1)) + val result2 = evaluate(equal(v2, v1)) assertEvaluatesTo(result2, false, "eq(%s, %s)", v2, v1) } } @@ -280,7 +280,7 @@ internal class ComparisonTests { // Firestore's behavior for direct comparison of two NULL constants: val v1 = nullValue() val v2 = nullValue() - val result = evaluate(eq(v1, v2)) + val result = evaluate(equal(v1, v2)) assertEvaluatesToNull(result, "eq(%s, %s)", v1, v2) } @@ -289,14 +289,19 @@ internal class ComparisonTests { ComparisonTestData.allSupportedComparableValues.forEach { value -> val nullVal = nullValue() // eq(null, value) - assertEvaluatesToNull(evaluate(eq(nullVal, value)), "eq(%s, %s)", nullVal, value) + assertEvaluatesToNull(evaluate(equal(nullVal, value)), "eq(%s, %s)", nullVal, value) // eq(value, null) - assertEvaluatesToNull(evaluate(eq(value, nullVal)), "eq(%s, %s)", value, nullVal) + assertEvaluatesToNull(evaluate(equal(value, nullVal)), "eq(%s, %s)", value, nullVal) } // eq(null, nonExistentField) val nullVal = nullValue() val missingField = field("nonexistent") - assertEvaluatesToError(evaluate(eq(nullVal, missingField)), "eq(%s, %s)", nullVal, missingField) + assertEvaluatesToError( + evaluate(equal(nullVal, missingField)), + "eq(%s, %s)", + nullVal, + missingField + ) } @Test @@ -304,11 +309,11 @@ internal class ComparisonTests { val nanExpr = ComparisonTestData.doubleNaN // NaN == NaN is false - assertEvaluatesTo(evaluate(eq(nanExpr, nanExpr)), false, "eq(%s, %s)", nanExpr, nanExpr) + assertEvaluatesTo(evaluate(equal(nanExpr, nanExpr)), false, "eq(%s, %s)", nanExpr, nanExpr) ComparisonTestData.numericValuesForNanTest.forEach { numVal -> - assertEvaluatesTo(evaluate(eq(nanExpr, numVal)), false, "eq(%s, %s)", nanExpr, numVal) - assertEvaluatesTo(evaluate(eq(numVal, nanExpr)), false, "eq(%s, %s)", numVal, nanExpr) + assertEvaluatesTo(evaluate(equal(nanExpr, numVal)), false, "eq(%s, %s)", nanExpr, numVal) + assertEvaluatesTo(evaluate(equal(numVal, nanExpr)), false, "eq(%s, %s)", numVal, nanExpr) } // Compare NaN with non-numeric types @@ -317,8 +322,20 @@ internal class ComparisonTests { nanExpr) .forEach { otherVal -> if (otherVal != nanExpr) { // Ensure we are not re-testing NaN vs NaN or NaN vs Numeric - assertEvaluatesTo(evaluate(eq(nanExpr, otherVal)), false, "eq(%s, %s)", nanExpr, otherVal) - assertEvaluatesTo(evaluate(eq(otherVal, nanExpr)), false, "eq(%s, %s)", otherVal, nanExpr) + assertEvaluatesTo( + evaluate(equal(nanExpr, otherVal)), + false, + "eq(%s, %s)", + nanExpr, + otherVal + ) + assertEvaluatesTo( + evaluate(equal(otherVal, nanExpr)), + false, + "eq(%s, %s)", + otherVal, + nanExpr + ) } } @@ -326,7 +343,7 @@ internal class ComparisonTests { val arrayWithNaN1 = array(constant(Double.NaN)) val arrayWithNaN2 = array(constant(Double.NaN)) assertEvaluatesTo( - evaluate(eq(arrayWithNaN1, arrayWithNaN2)), + evaluate(equal(arrayWithNaN1, arrayWithNaN2)), false, "eq(%s, %s)", arrayWithNaN1, @@ -337,7 +354,7 @@ internal class ComparisonTests { val mapWithNaN1 = map(mapOf("foo" to Double.NaN)) val mapWithNaN2 = map(mapOf("foo" to Double.NaN)) assertEvaluatesTo( - evaluate(eq(mapWithNaN1, mapWithNaN2)), + evaluate(equal(mapWithNaN1, mapWithNaN2)), false, "eq(%s, %s)", mapWithNaN1, @@ -349,29 +366,34 @@ internal class ComparisonTests { fun eq_nullContainerEquality_various() { val nullArray = array(nullValue()) // Array containing a Firestore Null - assertEvaluatesTo(evaluate(eq(nullArray, constant(1L))), false, "eq(%s, 1L)", nullArray) - assertEvaluatesTo(evaluate(eq(nullArray, constant("1"))), false, "eq(%s, \\\"1\\\")", nullArray) + assertEvaluatesTo(evaluate(equal(nullArray, constant(1L))), false, "eq(%s, 1L)", nullArray) + assertEvaluatesTo( + evaluate(equal(nullArray, constant("1"))), + false, + "eq(%s, \\\"1\\\")", + nullArray + ) assertEvaluatesToNull( - evaluate(eq(nullArray, nullValue())), + evaluate(equal(nullArray, nullValue())), "eq(%s, %s)", nullArray, nullValue() ) assertEvaluatesTo( - evaluate(eq(nullArray, ComparisonTestData.doubleNaN)), + evaluate(equal(nullArray, ComparisonTestData.doubleNaN)), false, "eq(%s, %s)", nullArray, ComparisonTestData.doubleNaN ) - assertEvaluatesTo(evaluate(eq(nullArray, array())), false, "eq(%s, [])", nullArray) + assertEvaluatesTo(evaluate(equal(nullArray, array())), false, "eq(%s, [])", nullArray) val nanArray = array(constant(Double.NaN)) - assertEvaluatesToNull(evaluate(eq(nullArray, nanArray)), "eq(%s, %s)", nullArray, nanArray) + assertEvaluatesToNull(evaluate(equal(nullArray, nanArray)), "eq(%s, %s)", nullArray, nanArray) val anotherNullArray = array(nullValue()) assertEvaluatesToNull( - evaluate(eq(nullArray, anotherNullArray)), + evaluate(equal(nullArray, anotherNullArray)), "eq(%s, %s)", nullArray, anotherNullArray @@ -380,12 +402,12 @@ internal class ComparisonTests { val nullMap = map(mapOf("foo" to NULL_VALUE)) // Map containing a Firestore Null val anotherNullMap = map(mapOf("foo" to NULL_VALUE)) assertEvaluatesToNull( - evaluate(eq(nullMap, anotherNullMap)), + evaluate(equal(nullMap, anotherNullMap)), "eq(%s, %s)", nullMap, anotherNullMap ) - assertEvaluatesTo(evaluate(eq(nullMap, map(emptyMap()))), false, "eq(%s, {})", nullMap) + assertEvaluatesTo(evaluate(equal(nullMap, map(emptyMap()))), false, "eq(%s, {})", nullMap) } @Test @@ -396,26 +418,26 @@ internal class ComparisonTests { ComparisonTestData.allSupportedComparableValues.forEach { value -> assertEvaluatesToError( - evaluate(eq(errorExpr, value), testDoc), + evaluate(equal(errorExpr, value), testDoc), "eq(%s, %s)", errorExpr, value ) assertEvaluatesToError( - evaluate(eq(value, errorExpr), testDoc), + evaluate(equal(value, errorExpr), testDoc), "eq(%s, %s)", value, errorExpr ) } assertEvaluatesToError( - evaluate(eq(errorExpr, errorExpr), testDoc), + evaluate(equal(errorExpr, errorExpr), testDoc), "eq(%s, %s)", errorExpr, errorExpr ) assertEvaluatesToError( - evaluate(eq(errorExpr, nullValue()), testDoc), + evaluate(equal(errorExpr, nullValue()), testDoc), "eq(%s, %s)", errorExpr, nullValue() @@ -429,13 +451,13 @@ internal class ComparisonTests { val testDoc = doc("test/eqMissing", 0, mapOf("exists" to 10L)) assertEvaluatesToError( - evaluate(eq(missingField, presentValue), testDoc), + evaluate(equal(missingField, presentValue), testDoc), "eq(%s, %s)", missingField, presentValue ) assertEvaluatesToError( - evaluate(eq(presentValue, missingField), testDoc), + evaluate(equal(presentValue, missingField), testDoc), "eq(%s, %s)", presentValue, missingField @@ -447,7 +469,7 @@ internal class ComparisonTests { @Test fun neq_equivalentValues_returnFalse() { ComparisonTestData.equivalentValues.forEach { (v1, v2) -> - val result = evaluate(neq(v1, v2)) + val result = evaluate(notEqual(v1, v2)) if (v1 == nullValue() && v2 == nullValue()) { assertEvaluatesToNull(result, "neq(%s, %s)", v1, v2) } else { @@ -459,15 +481,15 @@ internal class ComparisonTests { @Test fun neq_lessThanValues_returnTrue() { ComparisonTestData.lessThanValues.forEach { (v1, v2) -> - assertEvaluatesTo(evaluate(neq(v1, v2)), true, "neq(%s, %s)", v1, v2) - assertEvaluatesTo(evaluate(neq(v2, v1)), true, "neq(%s, %s)", v2, v1) + assertEvaluatesTo(evaluate(notEqual(v1, v2)), true, "neq(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(notEqual(v2, v1)), true, "neq(%s, %s)", v2, v1) } } @Test fun neq_greaterThanValues_returnTrue() { ComparisonTestData.lessThanValues.forEach { (less, greater) -> - assertEvaluatesTo(evaluate(neq(greater, less)), true, "neq(%s, %s)", greater, less) + assertEvaluatesTo(evaluate(notEqual(greater, less)), true, "neq(%s, %s)", greater, less) } } @@ -475,11 +497,11 @@ internal class ComparisonTests { fun neq_mixedTypeValues_returnTrue() { ComparisonTestData.mixedTypeValues.forEach { (v1, v2) -> if (v1 == nullValue() || v2 == nullValue()) { - assertEvaluatesToNull(evaluate(neq(v1, v2)), "neq(%s, %s)", v1, v2) - assertEvaluatesToNull(evaluate(neq(v2, v1)), "neq(%s, %s)", v2, v1) + assertEvaluatesToNull(evaluate(notEqual(v1, v2)), "neq(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(notEqual(v2, v1)), "neq(%s, %s)", v2, v1) } else { - assertEvaluatesTo(evaluate(neq(v1, v2)), true, "neq(%s, %s)", v1, v2) - assertEvaluatesTo(evaluate(neq(v2, v1)), true, "neq(%s, %s)", v2, v1) + assertEvaluatesTo(evaluate(notEqual(v1, v2)), true, "neq(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(notEqual(v2, v1)), true, "neq(%s, %s)", v2, v1) } } } @@ -488,7 +510,7 @@ internal class ComparisonTests { fun neq_nullNotEqualsNull_returnsNull() { val v1 = nullValue() val v2 = nullValue() - val result = evaluate(neq(v1, v2)) + val result = evaluate(notEqual(v1, v2)) assertEvaluatesToNull(result, "neq(%s, %s)", v1, v2) } @@ -496,13 +518,13 @@ internal class ComparisonTests { fun neq_nullOperand_returnsNullOrError() { ComparisonTestData.allSupportedComparableValues.forEach { value -> val nullVal = nullValue() - assertEvaluatesToNull(evaluate(neq(nullVal, value)), "neq(%s, %s)", nullVal, value) - assertEvaluatesToNull(evaluate(neq(value, nullVal)), "neq(%s, %s)", value, nullVal) + assertEvaluatesToNull(evaluate(notEqual(nullVal, value)), "neq(%s, %s)", nullVal, value) + assertEvaluatesToNull(evaluate(notEqual(value, nullVal)), "neq(%s, %s)", value, nullVal) } val nullVal = nullValue() val missingField = field("nonexistent") assertEvaluatesToError( - evaluate(neq(nullVal, missingField)), + evaluate(notEqual(nullVal, missingField)), "neq(%s, %s)", nullVal, missingField @@ -512,11 +534,11 @@ internal class ComparisonTests { @Test fun neq_nanComparisons_returnTrue() { val nanExpr = ComparisonTestData.doubleNaN - assertEvaluatesTo(evaluate(neq(nanExpr, nanExpr)), true, "neq(%s, %s)", nanExpr, nanExpr) + assertEvaluatesTo(evaluate(notEqual(nanExpr, nanExpr)), true, "neq(%s, %s)", nanExpr, nanExpr) ComparisonTestData.numericValuesForNanTest.forEach { numVal -> - assertEvaluatesTo(evaluate(neq(nanExpr, numVal)), true, "neq(%s, %s)", nanExpr, numVal) - assertEvaluatesTo(evaluate(neq(numVal, nanExpr)), true, "neq(%s, %s)", numVal, nanExpr) + assertEvaluatesTo(evaluate(notEqual(nanExpr, numVal)), true, "neq(%s, %s)", nanExpr, numVal) + assertEvaluatesTo(evaluate(notEqual(numVal, nanExpr)), true, "neq(%s, %s)", numVal, nanExpr) } (ComparisonTestData.allSupportedComparableValues - @@ -525,14 +547,14 @@ internal class ComparisonTests { .forEach { otherVal -> if (otherVal != nanExpr) { assertEvaluatesTo( - evaluate(neq(nanExpr, otherVal)), + evaluate(notEqual(nanExpr, otherVal)), true, "neq(%s, %s)", nanExpr, otherVal ) assertEvaluatesTo( - evaluate(neq(otherVal, nanExpr)), + evaluate(notEqual(otherVal, nanExpr)), true, "neq(%s, %s)", otherVal, @@ -544,7 +566,7 @@ internal class ComparisonTests { val arrayWithNaN1 = array(constant(Double.NaN)) val arrayWithNaN2 = array(constant(Double.NaN)) assertEvaluatesTo( - evaluate(neq(arrayWithNaN1, arrayWithNaN2)), + evaluate(notEqual(arrayWithNaN1, arrayWithNaN2)), true, "neq(%s, %s)", arrayWithNaN1, @@ -554,7 +576,7 @@ internal class ComparisonTests { val mapWithNaN1 = map(mapOf("foo" to Double.NaN)) val mapWithNaN2 = map(mapOf("foo" to Double.NaN)) assertEvaluatesTo( - evaluate(neq(mapWithNaN1, mapWithNaN2)), + evaluate(notEqual(mapWithNaN1, mapWithNaN2)), true, "neq(%s, %s)", mapWithNaN1, @@ -569,26 +591,26 @@ internal class ComparisonTests { ComparisonTestData.allSupportedComparableValues.forEach { value -> assertEvaluatesToError( - evaluate(neq(errorExpr, value), testDoc), + evaluate(notEqual(errorExpr, value), testDoc), "neq(%s, %s)", errorExpr, value ) assertEvaluatesToError( - evaluate(neq(value, errorExpr), testDoc), + evaluate(notEqual(value, errorExpr), testDoc), "neq(%s, %s)", value, errorExpr ) } assertEvaluatesToError( - evaluate(neq(errorExpr, errorExpr), testDoc), + evaluate(notEqual(errorExpr, errorExpr), testDoc), "neq(%s, %s)", errorExpr, errorExpr ) assertEvaluatesToError( - evaluate(neq(errorExpr, nullValue()), testDoc), + evaluate(notEqual(errorExpr, nullValue()), testDoc), "neq(%s, %s)", errorExpr, nullValue() @@ -602,13 +624,13 @@ internal class ComparisonTests { val testDoc = doc("test/neqMissing", 0, mapOf("exists" to 10L)) assertEvaluatesToError( - evaluate(neq(missingField, presentValue), testDoc), + evaluate(notEqual(missingField, presentValue), testDoc), "neq(%s, %s)", missingField, presentValue ) assertEvaluatesToError( - evaluate(neq(presentValue, missingField), testDoc), + evaluate(notEqual(presentValue, missingField), testDoc), "neq(%s, %s)", presentValue, missingField @@ -621,9 +643,9 @@ internal class ComparisonTests { fun lt_equivalentValues_returnFalse() { ComparisonTestData.equivalentValues.forEach { (v1, v2) -> if (v1 == nullValue() && v2 == nullValue()) { - assertEvaluatesToNull(evaluate(lt(v1, v2)), "lt(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(lessThan(v1, v2)), "lt(%s, %s)", v1, v2) } else { - assertEvaluatesTo(evaluate(lt(v1, v2)), false, "lt(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(lessThan(v1, v2)), false, "lt(%s, %s)", v1, v2) } } } @@ -631,7 +653,7 @@ internal class ComparisonTests { @Test fun lt_lessThanValues_returnTrue() { ComparisonTestData.lessThanValues.forEach { (v1, v2) -> - val result = evaluate(lt(v1, v2)) + val result = evaluate(lessThan(v1, v2)) assertEvaluatesTo(result, true, "lt(%s, %s)", v1, v2) } } @@ -639,7 +661,7 @@ internal class ComparisonTests { @Test fun lt_greaterThanValues_returnFalse() { ComparisonTestData.lessThanValues.forEach { (less, greater) -> - assertEvaluatesTo(evaluate(lt(greater, less)), false, "lt(%s, %s)", greater, less) + assertEvaluatesTo(evaluate(lessThan(greater, less)), false, "lt(%s, %s)", greater, less) } } @@ -647,11 +669,11 @@ internal class ComparisonTests { fun lt_mixedTypeValues_returnFalse() { ComparisonTestData.mixedTypeValues.forEach { (v1, v2) -> if (v1 == nullValue() || v2 == nullValue()) { - assertEvaluatesToNull(evaluate(lt(v1, v2)), "lt(%s, %s)", v1, v2) - assertEvaluatesToNull(evaluate(lt(v2, v1)), "lt(%s, %s)", v2, v1) + assertEvaluatesToNull(evaluate(lessThan(v1, v2)), "lt(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(lessThan(v2, v1)), "lt(%s, %s)", v2, v1) } else { - assertEvaluatesTo(evaluate(lt(v1, v2)), false, "lt(%s, %s)", v1, v2) - assertEvaluatesTo(evaluate(lt(v2, v1)), false, "lt(%s, %s)", v2, v1) + assertEvaluatesTo(evaluate(lessThan(v1, v2)), false, "lt(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(lessThan(v2, v1)), false, "lt(%s, %s)", v2, v1) } } } @@ -660,37 +682,54 @@ internal class ComparisonTests { fun lt_nullOperand_returnsNullOrError() { ComparisonTestData.allSupportedComparableValues.forEach { value -> val nullVal = nullValue() - assertEvaluatesToNull(evaluate(lt(nullVal, value)), "lt(%s, %s)", nullVal, value) - assertEvaluatesToNull(evaluate(lt(value, nullVal)), "lt(%s, %s)", value, nullVal) + assertEvaluatesToNull(evaluate(lessThan(nullVal, value)), "lt(%s, %s)", nullVal, value) + assertEvaluatesToNull(evaluate(lessThan(value, nullVal)), "lt(%s, %s)", value, nullVal) } val nullVal = nullValue() - assertEvaluatesToNull(evaluate(lt(nullVal, nullVal)), "lt(%s, %s)", nullVal, nullVal) + assertEvaluatesToNull(evaluate(lessThan(nullVal, nullVal)), "lt(%s, %s)", nullVal, nullVal) val missingField = field("nonexistent") - assertEvaluatesToError(evaluate(lt(nullVal, missingField)), "lt(%s, %s)", nullVal, missingField) + assertEvaluatesToError( + evaluate(lessThan(nullVal, missingField)), + "lt(%s, %s)", + nullVal, + missingField + ) } @Test fun lt_nanComparisons_returnFalse() { val nanExpr = ComparisonTestData.doubleNaN - assertEvaluatesTo(evaluate(lt(nanExpr, nanExpr)), false, "lt(%s, %s)", nanExpr, nanExpr) + assertEvaluatesTo(evaluate(lessThan(nanExpr, nanExpr)), false, "lt(%s, %s)", nanExpr, nanExpr) ComparisonTestData.numericValuesForNanTest.forEach { numVal -> - assertEvaluatesTo(evaluate(lt(nanExpr, numVal)), false, "lt(%s, %s)", nanExpr, numVal) - assertEvaluatesTo(evaluate(lt(numVal, nanExpr)), false, "lt(%s, %s)", numVal, nanExpr) + assertEvaluatesTo(evaluate(lessThan(nanExpr, numVal)), false, "lt(%s, %s)", nanExpr, numVal) + assertEvaluatesTo(evaluate(lessThan(numVal, nanExpr)), false, "lt(%s, %s)", numVal, nanExpr) } (ComparisonTestData.allSupportedComparableValues - ComparisonTestData.numericValuesForNanTest.toSet() - nanExpr) .forEach { otherVal -> if (otherVal != nanExpr) { - assertEvaluatesTo(evaluate(lt(nanExpr, otherVal)), false, "lt(%s, %s)", nanExpr, otherVal) - assertEvaluatesTo(evaluate(lt(otherVal, nanExpr)), false, "lt(%s, %s)", otherVal, nanExpr) + assertEvaluatesTo( + evaluate(lessThan(nanExpr, otherVal)), + false, + "lt(%s, %s)", + nanExpr, + otherVal + ) + assertEvaluatesTo( + evaluate(lessThan(otherVal, nanExpr)), + false, + "lt(%s, %s)", + otherVal, + nanExpr + ) } } val arrayWithNaN1 = array(constant(Double.NaN)) val arrayWithNaN2 = array(constant(Double.NaN)) assertEvaluatesTo( - evaluate(lt(arrayWithNaN1, arrayWithNaN2)), + evaluate(lessThan(arrayWithNaN1, arrayWithNaN2)), false, "lt(%s, %s)", arrayWithNaN1, @@ -705,26 +744,26 @@ internal class ComparisonTests { ComparisonTestData.allSupportedComparableValues.forEach { value -> assertEvaluatesToError( - evaluate(lt(errorExpr, value), testDoc), + evaluate(lessThan(errorExpr, value), testDoc), "lt(%s, %s)", errorExpr, value ) assertEvaluatesToError( - evaluate(lt(value, errorExpr), testDoc), + evaluate(lessThan(value, errorExpr), testDoc), "lt(%s, %s)", value, errorExpr ) } assertEvaluatesToError( - evaluate(lt(errorExpr, errorExpr), testDoc), + evaluate(lessThan(errorExpr, errorExpr), testDoc), "lt(%s, %s)", errorExpr, errorExpr ) assertEvaluatesToError( - evaluate(lt(errorExpr, nullValue()), testDoc), + evaluate(lessThan(errorExpr, nullValue()), testDoc), "lt(%s, %s)", errorExpr, nullValue() @@ -738,13 +777,13 @@ internal class ComparisonTests { val testDoc = doc("test/ltMissing", 0, mapOf("exists" to 10L)) assertEvaluatesToError( - evaluate(lt(missingField, presentValue), testDoc), + evaluate(lessThan(missingField, presentValue), testDoc), "lt(%s, %s)", missingField, presentValue ) assertEvaluatesToError( - evaluate(lt(presentValue, missingField), testDoc), + evaluate(lessThan(presentValue, missingField), testDoc), "lt(%s, %s)", presentValue, missingField @@ -757,9 +796,9 @@ internal class ComparisonTests { fun lte_equivalentValues_returnTrue() { ComparisonTestData.equivalentValues.forEach { (v1, v2) -> if (v1 == nullValue() && v2 == nullValue()) { - assertEvaluatesToNull(evaluate(lte(v1, v2)), "lte(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(lessThanOrEqual(v1, v2)), "lte(%s, %s)", v1, v2) } else { - assertEvaluatesTo(evaluate(lte(v1, v2)), true, "lte(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(lessThanOrEqual(v1, v2)), true, "lte(%s, %s)", v1, v2) } } } @@ -767,14 +806,20 @@ internal class ComparisonTests { @Test fun lte_lessThanValues_returnTrue() { ComparisonTestData.lessThanValues.forEach { (v1, v2) -> - assertEvaluatesTo(evaluate(lte(v1, v2)), true, "lte(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(lessThanOrEqual(v1, v2)), true, "lte(%s, %s)", v1, v2) } } @Test fun lte_greaterThanValues_returnFalse() { ComparisonTestData.lessThanValues.forEach { (less, greater) -> - assertEvaluatesTo(evaluate(lte(greater, less)), false, "lte(%s, %s)", greater, less) + assertEvaluatesTo( + evaluate(lessThanOrEqual(greater, less)), + false, + "lte(%s, %s)", + greater, + less + ) } } @@ -782,11 +827,11 @@ internal class ComparisonTests { fun lte_mixedTypeValues_returnFalse() { ComparisonTestData.mixedTypeValues.forEach { (v1, v2) -> if (v1 == nullValue() || v2 == nullValue()) { - assertEvaluatesToNull(evaluate(lte(v1, v2)), "lte(%s, %s)", v1, v2) - assertEvaluatesToNull(evaluate(lte(v2, v1)), "lte(%s, %s)", v2, v1) + assertEvaluatesToNull(evaluate(lessThanOrEqual(v1, v2)), "lte(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(lessThanOrEqual(v2, v1)), "lte(%s, %s)", v2, v1) } else { - assertEvaluatesTo(evaluate(lte(v1, v2)), false, "lte(%s, %s)", v1, v2) - assertEvaluatesTo(evaluate(lte(v2, v1)), false, "lte(%s, %s)", v2, v1) + assertEvaluatesTo(evaluate(lessThanOrEqual(v1, v2)), false, "lte(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(lessThanOrEqual(v2, v1)), false, "lte(%s, %s)", v2, v1) } } } @@ -795,14 +840,29 @@ internal class ComparisonTests { fun lte_nullOperand_returnsNullOrError() { ComparisonTestData.allSupportedComparableValues.forEach { value -> val nullVal = nullValue() - assertEvaluatesToNull(evaluate(lte(nullVal, value)), "lte(%s, %s)", nullVal, value) - assertEvaluatesToNull(evaluate(lte(value, nullVal)), "lte(%s, %s)", value, nullVal) + assertEvaluatesToNull( + evaluate(lessThanOrEqual(nullVal, value)), + "lte(%s, %s)", + nullVal, + value + ) + assertEvaluatesToNull( + evaluate(lessThanOrEqual(value, nullVal)), + "lte(%s, %s)", + value, + nullVal + ) } val nullVal = nullValue() - assertEvaluatesToNull(evaluate(lte(nullVal, nullVal)), "lte(%s, %s)", nullVal, nullVal) + assertEvaluatesToNull( + evaluate(lessThanOrEqual(nullVal, nullVal)), + "lte(%s, %s)", + nullVal, + nullVal + ) val missingField = field("nonexistent") assertEvaluatesToError( - evaluate(lte(nullVal, missingField)), + evaluate(lessThanOrEqual(nullVal, missingField)), "lte(%s, %s)", nullVal, missingField @@ -812,11 +872,29 @@ internal class ComparisonTests { @Test fun lte_nanComparisons_returnFalse() { val nanExpr = ComparisonTestData.doubleNaN - assertEvaluatesTo(evaluate(lte(nanExpr, nanExpr)), false, "lte(%s, %s)", nanExpr, nanExpr) + assertEvaluatesTo( + evaluate(lessThanOrEqual(nanExpr, nanExpr)), + false, + "lte(%s, %s)", + nanExpr, + nanExpr + ) ComparisonTestData.numericValuesForNanTest.forEach { numVal -> - assertEvaluatesTo(evaluate(lte(nanExpr, numVal)), false, "lte(%s, %s)", nanExpr, numVal) - assertEvaluatesTo(evaluate(lte(numVal, nanExpr)), false, "lte(%s, %s)", numVal, nanExpr) + assertEvaluatesTo( + evaluate(lessThanOrEqual(nanExpr, numVal)), + false, + "lte(%s, %s)", + nanExpr, + numVal + ) + assertEvaluatesTo( + evaluate(lessThanOrEqual(numVal, nanExpr)), + false, + "lte(%s, %s)", + numVal, + nanExpr + ) } (ComparisonTestData.allSupportedComparableValues - ComparisonTestData.numericValuesForNanTest.toSet() - @@ -824,14 +902,14 @@ internal class ComparisonTests { .forEach { otherVal -> if (otherVal != nanExpr) { assertEvaluatesTo( - evaluate(lte(nanExpr, otherVal)), + evaluate(lessThanOrEqual(nanExpr, otherVal)), false, "lte(%s, %s)", nanExpr, otherVal ) assertEvaluatesTo( - evaluate(lte(otherVal, nanExpr)), + evaluate(lessThanOrEqual(otherVal, nanExpr)), false, "lte(%s, %s)", otherVal, @@ -842,7 +920,7 @@ internal class ComparisonTests { val arrayWithNaN1 = array(constant(Double.NaN)) val arrayWithNaN2 = array(constant(Double.NaN)) assertEvaluatesTo( - evaluate(lte(arrayWithNaN1, arrayWithNaN2)), + evaluate(lessThanOrEqual(arrayWithNaN1, arrayWithNaN2)), false, "lte(%s, %s)", arrayWithNaN1, @@ -857,26 +935,26 @@ internal class ComparisonTests { ComparisonTestData.allSupportedComparableValues.forEach { value -> assertEvaluatesToError( - evaluate(lte(errorExpr, value), testDoc), + evaluate(lessThanOrEqual(errorExpr, value), testDoc), "lte(%s, %s)", errorExpr, value ) assertEvaluatesToError( - evaluate(lte(value, errorExpr), testDoc), + evaluate(lessThanOrEqual(value, errorExpr), testDoc), "lte(%s, %s)", value, errorExpr ) } assertEvaluatesToError( - evaluate(lte(errorExpr, errorExpr), testDoc), + evaluate(lessThanOrEqual(errorExpr, errorExpr), testDoc), "lte(%s, %s)", errorExpr, errorExpr ) assertEvaluatesToError( - evaluate(lte(errorExpr, nullValue()), testDoc), + evaluate(lessThanOrEqual(errorExpr, nullValue()), testDoc), "lte(%s, %s)", errorExpr, nullValue() @@ -890,13 +968,13 @@ internal class ComparisonTests { val testDoc = doc("test/lteMissing", 0, mapOf("exists" to 10L)) assertEvaluatesToError( - evaluate(lte(missingField, presentValue), testDoc), + evaluate(lessThanOrEqual(missingField, presentValue), testDoc), "lte(%s, %s)", missingField, presentValue ) assertEvaluatesToError( - evaluate(lte(presentValue, missingField), testDoc), + evaluate(lessThanOrEqual(presentValue, missingField), testDoc), "lte(%s, %s)", presentValue, missingField @@ -909,9 +987,9 @@ internal class ComparisonTests { fun gt_equivalentValues_returnFalse() { ComparisonTestData.equivalentValues.forEach { (v1, v2) -> if (v1 == nullValue() && v2 == nullValue()) { - assertEvaluatesToNull(evaluate(gt(v1, v2)), "gt(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(greaterThan(v1, v2)), "gt(%s, %s)", v1, v2) } else { - assertEvaluatesTo(evaluate(gt(v1, v2)), false, "gt(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(greaterThan(v1, v2)), false, "gt(%s, %s)", v1, v2) } } } @@ -919,14 +997,14 @@ internal class ComparisonTests { @Test fun gt_lessThanValues_returnFalse() { ComparisonTestData.lessThanValues.forEach { (v1, v2) -> - assertEvaluatesTo(evaluate(gt(v1, v2)), false, "gt(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(greaterThan(v1, v2)), false, "gt(%s, %s)", v1, v2) } } @Test fun gt_greaterThanValues_returnTrue() { ComparisonTestData.lessThanValues.forEach { (less, greater) -> - assertEvaluatesTo(evaluate(gt(greater, less)), true, "gt(%s, %s)", greater, less) + assertEvaluatesTo(evaluate(greaterThan(greater, less)), true, "gt(%s, %s)", greater, less) } } @@ -934,11 +1012,11 @@ internal class ComparisonTests { fun gt_mixedTypeValues_returnFalse() { ComparisonTestData.mixedTypeValues.forEach { (v1, v2) -> if (v1 == nullValue() || v2 == nullValue()) { - assertEvaluatesToNull(evaluate(gt(v1, v2)), "gt(%s, %s)", v1, v2) - assertEvaluatesToNull(evaluate(gt(v2, v1)), "gt(%s, %s)", v2, v1) + assertEvaluatesToNull(evaluate(greaterThan(v1, v2)), "gt(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(greaterThan(v2, v1)), "gt(%s, %s)", v2, v1) } else { - assertEvaluatesTo(evaluate(gt(v1, v2)), false, "gt(%s, %s)", v1, v2) - assertEvaluatesTo(evaluate(gt(v2, v1)), false, "gt(%s, %s)", v2, v1) + assertEvaluatesTo(evaluate(greaterThan(v1, v2)), false, "gt(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(greaterThan(v2, v1)), false, "gt(%s, %s)", v2, v1) } } } @@ -947,37 +1025,72 @@ internal class ComparisonTests { fun gt_nullOperand_returnsNullOrError() { ComparisonTestData.allSupportedComparableValues.forEach { value -> val nullVal = nullValue() - assertEvaluatesToNull(evaluate(gt(nullVal, value)), "gt(%s, %s)", nullVal, value) - assertEvaluatesToNull(evaluate(gt(value, nullVal)), "gt(%s, %s)", value, nullVal) + assertEvaluatesToNull(evaluate(greaterThan(nullVal, value)), "gt(%s, %s)", nullVal, value) + assertEvaluatesToNull(evaluate(greaterThan(value, nullVal)), "gt(%s, %s)", value, nullVal) } val nullVal = nullValue() - assertEvaluatesToNull(evaluate(gt(nullVal, nullVal)), "gt(%s, %s)", nullVal, nullVal) + assertEvaluatesToNull(evaluate(greaterThan(nullVal, nullVal)), "gt(%s, %s)", nullVal, nullVal) val missingField = field("nonexistent") - assertEvaluatesToError(evaluate(gt(nullVal, missingField)), "gt(%s, %s)", nullVal, missingField) + assertEvaluatesToError( + evaluate(greaterThan(nullVal, missingField)), + "gt(%s, %s)", + nullVal, + missingField + ) } @Test fun gt_nanComparisons_returnFalse() { val nanExpr = ComparisonTestData.doubleNaN - assertEvaluatesTo(evaluate(gt(nanExpr, nanExpr)), false, "gt(%s, %s)", nanExpr, nanExpr) + assertEvaluatesTo( + evaluate(greaterThan(nanExpr, nanExpr)), + false, + "gt(%s, %s)", + nanExpr, + nanExpr + ) ComparisonTestData.numericValuesForNanTest.forEach { numVal -> - assertEvaluatesTo(evaluate(gt(nanExpr, numVal)), false, "gt(%s, %s)", nanExpr, numVal) - assertEvaluatesTo(evaluate(gt(numVal, nanExpr)), false, "gt(%s, %s)", numVal, nanExpr) + assertEvaluatesTo( + evaluate(greaterThan(nanExpr, numVal)), + false, + "gt(%s, %s)", + nanExpr, + numVal + ) + assertEvaluatesTo( + evaluate(greaterThan(numVal, nanExpr)), + false, + "gt(%s, %s)", + numVal, + nanExpr + ) } (ComparisonTestData.allSupportedComparableValues - ComparisonTestData.numericValuesForNanTest.toSet() - nanExpr) .forEach { otherVal -> if (otherVal != nanExpr) { - assertEvaluatesTo(evaluate(gt(nanExpr, otherVal)), false, "gt(%s, %s)", nanExpr, otherVal) - assertEvaluatesTo(evaluate(gt(otherVal, nanExpr)), false, "gt(%s, %s)", otherVal, nanExpr) + assertEvaluatesTo( + evaluate(greaterThan(nanExpr, otherVal)), + false, + "gt(%s, %s)", + nanExpr, + otherVal + ) + assertEvaluatesTo( + evaluate(greaterThan(otherVal, nanExpr)), + false, + "gt(%s, %s)", + otherVal, + nanExpr + ) } } val arrayWithNaN1 = array(constant(Double.NaN)) val arrayWithNaN2 = array(constant(Double.NaN)) assertEvaluatesTo( - evaluate(gt(arrayWithNaN1, arrayWithNaN2)), + evaluate(greaterThan(arrayWithNaN1, arrayWithNaN2)), false, "gt(%s, %s)", arrayWithNaN1, @@ -992,26 +1105,26 @@ internal class ComparisonTests { ComparisonTestData.allSupportedComparableValues.forEach { value -> assertEvaluatesToError( - evaluate(gt(errorExpr, value), testDoc), + evaluate(greaterThan(errorExpr, value), testDoc), "gt(%s, %s)", errorExpr, value ) assertEvaluatesToError( - evaluate(gt(value, errorExpr), testDoc), + evaluate(greaterThan(value, errorExpr), testDoc), "gt(%s, %s)", value, errorExpr ) } assertEvaluatesToError( - evaluate(gt(errorExpr, errorExpr), testDoc), + evaluate(greaterThan(errorExpr, errorExpr), testDoc), "gt(%s, %s)", errorExpr, errorExpr ) assertEvaluatesToError( - evaluate(gt(errorExpr, nullValue()), testDoc), + evaluate(greaterThan(errorExpr, nullValue()), testDoc), "gt(%s, %s)", errorExpr, nullValue() @@ -1025,13 +1138,13 @@ internal class ComparisonTests { val testDoc = doc("test/gtMissing", 0, mapOf("exists" to 10L)) assertEvaluatesToError( - evaluate(gt(missingField, presentValue), testDoc), + evaluate(greaterThan(missingField, presentValue), testDoc), "gt(%s, %s)", missingField, presentValue ) assertEvaluatesToError( - evaluate(gt(presentValue, missingField), testDoc), + evaluate(greaterThan(presentValue, missingField), testDoc), "gt(%s, %s)", presentValue, missingField @@ -1044,9 +1157,9 @@ internal class ComparisonTests { fun gte_equivalentValues_returnTrue() { ComparisonTestData.equivalentValues.forEach { (v1, v2) -> if (v1 == nullValue() && v2 == nullValue()) { - assertEvaluatesToNull(evaluate(gte(v1, v2)), "gte(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(greaterThanOrEqual(v1, v2)), "gte(%s, %s)", v1, v2) } else { - assertEvaluatesTo(evaluate(gte(v1, v2)), true, "gte(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(greaterThanOrEqual(v1, v2)), true, "gte(%s, %s)", v1, v2) } } } @@ -1054,14 +1167,20 @@ internal class ComparisonTests { @Test fun gte_lessThanValues_returnFalse() { ComparisonTestData.lessThanValues.forEach { (v1, v2) -> - assertEvaluatesTo(evaluate(gte(v1, v2)), false, "gte(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(greaterThanOrEqual(v1, v2)), false, "gte(%s, %s)", v1, v2) } } @Test fun gte_greaterThanValues_returnTrue() { ComparisonTestData.lessThanValues.forEach { (less, greater) -> - assertEvaluatesTo(evaluate(gte(greater, less)), true, "gte(%s, %s)", greater, less) + assertEvaluatesTo( + evaluate(greaterThanOrEqual(greater, less)), + true, + "gte(%s, %s)", + greater, + less + ) } } @@ -1069,11 +1188,11 @@ internal class ComparisonTests { fun gte_mixedTypeValues_returnFalse() { ComparisonTestData.mixedTypeValues.forEach { (v1, v2) -> if (v1 == nullValue() || v2 == nullValue()) { - assertEvaluatesToNull(evaluate(gte(v1, v2)), "gte(%s, %s)", v1, v2) - assertEvaluatesToNull(evaluate(gte(v2, v1)), "gte(%s, %s)", v2, v1) + assertEvaluatesToNull(evaluate(greaterThanOrEqual(v1, v2)), "gte(%s, %s)", v1, v2) + assertEvaluatesToNull(evaluate(greaterThanOrEqual(v2, v1)), "gte(%s, %s)", v2, v1) } else { - assertEvaluatesTo(evaluate(gte(v1, v2)), false, "gte(%s, %s)", v1, v2) - assertEvaluatesTo(evaluate(gte(v2, v1)), false, "gte(%s, %s)", v2, v1) + assertEvaluatesTo(evaluate(greaterThanOrEqual(v1, v2)), false, "gte(%s, %s)", v1, v2) + assertEvaluatesTo(evaluate(greaterThanOrEqual(v2, v1)), false, "gte(%s, %s)", v2, v1) } } } @@ -1082,14 +1201,29 @@ internal class ComparisonTests { fun gte_nullOperand_returnsNullOrError() { ComparisonTestData.allSupportedComparableValues.forEach { value -> val nullVal = nullValue() - assertEvaluatesToNull(evaluate(gte(nullVal, value)), "gte(%s, %s)", nullVal, value) - assertEvaluatesToNull(evaluate(gte(value, nullVal)), "gte(%s, %s)", value, nullVal) + assertEvaluatesToNull( + evaluate(greaterThanOrEqual(nullVal, value)), + "gte(%s, %s)", + nullVal, + value + ) + assertEvaluatesToNull( + evaluate(greaterThanOrEqual(value, nullVal)), + "gte(%s, %s)", + value, + nullVal + ) } val nullVal = nullValue() - assertEvaluatesToNull(evaluate(gte(nullVal, nullVal)), "gte(%s, %s)", nullVal, nullVal) + assertEvaluatesToNull( + evaluate(greaterThanOrEqual(nullVal, nullVal)), + "gte(%s, %s)", + nullVal, + nullVal + ) val missingField = field("nonexistent") assertEvaluatesToError( - evaluate(gte(nullVal, missingField)), + evaluate(greaterThanOrEqual(nullVal, missingField)), "gte(%s, %s)", nullVal, missingField @@ -1099,11 +1233,29 @@ internal class ComparisonTests { @Test fun gte_nanComparisons_returnFalse() { val nanExpr = ComparisonTestData.doubleNaN - assertEvaluatesTo(evaluate(gte(nanExpr, nanExpr)), false, "gte(%s, %s)", nanExpr, nanExpr) + assertEvaluatesTo( + evaluate(greaterThanOrEqual(nanExpr, nanExpr)), + false, + "gte(%s, %s)", + nanExpr, + nanExpr + ) ComparisonTestData.numericValuesForNanTest.forEach { numVal -> - assertEvaluatesTo(evaluate(gte(nanExpr, numVal)), false, "gte(%s, %s)", nanExpr, numVal) - assertEvaluatesTo(evaluate(gte(numVal, nanExpr)), false, "gte(%s, %s)", numVal, nanExpr) + assertEvaluatesTo( + evaluate(greaterThanOrEqual(nanExpr, numVal)), + false, + "gte(%s, %s)", + nanExpr, + numVal + ) + assertEvaluatesTo( + evaluate(greaterThanOrEqual(numVal, nanExpr)), + false, + "gte(%s, %s)", + numVal, + nanExpr + ) } (ComparisonTestData.allSupportedComparableValues - ComparisonTestData.numericValuesForNanTest.toSet() - @@ -1111,14 +1263,14 @@ internal class ComparisonTests { .forEach { otherVal -> if (otherVal != nanExpr) { assertEvaluatesTo( - evaluate(gte(nanExpr, otherVal)), + evaluate(greaterThanOrEqual(nanExpr, otherVal)), false, "gte(%s, %s)", nanExpr, otherVal ) assertEvaluatesTo( - evaluate(gte(otherVal, nanExpr)), + evaluate(greaterThanOrEqual(otherVal, nanExpr)), false, "gte(%s, %s)", otherVal, @@ -1129,7 +1281,7 @@ internal class ComparisonTests { val arrayWithNaN1 = array(constant(Double.NaN)) val arrayWithNaN2 = array(constant(Double.NaN)) assertEvaluatesTo( - evaluate(gte(arrayWithNaN1, arrayWithNaN2)), + evaluate(greaterThanOrEqual(arrayWithNaN1, arrayWithNaN2)), false, "gte(%s, %s)", arrayWithNaN1, @@ -1144,26 +1296,26 @@ internal class ComparisonTests { ComparisonTestData.allSupportedComparableValues.forEach { value -> assertEvaluatesToError( - evaluate(gte(errorExpr, value), testDoc), + evaluate(greaterThanOrEqual(errorExpr, value), testDoc), "gte(%s, %s)", errorExpr, value ) assertEvaluatesToError( - evaluate(gte(value, errorExpr), testDoc), + evaluate(greaterThanOrEqual(value, errorExpr), testDoc), "gte(%s, %s)", value, errorExpr ) } assertEvaluatesToError( - evaluate(gte(errorExpr, errorExpr), testDoc), + evaluate(greaterThanOrEqual(errorExpr, errorExpr), testDoc), "gte(%s, %s)", errorExpr, errorExpr ) assertEvaluatesToError( - evaluate(gte(errorExpr, nullValue()), testDoc), + evaluate(greaterThanOrEqual(errorExpr, nullValue()), testDoc), "gte(%s, %s)", errorExpr, nullValue() @@ -1177,13 +1329,13 @@ internal class ComparisonTests { val testDoc = doc("test/gteMissing", 0, mapOf("exists" to 10L)) assertEvaluatesToError( - evaluate(gte(missingField, presentValue), testDoc), + evaluate(greaterThanOrEqual(missingField, presentValue), testDoc), "gte(%s, %s)", missingField, presentValue ) assertEvaluatesToError( - evaluate(gte(presentValue, missingField), testDoc), + evaluate(greaterThanOrEqual(presentValue, missingField), testDoc), "gte(%s, %s)", presentValue, missingField diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComplexTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComplexTests.kt index 5ced6607be3..ca670d9c9d4 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComplexTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ComplexTests.kt @@ -20,14 +20,13 @@ import com.google.firebase.firestore.FirebaseFirestore import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil import com.google.firebase.firestore.model.MutableDocument -import com.google.firebase.firestore.pipeline.Expr.Companion.add -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.add +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.or import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -65,7 +64,7 @@ internal class ComplexTests { var pipeline = RealtimePipelineSource(db).collection(collectionId) for (i in 1..numOfFields) { - pipeline = pipeline.where(field("field_$i").gt(0L)) + pipeline = pipeline.where(field("field_$i").greaterThan(0L)) } val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -84,7 +83,7 @@ internal class ComplexTests { val values = List(maxElements) { i -> i + 1 } val pipeline = - RealtimePipelineSource(db).collection(collectionId).where(field("field_1").eqAny(values)) + RealtimePipelineSource(db).collection(collectionId).where(field("field_1").equalAny(values)) val result = runPipeline(pipeline, listOf(*allDocuments.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(documentsSource) @@ -101,7 +100,7 @@ internal class ComplexTests { val allDocuments = documentsSource + nonMatchingDoc val values = List(maxElements) { i -> i + 1 } - val conditions = (1..numOfFields).map { i -> field("field_$i").eqAny(values) } + val conditions = (1..numOfFields).map { i -> field("field_$i").equalAny(values) } val pipeline = RealtimePipelineSource(db) @@ -124,7 +123,9 @@ internal class ComplexTests { val values = List(maxElements) { i -> i + 1 } val pipeline = - RealtimePipelineSource(db).collection(collectionId).where(field("field_1").notEqAny(values)) + RealtimePipelineSource(db) + .collection(collectionId) + .where(field("field_1").notEqualAny(values)) val result = runPipeline(pipeline, listOf(*allDocuments.toTypedArray())).toList() assertThat(result).containsExactly(matchingDoc) @@ -161,7 +162,7 @@ internal class ComplexTests { val values = List(maxElements) { i -> (i + 1) } // 1 to 3000 - val conditions = (1..numOfFields).map { i -> field("field_$i").notEqAny(values) } + val conditions = (1..numOfFields).map { i -> field("field_$i").notEqualAny(values) } val pipeline = RealtimePipelineSource(db) @@ -267,14 +268,16 @@ internal class ComplexTests { // All docs have field_1 = 0L val documents = seedDatabase(numOfDocuments, numOfFields) { _, _ -> 0L } - var addExpr: Expr = field("field_1") + var addExpr: Expression = field("field_1") for (i in 1..depth) { addExpr = add(addExpr, constant(1L)) } // addExpr is field_1 + 1 (depth times) = field_1 + depth = 0 + 31 = 31 val pipeline = - RealtimePipelineSource(db).collection(collectionId).where(addExpr.gt(0L)) // 31 > 0L is true + RealtimePipelineSource(db) + .collection(collectionId) + .where(addExpr.greaterThan(0L)) // 31 > 0L is true val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(documents) @@ -297,7 +300,7 @@ internal class ComplexTests { } val maxValueInDb = (numOfDocuments - 1) * numOfFields + numOfFields // 5000L - val orConditions = (1..numOfFields).map { i -> field("field_$i").lte(maxValueInDb) } + val orConditions = (1..numOfFields).map { i -> field("field_$i").lessThanOrEqual(maxValueInDb) } val pipeline = RealtimePipelineSource(db) @@ -320,8 +323,10 @@ internal class ComplexTests { } val andConditions1 = - (1..numOfFields).map { i -> field("field_$i").gt(0L) } // Use 0L for clarity with Long types - val andConditions2 = (1..numOfFields).map { i -> field("field_$i").lt(Long.MAX_VALUE) } + (1..numOfFields).map { i -> + field("field_$i").greaterThan(0L) + } // Use 0L for clarity with Long types + val andConditions2 = (1..numOfFields).map { i -> field("field_$i").lessThan(Long.MAX_VALUE) } val pipeline = RealtimePipelineSource(db) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DebugTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DebugTests.kt index faa1c6ce867..49540b605d9 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DebugTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DebugTests.kt @@ -14,15 +14,15 @@ package com.google.firebase.firestore.pipeline -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayLength -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.exists -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.isError -import com.google.firebase.firestore.pipeline.Expr.Companion.map -import com.google.firebase.firestore.pipeline.Expr.Companion.not -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayLength +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.exists +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.isError +import com.google.firebase.firestore.pipeline.Expression.Companion.map +import com.google.firebase.firestore.pipeline.Expression.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue import com.google.firebase.firestore.testutil.TestUtil.doc import org.junit.Test import org.junit.runner.RunWith @@ -78,7 +78,7 @@ class DebugTests { @Test fun `empty map returns true for exists`() { - // Expr.map() creates an empty map expression + // Expression.map() creates an empty map expression assertEvaluatesTo(evaluate(exists(map(emptyMap()))), true, "exists({})") } diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DisjunctiveTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DisjunctiveTests.kt index afd433399f2..115267e099a 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DisjunctiveTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/DisjunctiveTests.kt @@ -17,17 +17,16 @@ package com.google.firebase.firestore.pipeline import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.isNan -import com.google.firebase.firestore.pipeline.Expr.Companion.isNull -import com.google.firebase.firestore.pipeline.Expr.Companion.not -import com.google.firebase.firestore.pipeline.Expr.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.isNan +import com.google.firebase.firestore.pipeline.Expression.Companion.isNull +import com.google.firebase.firestore.pipeline.Expression.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.or import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -52,7 +51,7 @@ internal class DisjunctiveTests { .collection("/users") .where( field("name") - .eqAny( + .equalAny( array( constant("alice"), constant("bob"), @@ -82,7 +81,7 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array( constant("alice"), constant("bob"), @@ -91,7 +90,7 @@ internal class DisjunctiveTests { constant("eric") ) ), - field("age").eqAny(array(constant(10.0), constant(25.0))) + field("age").equalAny(array(constant(10.0), constant(25.0))) ) ) @@ -113,7 +112,7 @@ internal class DisjunctiveTests { .collection("/users") .where( field("name") - .eqAny( + .equalAny( array( constant("alice"), constant("bob"), @@ -123,7 +122,7 @@ internal class DisjunctiveTests { ) ) ) - .where(field("age").eqAny(array(constant(10.0), constant(25.0)))) + .where(field("age").equalAny(array(constant(10.0), constant(25.0)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc4, doc5)) @@ -143,8 +142,8 @@ internal class DisjunctiveTests { .collection("/users") .where( or( - field("name").eqAny(array(constant("alice"), constant("bob"))), - field("age").eqAny(array(constant(10.0), constant(25.0))) + field("name").equalAny(array(constant("alice"), constant("bob"))), + field("age").equalAny(array(constant(10.0), constant(25.0))) ) ) @@ -166,7 +165,9 @@ internal class DisjunctiveTests { .collectionGroup("users") .where( field("name") - .eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric"))) + .equalAny( + array(constant("alice"), constant("bob"), constant("diane"), constant("eric")) + ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -187,7 +188,9 @@ internal class DisjunctiveTests { .collection("/users") .where( field("name") - .eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric"))) + .equalAny( + array(constant("alice"), constant("bob"), constant("diane"), constant("eric")) + ) ) .sort(field("age").ascending()) @@ -209,7 +212,9 @@ internal class DisjunctiveTests { .collection("/users") .where( field("name") - .eqAny(array(constant("alice"), constant("bob"), constant("diane"), constant("eric"))) + .equalAny( + array(constant("alice"), constant("bob"), constant("diane"), constant("eric")) + ) ) .sort(field("name").ascending()) @@ -232,7 +237,7 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array( constant("alice"), constant("bob"), @@ -241,7 +246,7 @@ internal class DisjunctiveTests { constant("eric") ) ), - field("age").eq(constant(10.0)) + field("age").equal(constant(10.0)) ) ) .sort(field("name").ascending()) @@ -264,8 +269,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").eqAny(array(constant("alice"), constant("diane"), constant("eric"))), - field("name").eq(constant("eric")) + field("name").equalAny(array(constant("alice"), constant("diane"), constant("eric"))), + field("name").equal(constant("eric")) ) ) @@ -285,8 +290,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").eqAny(array(constant("alice"), constant("bob"))), - field("name").eq(constant("other")) + field("name").equalAny(array(constant("alice"), constant("bob"))), + field("name").equal(constant("other")) ) ) @@ -309,11 +314,11 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array(constant("alice"), constant("bob"), constant("charlie"), constant("diane")) ), - field("age").gt(constant(10.0)), - field("age").lt(constant(100.0)) + field("age").greaterThan(constant(10.0)), + field("age").lessThan(constant(100.0)) ) ) @@ -336,11 +341,11 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array(constant("alice"), constant("bob"), constant("charlie"), constant("diane")) ), - field("age").gte(constant(10.0)), - field("age").lte(constant(100.0)) + field("age").greaterThanOrEqual(constant(10.0)), + field("age").lessThanOrEqual(constant(100.0)) ) ) @@ -363,11 +368,11 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array(constant("alice"), constant("bob"), constant("charlie"), constant("diane")) ), - field("age").gt(constant(10.0)), - field("age").lt(constant(100.0)) + field("age").greaterThan(constant(10.0)), + field("age").lessThan(constant(100.0)) ) ) .sort(field("age").ascending()) @@ -391,10 +396,10 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array(constant("alice"), constant("bob"), constant("charlie"), constant("diane")) ), - field("age").neq(constant(100.0)) + field("age").notEqual(constant(100.0)) ) ) @@ -416,7 +421,7 @@ internal class DisjunctiveTests { .collection("/users") .where( field("name") - .eqAny( + .equalAny( array(constant("alice"), constant("bob"), constant("charlie"), constant("diane")) ) ) @@ -436,7 +441,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("age").eqAny(array(constant(10.0)))) + .where(field("age").equalAny(array(constant(10.0)))) .sort(field("age").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -459,7 +464,7 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array( constant("alice"), constant("bob"), @@ -468,7 +473,7 @@ internal class DisjunctiveTests { constant("eric") ) ), - field("age").eq(constant(10.0)) + field("age").equal(constant(10.0)) ) ) .sort(field("name").ascending()) @@ -492,7 +497,7 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array( constant("alice"), constant("bob"), @@ -501,7 +506,7 @@ internal class DisjunctiveTests { constant("eric") ) ), - field("age").eq(constant(10.0)) + field("age").equal(constant(10.0)) ) ) .sort(field("age").ascending()) @@ -524,8 +529,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("age").eqAny(array(constant(10.0), constant(25.0), constant(100.0))), - field("age").gt(constant(20.0)) + field("age").equalAny(array(constant(10.0), constant(25.0), constant(100.0))), + field("age").greaterThan(constant(20.0)) ) ) @@ -548,10 +553,10 @@ internal class DisjunctiveTests { .where( and( field("name") - .eqAny( + .equalAny( array(constant("alice"), constant("bob"), constant("charlie"), constant("diane")) ), - field("age").gt(constant(20.0)) + field("age").greaterThan(constant(20.0)) ) ) .sort(field("age").ascending()) // C++ test sorts by age (inequality field) @@ -570,7 +575,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("name").eqAny(array(Expr.nullValue(), constant("alice")))) + .where(field("name").equalAny(array(Expression.nullValue(), constant("alice")))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) // Nulls are not matched by IN @@ -587,7 +592,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(Expr.arrayContains(field("field"), Expr.nullValue())) + .where(Expression.arrayContains(field("field"), Expression.nullValue())) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() // arrayContains does not match null @@ -604,7 +609,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("field").arrayContainsAny(array(Expr.nullValue(), constant("foo")))) + .where(field("field").arrayContainsAny(array(Expression.nullValue(), constant("foo")))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) // arrayContainsAny does not match null @@ -620,7 +625,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("age").eqAny(array(Expr.nullValue()))) + .where(field("age").equalAny(array(Expression.nullValue()))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() // Nulls are not matched by IN @@ -716,7 +721,7 @@ internal class DisjunctiveTests { .where( and( field("groups").arrayContainsAny(array(constant(1L), constant(5L))), - field("groups").lt(array(constant(3L), constant(4L), constant(5L))) + field("groups").lessThan(array(constant(3L), constant(4L), constant(5L))) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -738,7 +743,7 @@ internal class DisjunctiveTests { .where( and( field("groups").arrayContainsAny(array(constant(1L), constant(5L))), - field("name").eqAny(array(constant("alice"), constant("bob"))) + field("name").equalAny(array(constant("alice"), constant("bob"))) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -756,7 +761,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("name").eq(constant("bob")), field("age").eq(constant(10.0)))) + .where(or(field("name").equal(constant("bob")), field("age").equal(constant(10.0)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc4)) @@ -775,10 +780,10 @@ internal class DisjunctiveTests { .collection("/users") .where( or( - field("name").eq(constant("bob")), - field("name").eq(constant("diane")), - field("age").eq(constant(25.0)), - field("age").eq(constant(100.0)) + field("name").equal(constant("bob")), + field("name").equal(constant("diane")), + field("age").equal(constant(25.0)), + field("age").equal(constant(100.0)) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -796,8 +801,8 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("name").eq(constant("bob")), field("age").eq(constant(10.0)))) - .where(or(field("name").eq(constant("diane")), field("age").eq(constant(100.0)))) + .where(or(field("name").equal(constant("bob")), field("age").equal(constant(10.0)))) + .where(or(field("name").equal(constant("diane")), field("age").equal(constant(100.0)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc4) // (name=bob OR age=10) AND (name=diane OR age=100) @@ -816,8 +821,8 @@ internal class DisjunctiveTests { .collection("/users") .where( or( - and(field("name").eq(constant("bob")), field("age").eq(constant(25.0))), - and(field("name").eq(constant("diane")), field("age").eq(constant(10.0))) + and(field("name").equal(constant("bob")), field("age").equal(constant(25.0))), + and(field("name").equal(constant("diane")), field("age").equal(constant(10.0))) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -837,8 +842,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - or(field("name").eq(constant("bob")), field("age").eq(constant(10.0))), - field("age").lt(constant(80.0)) + or(field("name").equal(constant("bob")), field("age").equal(constant(10.0))), + field("age").lessThan(constant(80.0)) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -858,8 +863,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - or(field("name").eq(constant("bob")), field("age").eq(constant(10.0))), - or(field("name").eq(constant("diane")), field("age").eq(constant(100.0))) + or(field("name").equal(constant("bob")), field("age").equal(constant(10.0))), + or(field("name").equal(constant("diane")), field("age").equal(constant(100.0))) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -879,8 +884,8 @@ internal class DisjunctiveTests { .collection("/users") .where( or( - or(field("name").eq(constant("bob")), field("age").eq(constant(10.0))), - or(field("name").eq(constant("diane")), field("age").eq(constant(100.0))) + or(field("name").equal(constant("bob")), field("age").equal(constant(10.0))), + or(field("name").equal(constant("diane")), field("age").equal(constant(100.0))) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -900,8 +905,8 @@ internal class DisjunctiveTests { .collection("/users") .where( or( - field("name").eq(constant("bob")), - and(field("age").eq(constant(10.0)), field("age").gt(constant(20.0))) + field("name").equal(constant("bob")), + and(field("age").equal(constant(10.0)), field("age").greaterThan(constant(20.0))) ) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -919,7 +924,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("name").eq(constant("diane")), field("age").gt(constant(20.0)))) + .where(or(field("name").equal(constant("diane")), field("age").greaterThan(constant(20.0)))) .sort(field("age").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -937,7 +942,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("age").lt(constant(20.0)), field("age").gt(constant(50.0)))) + .where(or(field("age").lessThan(constant(20.0)), field("age").greaterThan(constant(50.0)))) .sort(field("age").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -955,7 +960,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("age").lt(constant(20.0)), field("age").gt(constant(50.0)))) + .where(or(field("age").lessThan(constant(20.0)), field("age").greaterThan(constant(50.0)))) .sort(field("name").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -979,7 +984,9 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("age").lt(constant(80.0)), field("height").gt(constant(160.0)))) + .where( + or(field("age").lessThan(constant(80.0)), field("height").greaterThan(constant(160.0))) + ) .sort(field("age").ascending(), field("height").descending(), field("name").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -997,7 +1004,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("name").eq(constant("diane")), field("age").gt(constant(20.0)))) + .where(or(field("name").equal(constant("diane")), field("age").greaterThan(constant(20.0)))) .sort(field("age").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -1015,7 +1022,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("name").eq(constant("diane")), field("age").gt(constant(20.0)))) + .where(or(field("name").equal(constant("diane")), field("age").greaterThan(constant(20.0)))) .sort(field("age").ascending()) .limit(2) @@ -1036,7 +1043,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("a").eq(constant(1L)), isNull(field("a")))) + .where(or(field("a").equal(constant(1L)), isNull(field("a")))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() // C++ test expects 1.0 to match 1L in this context. @@ -1057,7 +1064,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("b").eq(constant(1L)), isNull(field("a")))) + .where(or(field("b").equal(constant(1L)), isNull(field("a")))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc3, doc4)) @@ -1076,7 +1083,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("a").gt(constant(1L)), not(isNull(field("a"))))) + .where(or(field("a").greaterThan(constant(1L)), not(isNull(field("a"))))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() // a > 1L (none) OR a IS NOT NULL (doc1, doc2, doc3, doc5) @@ -1096,7 +1103,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(or(field("b").eq(constant(1L)), not(isNull(field("a"))))) + .where(or(field("b").equal(constant(1L)), not(isNull(field("a"))))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() // b == 1L (doc3) OR a IS NOT NULL (doc1, doc2, doc3, doc5) @@ -1150,7 +1157,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("name").notEqAny(array(constant("alice"), constant("bob")))) + .where(field("name").notEqualAny(array(constant("alice"), constant("bob")))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc3, doc4, doc5)) @@ -1170,8 +1177,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("bob"))), - field("age").notEqAny(array(constant(10.0), constant(25.0))) + field("name").notEqualAny(array(constant("alice"), constant("bob"))), + field("age").notEqualAny(array(constant(10.0), constant(25.0))) ) ) @@ -1193,8 +1200,8 @@ internal class DisjunctiveTests { .collection("/users") .where( or( - field("name").notEqAny(array(constant("alice"), constant("bob"))), - field("age").notEqAny(array(constant(10.0), constant(25.0))) + field("name").notEqualAny(array(constant("alice"), constant("bob"))), + field("age").notEqualAny(array(constant(10.0), constant(25.0))) ) ) @@ -1214,7 +1221,9 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collectionGroup("users") - .where(field("name").notEqAny(array(constant("alice"), constant("bob"), constant("diane")))) + .where( + field("name").notEqualAny(array(constant("alice"), constant("bob"), constant("diane"))) + ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -1232,7 +1241,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("name").notEqAny(array(constant("alice"), constant("diane")))) + .where(field("name").notEqualAny(array(constant("alice"), constant("diane")))) .sort(field("age").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -1253,8 +1262,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("bob"))), - field("age").eq(constant(10.0)) + field("name").notEqualAny(array(constant("alice"), constant("bob"))), + field("age").equal(constant(10.0)) ) ) @@ -1276,8 +1285,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("diane"))), - field("name").eq(constant("eric")) + field("name").notEqualAny(array(constant("alice"), constant("diane"))), + field("name").equal(constant("eric")) ) ) @@ -1299,9 +1308,9 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("charlie"))), - field("age").gt(constant(10.0)), - field("age").lt(constant(100.0)) + field("name").notEqualAny(array(constant("alice"), constant("charlie"))), + field("age").greaterThan(constant(10.0)), + field("age").lessThan(constant(100.0)) ) ) @@ -1323,9 +1332,9 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("bob"), constant("eric"))), - field("age").gte(constant(10.0)), - field("age").lte(constant(100.0)) + field("name").notEqualAny(array(constant("alice"), constant("bob"), constant("eric"))), + field("age").greaterThanOrEqual(constant(10.0)), + field("age").lessThanOrEqual(constant(100.0)) ) ) @@ -1347,9 +1356,9 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("diane"))), - field("age").gt(constant(10.0)), - field("age").lte(constant(100.0)) + field("name").notEqualAny(array(constant("alice"), constant("diane"))), + field("age").greaterThan(constant(10.0)), + field("age").lessThanOrEqual(constant(100.0)) ) ) .sort(field("age").ascending()) @@ -1372,8 +1381,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("bob"))), - field("age").neq(constant(100.0)) + field("name").notEqualAny(array(constant("alice"), constant("bob"))), + field("age").notEqual(constant(100.0)) ) ) @@ -1393,7 +1402,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("name").notEqAny(array(constant("alice"), constant("bob")))) + .where(field("name").notEqualAny(array(constant("alice"), constant("bob")))) .sort(field("name").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -1410,7 +1419,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("age").notEqAny(array(constant(100.0)))) + .where(field("age").notEqualAny(array(constant(100.0)))) .sort(field("age").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -1431,8 +1440,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("bob"))), - field("age").eq(constant(10.0)) + field("name").notEqualAny(array(constant("alice"), constant("bob"))), + field("age").equal(constant(10.0)) ) ) .sort(field("name").ascending()) @@ -1455,8 +1464,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("bob"))), - field("age").eq(constant(10.0)) + field("name").notEqualAny(array(constant("alice"), constant("bob"))), + field("age").equal(constant(10.0)) ) ) .sort(field("age").ascending()) @@ -1479,8 +1488,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("age").notEqAny(array(constant(10.0), constant(100.0))), - field("age").gt(constant(20.0)) + field("age").notEqualAny(array(constant(10.0), constant(100.0))), + field("age").greaterThan(constant(20.0)) ) ) .sort(field("age").ascending()) @@ -1503,8 +1512,8 @@ internal class DisjunctiveTests { .collection("/users") .where( and( - field("name").notEqAny(array(constant("alice"), constant("diane"))), - field("age").gt(constant(20.0)) + field("name").notEqualAny(array(constant("alice"), constant("diane"))), + field("age").greaterThan(constant(20.0)) ) ) .sort(field("age").ascending()) // C++ test sorts by age (inequality field) @@ -1527,18 +1536,18 @@ internal class DisjunctiveTests { .collection("/users") .where( or( - field("name").eq(constant("alice")), - field("name").eq(constant("bob")), - field("name").eq(constant("charlie")), - field("name").eq(constant("diane")), - field("age").eq(constant(10.0)), - field("age").eq(constant(25.0)), - field("age").eq(constant(40.0)), // No doc matches this - field("age").eq(constant(100.0)), - field("height").eq(constant(150.0)), - field("height").eq(constant(160.0)), // No doc matches this - field("height").eq(constant(170.0)), - field("height").eq(constant(180.0)) + field("name").equal(constant("alice")), + field("name").equal(constant("bob")), + field("name").equal(constant("charlie")), + field("name").equal(constant("diane")), + field("age").equal(constant(10.0)), + field("age").equal(constant(25.0)), + field("age").equal(constant(40.0)), // No doc matches this + field("age").equal(constant(100.0)), + field("height").equal(constant(150.0)), + field("height").equal(constant(160.0)), // No doc matches this + field("height").equal(constant(170.0)), + field("height").equal(constant(180.0)) ) ) @@ -1557,7 +1566,7 @@ internal class DisjunctiveTests { RealtimePipelineSource(db) .collection("/users") .where( - field("score").eqAny(array(constant(50L), constant(97L), constant(97L), constant(97L))) + field("score").equalAny(array(constant(50L), constant(97L), constant(97L), constant(97L))) ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -1574,7 +1583,7 @@ internal class DisjunctiveTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("score").notEqAny(array(constant(50L), constant(50L)))) + .where(field("score").notEqualAny(array(constant(50L), constant(50L)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3)) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ErrorHandlingTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ErrorHandlingTests.kt index bc2cb16ef2e..1951230f10e 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ErrorHandlingTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/ErrorHandlingTests.kt @@ -17,16 +17,15 @@ package com.google.firebase.firestore.pipeline import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.divide -import com.google.firebase.firestore.pipeline.Expr.Companion.eq -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.or -import com.google.firebase.firestore.pipeline.Expr.Companion.xor +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.divide +import com.google.firebase.firestore.pipeline.Expression.Companion.equal +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.xor import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -52,9 +51,9 @@ internal class ErrorHandlingTests { .collection("k") .where( or( - eq(field("a"), constant(true)), - eq(field("b"), constant(true)), - eq(field("c"), constant(true)) + equal(field("a"), constant(true)), + equal(field("b"), constant(true)), + equal(field("c"), constant(true)) ) ) @@ -82,9 +81,9 @@ internal class ErrorHandlingTests { .collection("k") .where( and( - eq(field("a"), constant(true)), - eq(field("b"), constant(true)), - eq(field("c"), constant(true)) + equal(field("a"), constant(true)), + equal(field("b"), constant(true)), + equal(field("c"), constant(true)) ) ) @@ -110,9 +109,9 @@ internal class ErrorHandlingTests { .collection("k") .where( xor( - eq(field("a"), constant(true)), - eq(field("b"), constant(true)), - eq(field("c"), constant(true)) + equal(field("a"), constant(true)), + equal(field("b"), constant(true)), + equal(field("c"), constant(true)) ) ) @@ -138,7 +137,8 @@ internal class ErrorHandlingTests { // This test case in C++ was adjusted to match a TS behavior, // resulting in a condition `field("a") == false`. - val pipeline = RealtimePipelineSource(db).collection("k").where(eq(field("a"), constant(false))) + val pipeline = + RealtimePipelineSource(db).collection("k").where(equal(field("a"), constant(false))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() // Only doc1 has a == false. @@ -155,7 +155,7 @@ internal class ErrorHandlingTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(divide(constant("100"), constant("50")), constant(2L))) + .where(equal(divide(constant("100"), constant("50")), constant(2L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() // Division of string constants should cause an evaluation error, diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/FieldTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/FieldTests.kt index 7eb0a5d965c..09aceb56e54 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/FieldTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/FieldTests.kt @@ -25,7 +25,7 @@ class FieldTests { @Test fun `can get field`() { val docWithField = doc("coll/doc1", 1, mapOf("exists" to true)) - val fieldExpr = Expr.field("exists") + val fieldExpr = Expression.field("exists") val result = evaluate(fieldExpr, docWithField) // Using evaluate from pipeline.testUtil assertEvaluatesTo(result, true, "Expected field 'exists' to evaluate to true") } @@ -33,7 +33,7 @@ class FieldTests { @Test fun `returns unset if not found`() { val doc = doc("coll/doc1", 1, emptyMap()) - val fieldExpr = Expr.field("not-exists") + val fieldExpr = Expression.field("not-exists") val result = evaluate(fieldExpr, doc) // Using evaluate from pipeline.testUtil assertEvaluatesToUnset(result, "Expected non-existent field to evaluate to UNSET") } diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/InequalityTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/InequalityTests.kt index 2759129d182..1d716e8a8a2 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/InequalityTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/InequalityTests.kt @@ -19,14 +19,13 @@ import com.google.firebase.Timestamp import com.google.firebase.firestore.GeoPoint import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.not -import com.google.firebase.firestore.pipeline.Expr.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.or import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -44,7 +43,8 @@ internal class InequalityTests { val doc3 = doc("users/charlie", 1000, mapOf("score" to 97L)) val documents = listOf(doc1, doc2, doc3) - val pipeline = RealtimePipelineSource(db).collection("users").where(field("score").gt(90L)) + val pipeline = + RealtimePipelineSource(db).collection("users").where(field("score").greaterThan(90L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -57,7 +57,8 @@ internal class InequalityTests { val doc3 = doc("users/charlie", 1000, mapOf("score" to 97L)) val documents = listOf(doc1, doc2, doc3) - val pipeline = RealtimePipelineSource(db).collection("users").where(field("score").gte(90L)) + val pipeline = + RealtimePipelineSource(db).collection("users").where(field("score").greaterThanOrEqual(90L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3)) @@ -70,7 +71,8 @@ internal class InequalityTests { val doc3 = doc("users/charlie", 1000, mapOf("score" to 97L)) val documents = listOf(doc1, doc2, doc3) - val pipeline = RealtimePipelineSource(db).collection("users").where(field("score").lt(90L)) + val pipeline = + RealtimePipelineSource(db).collection("users").where(field("score").lessThan(90L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc2) @@ -83,7 +85,8 @@ internal class InequalityTests { val doc3 = doc("users/charlie", 1000, mapOf("score" to 97L)) val documents = listOf(doc1, doc2, doc3) - val pipeline = RealtimePipelineSource(db).collection("users").where(field("score").lte(90L)) + val pipeline = + RealtimePipelineSource(db).collection("users").where(field("score").lessThanOrEqual(90L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc2)) @@ -96,7 +99,8 @@ internal class InequalityTests { val doc3 = doc("users/charlie", 1000, mapOf("score" to 97L)) val documents = listOf(doc1, doc2, doc3) - val pipeline = RealtimePipelineSource(db).collection("users").where(field("score").neq(90L)) + val pipeline = + RealtimePipelineSource(db).collection("users").where(field("score").notEqual(90L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc3)) @@ -114,7 +118,8 @@ internal class InequalityTests { val doc8 = doc("users/hope", 1000, mapOf("score" to mapOf("foo" to 42L))) val documents = listOf(doc1, doc2, doc3, doc4, doc5, doc6, doc7, doc8) - val pipeline = RealtimePipelineSource(db).collection("users").where(field("score").neq(90L)) + val pipeline = + RealtimePipelineSource(db).collection("users").where(field("score").notEqual(90L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc3, doc4, doc5, doc6, doc7, doc8)) @@ -132,7 +137,8 @@ internal class InequalityTests { val doc8 = doc("users/hope", 1000, mapOf("score" to mapOf("foo" to 42L))) val documents = listOf(doc1, doc2, doc3, doc4, doc5, doc6, doc7, doc8) - val pipeline = RealtimePipelineSource(db).collection("users").where(field("score").gt(42L)) + val pipeline = + RealtimePipelineSource(db).collection("users").where(field("score").greaterThan(42L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc2) @@ -153,7 +159,8 @@ internal class InequalityTests { doc("users/hope", 1000, mapOf("score" to mapOf("foo" to 42L))) // !(M > 90) -> !F -> T val documents = listOf(doc1, doc2, doc3, doc4, doc5, doc6, doc7, doc8) - val pipeline = RealtimePipelineSource(db).collection("users").where(not(field("score").gt(90L))) + val pipeline = + RealtimePipelineSource(db).collection("users").where(not(field("score").greaterThan(90L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3, doc4, doc5, doc6, doc7, doc8)) @@ -170,7 +177,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").eq(2L), field("score").gt(80L))) + .where(and(field("rank").equal(2L), field("score").greaterThan(80L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -186,7 +193,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").eq(90L), field("score").gt(80L))) + .where(and(field("score").equal(90L), field("score").greaterThan(80L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -202,7 +209,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("score").gte(90L)) + .where(field("score").greaterThanOrEqual(90L)) .sort(field("score").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -219,7 +226,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("score").gte(90L)) + .where(field("score").greaterThanOrEqual(90L)) .sort(field("rank").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -236,7 +243,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(or(field("score").gt(90L), field("score").lt(60L))) + .where(or(field("score").greaterThan(90L), field("score").lessThan(60L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc3)) @@ -258,7 +265,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(or(field("score").gt(80L), field("rank").lt(2L))) + .where(or(field("score").greaterThan(80L), field("rank").lessThan(2L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3)) @@ -279,7 +286,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").gt(80L), field("score").eqAny(listOf(50L, 80L, 97L)))) + .where(and(field("score").greaterThan(80L), field("score").equalAny(listOf(50L, 80L, 97L)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -305,7 +312,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").lt(3L), field("score").eqAny(listOf(50L, 80L, 97L)))) + .where(and(field("rank").lessThan(3L), field("score").equalAny(listOf(50L, 80L, 97L)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -324,7 +331,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").gt(80L), field("score").notEqAny(listOf(90L, 95L)))) + .where(and(field("score").greaterThan(80L), field("score").notEqualAny(listOf(90L, 95L)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc4) @@ -347,7 +354,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("score").notEqAny(listOf("foo", 90L, false))) + .where(field("score").notEqualAny(listOf("foo", 90L, false))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result) @@ -370,7 +377,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").lt(3L), field("score").notEqAny(listOf(90L, 95L)))) + .where(and(field("rank").lessThan(3L), field("score").notEqualAny(listOf(90L, 95L)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -389,7 +396,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").eq(2L), field("score").gt(80L))) + .where(and(field("rank").equal(2L), field("score").greaterThan(80L))) .sort(field("rank").ascending(), field("score").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -418,7 +425,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").eqAny(listOf(2L, 3L, 4L)), field("score").gt(80L))) + .where(and(field("rank").equalAny(listOf(2L, 3L, 4L)), field("score").greaterThan(80L))) .sort(field("rank").ascending(), field("score").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -450,7 +457,12 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("scores").lte(array(90L, 90L, 90L)), field("rounds").gt(array(1L, 2L)))) + .where( + and( + field("scores").lessThanOrEqual(array(90L, 90L, 90L)), + field("rounds").greaterThan(array(1L, 2L)) + ) + ) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -483,7 +495,7 @@ internal class InequalityTests { .collection("users") .where( and( - field("scores").lte(array(90L, 90L, 90L)), + field("scores").lessThanOrEqual(array(90L, 90L, 90L)), field("rounds").arrayContains(3L) // C++ used ArrayContainsExpr ) ) @@ -505,7 +517,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("score").gt(80L)) + .where(field("score").greaterThan(80L)) .sort(field("rank").ascending()) .limit(2) @@ -523,7 +535,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").gt(90L), field("score").lt(100L))) + .where(and(field("score").greaterThan(90L), field("score").lessThan(100L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -544,7 +556,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").gt(90L), field("rank").lt(2L))) + .where(and(field("score").greaterThan(90L), field("rank").lessThan(2L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -566,7 +578,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").gt(80L), field("rank").lt(3L))) + .where(and(field("score").greaterThan(80L), field("rank").lessThan(3L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3)) @@ -589,7 +601,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").gt(40L), field("rank").lt(4L))) + .where(and(field("score").greaterThan(40L), field("rank").lessThan(4L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc2, doc3)) @@ -605,7 +617,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("score").lt(90L), field("rank").gt(3L))) + .where(and(field("score").lessThan(90L), field("rank").greaterThan(3L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -629,10 +641,10 @@ internal class InequalityTests { .collection("users") .where( and( - field("rank").gt(0L), - field("rank").lt(4L), - field("score").gt(80L), - field("score").lt(95L) + field("rank").greaterThan(0L), + field("rank").lessThan(4L), + field("score").greaterThan(80L), + field("score").lessThan(95L) ) ) @@ -650,7 +662,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").lt(3L), field("score").gt(80L))) + .where(and(field("rank").lessThan(3L), field("score").greaterThan(80L))) .sort(field("rank").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -667,7 +679,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").lt(3L), field("score").gt(80L))) + .where(and(field("rank").lessThan(3L), field("score").greaterThan(80L))) .sort(field("rank").descending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -684,7 +696,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").lt(3L), field("score").gt(80L))) + .where(and(field("rank").lessThan(3L), field("score").greaterThan(80L))) .sort(field("rank").ascending(), field("score").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -701,7 +713,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").lt(3L), field("score").gt(80L))) + .where(and(field("rank").lessThan(3L), field("score").greaterThan(80L))) .sort(field("rank").descending(), field("score").descending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -718,7 +730,7 @@ internal class InequalityTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(field("rank").lt(3L), field("score").gt(80L))) + .where(and(field("rank").lessThan(3L), field("score").greaterThan(80L))) .sort(field("score").descending(), field("rank").descending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/LogicalTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/LogicalTests.kt index 5fb4a1d6e03..dffd5eaa5f6 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/LogicalTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/LogicalTests.kt @@ -15,25 +15,25 @@ package com.google.firebase.firestore.pipeline import com.google.firebase.firestore.model.Values.encodeValue -import com.google.firebase.firestore.pipeline.Expr.Companion.add -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.cond -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.eqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.isNan -import com.google.firebase.firestore.pipeline.Expr.Companion.isNotNan -import com.google.firebase.firestore.pipeline.Expr.Companion.isNotNull -import com.google.firebase.firestore.pipeline.Expr.Companion.isNull -import com.google.firebase.firestore.pipeline.Expr.Companion.logicalMaximum -import com.google.firebase.firestore.pipeline.Expr.Companion.logicalMinimum -import com.google.firebase.firestore.pipeline.Expr.Companion.map -import com.google.firebase.firestore.pipeline.Expr.Companion.not -import com.google.firebase.firestore.pipeline.Expr.Companion.notEqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue -import com.google.firebase.firestore.pipeline.Expr.Companion.or -import com.google.firebase.firestore.pipeline.Expr.Companion.xor +import com.google.firebase.firestore.pipeline.Expression.Companion.add +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.conditional +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.equalAny +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.isNan +import com.google.firebase.firestore.pipeline.Expression.Companion.isNotNan +import com.google.firebase.firestore.pipeline.Expression.Companion.isNotNull +import com.google.firebase.firestore.pipeline.Expression.Companion.isNull +import com.google.firebase.firestore.pipeline.Expression.Companion.logicalMaximum +import com.google.firebase.firestore.pipeline.Expression.Companion.logicalMinimum +import com.google.firebase.firestore.pipeline.Expression.Companion.map +import com.google.firebase.firestore.pipeline.Expression.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqualAny +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue +import com.google.firebase.firestore.pipeline.Expression.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.xor import com.google.firebase.firestore.testutil.TestUtilKtx.doc import org.junit.Test import org.junit.runner.RunWith @@ -46,7 +46,7 @@ class LogicalTests { private val falseExpr = constant(false) private val nullExpr = nullValue() // Changed private val nanExpr = constant(Double.NaN) - private val errorExpr = field("error.field").eq(constant("random")) + private val errorExpr = field("error.field").equal(constant("random")) // Corrected document creation using doc() from TestUtilKtx private val testDocWithNan = @@ -292,33 +292,33 @@ class LogicalTests { // --- Cond (? :) Tests --- @Test fun `cond - true condition returns true case`() { - val expr = cond(trueExpr, constant("true case"), errorExpr) + val expr = conditional(trueExpr, constant("true case"), errorExpr) val result = evaluate(expr, emptyDoc) assertEvaluatesTo(result, encodeValue("true case"), "cond(true, 'true case', error)") } @Test fun `cond - false condition returns false case`() { - val expr = cond(falseExpr, errorExpr, constant("false case")) + val expr = conditional(falseExpr, errorExpr, constant("false case")) val result = evaluate(expr, emptyDoc) assertEvaluatesTo(result, encodeValue("false case"), "cond(false, error, 'false case')") } @Test fun `cond - error condition returns error`() { - val expr = cond(errorExpr, constant("true case"), constant("false case")) + val expr = conditional(errorExpr, constant("true case"), constant("false case")) assertEvaluatesToError(evaluate(expr, errorDoc), "Cond with error condition") } @Test fun `cond - true condition but true case is error returns error`() { - val expr = cond(trueExpr, errorExpr, constant("false case")) + val expr = conditional(trueExpr, errorExpr, constant("false case")) assertEvaluatesToError(evaluate(expr, errorDoc), "Cond with error true-case") } @Test fun `cond - false condition but false case is error returns error`() { - val expr = cond(falseExpr, constant("true case"), errorExpr) + val expr = conditional(falseExpr, constant("true case"), errorExpr) assertEvaluatesToError(evaluate(expr, errorDoc), "Cond with error false-case") } @@ -571,7 +571,7 @@ class LogicalTests { @Test fun `not - error is error`() { - val expr = not(errorExpr as BooleanExpr) // Changed + val expr = not(errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "NOT(error)") } @@ -585,7 +585,7 @@ class LogicalTests { @Test fun `xor - false, error is error`() { - val expr = xor(falseExpr, errorExpr as BooleanExpr) // Changed + val expr = xor(falseExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(F,E)") } @@ -597,19 +597,19 @@ class LogicalTests { @Test fun `xor - error, false is error`() { - val expr = xor(errorExpr as BooleanExpr, falseExpr) // Changed + val expr = xor(errorExpr as BooleanExpression, falseExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,F)") } @Test fun `xor - error, error is error`() { - val expr = xor(errorExpr as BooleanExpr, errorExpr as BooleanExpr) // Changed + val expr = xor(errorExpr as BooleanExpression, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,E)") } @Test fun `xor - error, true is error`() { - val expr = xor(errorExpr as BooleanExpr, trueExpr) // Changed + val expr = xor(errorExpr as BooleanExpression, trueExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,T)") } @@ -621,7 +621,7 @@ class LogicalTests { @Test fun `xor - true, error is error`() { - val expr = xor(trueExpr, errorExpr as BooleanExpr) // Changed + val expr = xor(trueExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(T,E)") } @@ -640,7 +640,7 @@ class LogicalTests { @Test fun `xor - false, false, error is error`() { - val expr = xor(falseExpr, falseExpr, errorExpr as BooleanExpr) // Changed + val expr = xor(falseExpr, falseExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(F,F,E)") } @@ -652,19 +652,20 @@ class LogicalTests { @Test fun `xor - false, error, false is error`() { - val expr = xor(falseExpr, errorExpr as BooleanExpr, falseExpr) // Changed + val expr = xor(falseExpr, errorExpr as BooleanExpression, falseExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(F,E,F)") } @Test fun `xor - false, error, error is error`() { - val expr = xor(falseExpr, errorExpr as BooleanExpr, errorExpr as BooleanExpr) // Changed + val expr = + xor(falseExpr, errorExpr as BooleanExpression, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(F,E,E)") } @Test fun `xor - false, error, true is error`() { - val expr = xor(falseExpr, errorExpr as BooleanExpr, trueExpr) // Changed + val expr = xor(falseExpr, errorExpr as BooleanExpression, trueExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(F,E,T)") } @@ -676,7 +677,7 @@ class LogicalTests { @Test fun `xor - false, true, error is error`() { - val expr = xor(falseExpr, trueExpr, errorExpr as BooleanExpr) // Changed + val expr = xor(falseExpr, trueExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(F,T,E)") } @@ -688,56 +689,64 @@ class LogicalTests { @Test fun `xor - error, false, false is error`() { - val expr = xor(errorExpr as BooleanExpr, falseExpr, falseExpr) // Changed + val expr = xor(errorExpr as BooleanExpression, falseExpr, falseExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,F,F)") } @Test fun `xor - error, false, error is error`() { - val expr = xor(errorExpr as BooleanExpr, falseExpr, errorExpr as BooleanExpr) // Changed + val expr = + xor(errorExpr as BooleanExpression, falseExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,F,E)") } @Test fun `xor - error, false, true is error`() { - val expr = xor(errorExpr as BooleanExpr, falseExpr, trueExpr) // Changed + val expr = xor(errorExpr as BooleanExpression, falseExpr, trueExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,F,T)") } @Test fun `xor - error, error, false is error`() { - val expr = xor(errorExpr as BooleanExpr, errorExpr as BooleanExpr, falseExpr) // Changed + val expr = + xor(errorExpr as BooleanExpression, errorExpr as BooleanExpression, falseExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,E,F)") } @Test fun `xor - error, error, error is error`() { val expr = - xor(errorExpr as BooleanExpr, errorExpr as BooleanExpr, errorExpr as BooleanExpr) // Changed + xor( + errorExpr as BooleanExpression, + errorExpr as BooleanExpression, + errorExpr as BooleanExpression + ) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,E,E)") } @Test fun `xor - error, error, true is error`() { - val expr = xor(errorExpr as BooleanExpr, errorExpr as BooleanExpr, trueExpr) // Changed + val expr = + xor(errorExpr as BooleanExpression, errorExpr as BooleanExpression, trueExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,E,T)") } @Test fun `xor - error, true, false is error`() { - val expr = xor(errorExpr as BooleanExpr, trueExpr, falseExpr) // Changed + val expr = xor(errorExpr as BooleanExpression, trueExpr, falseExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,T,F)") } @Test fun `xor - error, true, error is error`() { - val expr = xor(errorExpr as BooleanExpr, trueExpr, errorExpr as BooleanExpr) // Changed + val expr = + xor(errorExpr as BooleanExpression, trueExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,T,E)") } @Test fun `xor - error, true, true is error`() { - val expr = xor(errorExpr as BooleanExpr, trueExpr, trueExpr) // Changed + val expr = xor(errorExpr as BooleanExpression, trueExpr, trueExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(E,T,T)") } @@ -749,7 +758,7 @@ class LogicalTests { @Test fun `xor - true, false, error is error`() { - val expr = xor(trueExpr, falseExpr, errorExpr as BooleanExpr) // Changed + val expr = xor(trueExpr, falseExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(T,F,E)") } @@ -761,19 +770,20 @@ class LogicalTests { @Test fun `xor - true, error, false is error`() { - val expr = xor(trueExpr, errorExpr as BooleanExpr, falseExpr) // Changed + val expr = xor(trueExpr, errorExpr as BooleanExpression, falseExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(T,E,F)") } @Test fun `xor - true, error, error is error`() { - val expr = xor(trueExpr, errorExpr as BooleanExpr, errorExpr as BooleanExpr) // Changed + val expr = + xor(trueExpr, errorExpr as BooleanExpression, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(T,E,E)") } @Test fun `xor - true, error, true is error`() { - val expr = xor(trueExpr, errorExpr as BooleanExpr, trueExpr) // Changed + val expr = xor(trueExpr, errorExpr as BooleanExpression, trueExpr) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(T,E,T)") } @@ -785,7 +795,7 @@ class LogicalTests { @Test fun `xor - true, true, error is error`() { - val expr = xor(trueExpr, trueExpr, errorExpr as BooleanExpr) // Changed + val expr = xor(trueExpr, trueExpr, errorExpr as BooleanExpression) // Changed assertEvaluatesToError(evaluate(expr, errorDoc), "XOR(T,T,E)") } @@ -960,26 +970,27 @@ class LogicalTests { // --- EqAny Tests --- @Test fun `eqAny - value found in array`() { - val expr = eqAny(constant("hello"), array(constant("hello"), constant("world"))) + val expr = equalAny(constant("hello"), array(constant("hello"), constant("world"))) assertEvaluatesTo(evaluate(expr, emptyDoc), true, "eqAny(hello, [hello, world])") } @Test fun `eqAny - value not found in array`() { - val expr = eqAny(constant(4L), array(constant(42L), constant("matang"), constant(true))) + val expr = equalAny(constant(4L), array(constant(42L), constant("matang"), constant(true))) assertEvaluatesTo(evaluate(expr, emptyDoc), false, "eqAny(4, [42, matang, true])") } @Test fun `notEqAny - value not found in array`() { val expr = - notEqAny(constant(4L), array(constant(42L), constant("matang"), constant(true))) // Changed + notEqualAny(constant(4L), array(constant(42L), constant("matang"), constant(true))) // Changed assertEvaluatesTo(evaluate(expr, emptyDoc), true, "notEqAny(4, [42, matang, true])") } @Test fun `notEqAny - value found in array`() { - val expr = notEqAny(constant("hello"), array(constant("hello"), constant("world"))) // Changed + val expr = + notEqualAny(constant("hello"), array(constant("hello"), constant("world"))) // Changed assertEvaluatesTo(evaluate(expr, emptyDoc), false, "notEqAny(hello, [hello, world])") } @@ -987,7 +998,7 @@ class LogicalTests { fun `eqAny - equivalent numerics`() { assertEvaluatesTo( evaluate( - eqAny(constant(42L), array(constant(42.0), constant("matang"), constant(true))), + equalAny(constant(42L), array(constant(42.0), constant("matang"), constant(true))), emptyDoc ), true, @@ -995,7 +1006,7 @@ class LogicalTests { ) assertEvaluatesTo( evaluate( - eqAny(constant(42.0), array(constant(42L), constant("matang"), constant(true))), + equalAny(constant(42.0), array(constant(42L), constant("matang"), constant(true))), emptyDoc ), true, @@ -1012,7 +1023,7 @@ class LogicalTests { array(constant(4L), constant(5L), constant(6L)) ) assertEvaluatesTo( - evaluate(eqAny(searchArray, valuesArray), emptyDoc), + evaluate(equalAny(searchArray, valuesArray), emptyDoc), true, "eqAny([1,2,3], [[1,2,3],...])" ) @@ -1020,49 +1031,49 @@ class LogicalTests { @Test fun `eqAny - array not found returns error`() { - val expr = eqAny(constant("matang"), field("non-existent-field")) + val expr = equalAny(constant("matang"), field("non-existent-field")) assertEvaluatesToError(evaluate(expr, emptyDoc), "eqAny(matang, non-existent-field)") } @Test fun `eqAny - array is empty returns false`() { - val expr = eqAny(constant(42L), array()) + val expr = equalAny(constant(42L), array()) assertEvaluatesTo(evaluate(expr, emptyDoc), false, "eqAny(42L, [])") } @Test fun `eqAny - search reference not found returns error`() { - val expr = eqAny(field("non-existent-field"), array(constant(42L))) + val expr = equalAny(field("non-existent-field"), array(constant(42L))) assertEvaluatesToError(evaluate(expr, emptyDoc), "eqAny(non-existent-field, [42L])") } @Test fun `eqAny - search is null`() { - val expr = eqAny(nullExpr, array(nullExpr, constant(1L), constant("matang"))) + val expr = equalAny(nullExpr, array(nullExpr, constant(1L), constant("matang"))) assertEvaluatesToNull(evaluate(expr, emptyDoc), "eqAny(null, [null,1,matang])") } @Test fun `eqAny - search is null empty values array returns null`() { - val expr = eqAny(nullExpr, array()) + val expr = equalAny(nullExpr, array()) assertEvaluatesToNull(evaluate(expr, emptyDoc), "eqAny(null, [])") } @Test fun `eqAny - search is nan`() { - val expr = eqAny(nanExpr, array(nanExpr, constant(42L), constant(3.14))) + val expr = equalAny(nanExpr, array(nanExpr, constant(42L), constant(3.14))) assertEvaluatesTo(evaluate(expr, emptyDoc), false, "eqAny(NaN, [NaN,42,3.14])") } @Test fun `eqAny - search is empty array is empty`() { - val expr = eqAny(array(), array()) + val expr = equalAny(array(), array()) assertEvaluatesTo(evaluate(expr, emptyDoc), false, "eqAny([], [])") } @Test fun `eqAny - search is empty array contains empty array returns true`() { - val expr = eqAny(array(), array(array())) + val expr = equalAny(array(), array(array())) assertEvaluatesTo(evaluate(expr, emptyDoc), true, "eqAny([], [[]])") } @@ -1076,7 +1087,7 @@ class LogicalTests { map(mapOf("foo" to constant(42L))) ) assertEvaluatesTo( - evaluate(eqAny(searchMap, valuesArray), emptyDoc), + evaluate(equalAny(searchMap, valuesArray), emptyDoc), true, "eqAny(map, [...,map])" ) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MapTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MapTests.kt index 71a740a1b90..2fd169a7824 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MapTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MapTests.kt @@ -15,9 +15,9 @@ package com.google.firebase.firestore.pipeline import com.google.firebase.firestore.model.Values.encodeValue -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.map -import com.google.firebase.firestore.pipeline.Expr.Companion.mapGet +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.map +import com.google.firebase.firestore.pipeline.Expression.Companion.mapGet import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MirroringSemanticsTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MirroringSemanticsTests.kt index 6737959cb60..94e3e15048d 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MirroringSemanticsTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/MirroringSemanticsTests.kt @@ -14,54 +14,54 @@ package com.google.firebase.firestore.pipeline -import com.google.firebase.firestore.pipeline.Expr.Companion.abs -import com.google.firebase.firestore.pipeline.Expr.Companion.add -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContains -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAll -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAny -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayLength -import com.google.firebase.firestore.pipeline.Expr.Companion.byteLength -import com.google.firebase.firestore.pipeline.Expr.Companion.charLength -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.divide -import com.google.firebase.firestore.pipeline.Expr.Companion.endsWith -import com.google.firebase.firestore.pipeline.Expr.Companion.eq -import com.google.firebase.firestore.pipeline.Expr.Companion.eqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.exp -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.gt -import com.google.firebase.firestore.pipeline.Expr.Companion.gte -import com.google.firebase.firestore.pipeline.Expr.Companion.isNan -import com.google.firebase.firestore.pipeline.Expr.Companion.isNotNan -import com.google.firebase.firestore.pipeline.Expr.Companion.like -import com.google.firebase.firestore.pipeline.Expr.Companion.ln -import com.google.firebase.firestore.pipeline.Expr.Companion.log -import com.google.firebase.firestore.pipeline.Expr.Companion.log10 -import com.google.firebase.firestore.pipeline.Expr.Companion.lt -import com.google.firebase.firestore.pipeline.Expr.Companion.lte -import com.google.firebase.firestore.pipeline.Expr.Companion.mod -import com.google.firebase.firestore.pipeline.Expr.Companion.multiply -import com.google.firebase.firestore.pipeline.Expr.Companion.neq -import com.google.firebase.firestore.pipeline.Expr.Companion.notEqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue -import com.google.firebase.firestore.pipeline.Expr.Companion.pow -import com.google.firebase.firestore.pipeline.Expr.Companion.regexContains -import com.google.firebase.firestore.pipeline.Expr.Companion.regexMatch -import com.google.firebase.firestore.pipeline.Expr.Companion.reverse -import com.google.firebase.firestore.pipeline.Expr.Companion.sqrt -import com.google.firebase.firestore.pipeline.Expr.Companion.startsWith -import com.google.firebase.firestore.pipeline.Expr.Companion.strConcat -import com.google.firebase.firestore.pipeline.Expr.Companion.strContains -import com.google.firebase.firestore.pipeline.Expr.Companion.subtract -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixMicros -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixMillis -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixSeconds -import com.google.firebase.firestore.pipeline.Expr.Companion.toLower -import com.google.firebase.firestore.pipeline.Expr.Companion.toUpper -import com.google.firebase.firestore.pipeline.Expr.Companion.trim -import com.google.firebase.firestore.pipeline.Expr.Companion.unixMicrosToTimestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.unixMillisToTimestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.unixSecondsToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.abs +import com.google.firebase.firestore.pipeline.Expression.Companion.add +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContains +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAll +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAny +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayLength +import com.google.firebase.firestore.pipeline.Expression.Companion.byteLength +import com.google.firebase.firestore.pipeline.Expression.Companion.charLength +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.divide +import com.google.firebase.firestore.pipeline.Expression.Companion.endsWith +import com.google.firebase.firestore.pipeline.Expression.Companion.equal +import com.google.firebase.firestore.pipeline.Expression.Companion.equalAny +import com.google.firebase.firestore.pipeline.Expression.Companion.exp +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.greaterThan +import com.google.firebase.firestore.pipeline.Expression.Companion.greaterThanOrEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.isNan +import com.google.firebase.firestore.pipeline.Expression.Companion.isNotNan +import com.google.firebase.firestore.pipeline.Expression.Companion.lessThan +import com.google.firebase.firestore.pipeline.Expression.Companion.lessThanOrEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.like +import com.google.firebase.firestore.pipeline.Expression.Companion.ln +import com.google.firebase.firestore.pipeline.Expression.Companion.log +import com.google.firebase.firestore.pipeline.Expression.Companion.log10 +import com.google.firebase.firestore.pipeline.Expression.Companion.mod +import com.google.firebase.firestore.pipeline.Expression.Companion.multiply +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqualAny +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue +import com.google.firebase.firestore.pipeline.Expression.Companion.pow +import com.google.firebase.firestore.pipeline.Expression.Companion.regexContains +import com.google.firebase.firestore.pipeline.Expression.Companion.regexMatch +import com.google.firebase.firestore.pipeline.Expression.Companion.reverse +import com.google.firebase.firestore.pipeline.Expression.Companion.sqrt +import com.google.firebase.firestore.pipeline.Expression.Companion.startsWith +import com.google.firebase.firestore.pipeline.Expression.Companion.stringConcat +import com.google.firebase.firestore.pipeline.Expression.Companion.stringContains +import com.google.firebase.firestore.pipeline.Expression.Companion.subtract +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixMicros +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixMillis +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixSeconds +import com.google.firebase.firestore.pipeline.Expression.Companion.toLower +import com.google.firebase.firestore.pipeline.Expression.Companion.toUpper +import com.google.firebase.firestore.pipeline.Expression.Companion.trim +import com.google.firebase.firestore.pipeline.Expression.Companion.unixMicrosToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.unixMillisToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.unixSecondsToTimestamp import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner @@ -83,14 +83,14 @@ internal class MirroringSemanticsTests { } private data class UnaryTestCase( - val inputExpr: Expr, + val inputExpr: Expression, val expectedOutcome: ExpectedOutcome, val description: String ) private data class BinaryTestCase( - val left: Expr, - val right: Expr, + val left: Expression, + val right: Expression, val expectedOutcome: ExpectedOutcome, val description: String ) @@ -98,7 +98,7 @@ internal class MirroringSemanticsTests { @Test fun `unary function input mirroring`() { val unaryFunctionBuilders = - listOf Expr>>( + listOf Expression>>( "abs" to { v -> abs(v) }, "exp" to { v -> exp(v) }, "ln" to { v -> ln(v) }, @@ -152,7 +152,7 @@ internal class MirroringSemanticsTests { @Test fun `binary function input mirroring`() { val binaryFunctionBuilders = - listOf Expr>>( + listOf Expression>>( // Arithmetic (Variadic, base is binary) "add" to { v1, v2 -> add(v1, v2) }, "subtract" to { v1, v2 -> subtract(v1, v2) }, @@ -162,26 +162,26 @@ internal class MirroringSemanticsTests { "log" to { v1, v2 -> log(v1, v2) }, "pow" to { v1, v2 -> pow(v1, v2) }, // Comparison - "eq" to { v1, v2 -> eq(v1, v2) }, - "neq" to { v1, v2 -> neq(v1, v2) }, - "lt" to { v1, v2 -> lt(v1, v2) }, - "lte" to { v1, v2 -> lte(v1, v2) }, - "gt" to { v1, v2 -> gt(v1, v2) }, - "gte" to { v1, v2 -> gte(v1, v2) }, + "eq" to { v1, v2 -> equal(v1, v2) }, + "neq" to { v1, v2 -> notEqual(v1, v2) }, + "lt" to { v1, v2 -> lessThan(v1, v2) }, + "lte" to { v1, v2 -> lessThanOrEqual(v1, v2) }, + "gt" to { v1, v2 -> greaterThan(v1, v2) }, + "gte" to { v1, v2 -> greaterThanOrEqual(v1, v2) }, // Array "arrayContains" to { v1, v2 -> arrayContains(v1, v2) }, "arrayContainsAll" to { v1, v2 -> arrayContainsAll(v1, v2) }, "arrayContainsAny" to { v1, v2 -> arrayContainsAny(v1, v2) }, - "eqAny" to { v1, v2 -> eqAny(v1, v2) }, // Maps to EqAnyExpr - "notEqAny" to { v1, v2 -> notEqAny(v1, v2) }, // Maps to NotEqAnyExpr + "eqAny" to { v1, v2 -> equalAny(v1, v2) }, // Maps to EqAnyExpr + "notEqAny" to { v1, v2 -> notEqualAny(v1, v2) }, // Maps to NotEqAnyExpr // String "like" to { v1, v2 -> like(v1, v2) }, "regexContains" to { v1, v2 -> regexContains(v1, v2) }, "regexMatch" to { v1, v2 -> regexMatch(v1, v2) }, - "strContains" to { v1, v2 -> strContains(v1, v2) }, // Maps to StrContainsExpr + "strContains" to { v1, v2 -> stringContains(v1, v2) }, // Maps to StrContainsExpr "startsWith" to { v1, v2 -> startsWith(v1, v2) }, "endsWith" to { v1, v2 -> endsWith(v1, v2) }, - "strConcat" to { v1, v2 -> strConcat(v1, v2) } // Maps to StrConcatExpr + "strConcat" to { v1, v2 -> stringConcat(v1, v2) } // Maps to StrConcatExpr // TODO(b/351084804): mapGet is not implemented yet ) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NestedPropertiesTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NestedPropertiesTests.kt index b9a226db48a..8361747e416 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NestedPropertiesTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NestedPropertiesTests.kt @@ -18,15 +18,14 @@ import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.FieldPath as PublicFieldPath import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.exists -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.isNull -import com.google.firebase.firestore.pipeline.Expr.Companion.map -import com.google.firebase.firestore.pipeline.Expr.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.exists +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.isNull +import com.google.firebase.firestore.pipeline.Expression.Companion.map +import com.google.firebase.firestore.pipeline.Expression.Companion.not import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -123,7 +122,7 @@ internal class NestedPropertiesTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("a.b.c.d.e.f.g.h.i.j.k").eq(constant(42L))) + .where(field("a.b.c.d.e.f.g.h.i.j.k").equal(constant(42L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -215,7 +214,7 @@ internal class NestedPropertiesTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("a.b.c.d.e.f.g.h.i.j.k").gte(constant(0L))) + .where(field("a.b.c.d.e.f.g.h.i.j.k").greaterThanOrEqual(constant(0L))) .sort(field(PublicFieldPath.documentId()).ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -251,7 +250,7 @@ internal class NestedPropertiesTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("address.street").eq(constant("76"))) + .where(field("address.street").equal(constant("76"))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc2) @@ -286,8 +285,8 @@ internal class NestedPropertiesTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("address.city").eq(constant("San Francisco"))) - .where(field("address.zip").gt(constant(90000L))) + .where(field("address.city").equal(constant("San Francisco"))) + .where(field("address.zip").greaterThan(constant(90000L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -324,9 +323,9 @@ internal class NestedPropertiesTests { .collection("/users") .where( field("address") - .eq(map(mapOf("city" to "San Francisco", "state" to "CA", "zip" to 94105L))) + .equal(map(mapOf("city" to "San Francisco", "state" to "CA", "zip" to 94105L))) ) - .where(field("address.zip").gt(constant(90000L))) + .where(field("address.zip").greaterThan(constant(90000L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -362,8 +361,8 @@ internal class NestedPropertiesTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("address.city").eq(constant("San Francisco"))) - .where(field("address.zip").gt(constant(90000L))) + .where(field("address.city").equal(constant("San Francisco"))) + .where(field("address.zip").greaterThan(constant(90000L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -398,25 +397,27 @@ internal class NestedPropertiesTests { val pipeline1 = RealtimePipelineSource(db) .collection("/users") - .where(field("address.zip").gt(constant(90000L))) + .where(field("address.zip").greaterThan(constant(90000L))) assertThat(runPipeline(pipeline1, listOf(*documents.toTypedArray())).toList()) .containsExactly(doc1, doc3) val pipeline2 = RealtimePipelineSource(db) .collection("/users") - .where(field("address.zip").lt(constant(90000L))) + .where(field("address.zip").lessThan(constant(90000L))) assertThat(runPipeline(pipeline2, listOf(*documents.toTypedArray())).toList()) .containsExactly(doc2) val pipeline3 = - RealtimePipelineSource(db).collection("/users").where(field("address.zip").lt(constant(0L))) + RealtimePipelineSource(db) + .collection("/users") + .where(field("address.zip").lessThan(constant(0L))) assertThat(runPipeline(pipeline3, listOf(*documents.toTypedArray())).toList()).isEmpty() val pipeline4 = RealtimePipelineSource(db) .collection("/users") - .where(field("address.zip").neq(constant(10011L))) + .where(field("address.zip").notEqual(constant(10011L))) assertThat(runPipeline(pipeline4, listOf(*documents.toTypedArray())).toList()) .containsExactly(doc1, doc3) } @@ -643,7 +644,7 @@ internal class NestedPropertiesTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field("address.city").eq(constant("San Francisco"))) + .where(field("address.city").equal(constant("San Francisco"))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc2) @@ -659,7 +660,7 @@ internal class NestedPropertiesTests { val pipeline = RealtimePipelineSource(db) .collection("/users") - .where(field(PublicFieldPath.of("address.city")).eq(constant("San Francisco"))) + .where(field(PublicFieldPath.of("address.city")).equal(constant("San Francisco"))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NullSemanticsTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NullSemanticsTests.kt index 1b7be77b606..9af855cc1f4 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NullSemanticsTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NullSemanticsTests.kt @@ -17,32 +17,31 @@ package com.google.firebase.firestore.pipeline import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContains -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAll -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAny -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.eq -import com.google.firebase.firestore.pipeline.Expr.Companion.eqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.gt -import com.google.firebase.firestore.pipeline.Expr.Companion.gte -import com.google.firebase.firestore.pipeline.Expr.Companion.isError -import com.google.firebase.firestore.pipeline.Expr.Companion.isNotNull -import com.google.firebase.firestore.pipeline.Expr.Companion.isNull -import com.google.firebase.firestore.pipeline.Expr.Companion.lt -import com.google.firebase.firestore.pipeline.Expr.Companion.lte -import com.google.firebase.firestore.pipeline.Expr.Companion.map -import com.google.firebase.firestore.pipeline.Expr.Companion.neq -import com.google.firebase.firestore.pipeline.Expr.Companion.not -import com.google.firebase.firestore.pipeline.Expr.Companion.notEqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue -import com.google.firebase.firestore.pipeline.Expr.Companion.or -import com.google.firebase.firestore.pipeline.Expr.Companion.xor +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContains +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAll +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAny +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.equal +import com.google.firebase.firestore.pipeline.Expression.Companion.equalAny +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.greaterThan +import com.google.firebase.firestore.pipeline.Expression.Companion.greaterThanOrEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.isError +import com.google.firebase.firestore.pipeline.Expression.Companion.isNotNull +import com.google.firebase.firestore.pipeline.Expression.Companion.isNull +import com.google.firebase.firestore.pipeline.Expression.Companion.lessThan +import com.google.firebase.firestore.pipeline.Expression.Companion.lessThanOrEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.map +import com.google.firebase.firestore.pipeline.Expression.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqual +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqualAny +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue +import com.google.firebase.firestore.pipeline.Expression.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.xor import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -119,7 +118,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(eq(field("score"), nullValue())) // Equality filters never match null or missing + .where(equal(field("score"), nullValue())) // Equality filters never match null or missing val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -137,7 +136,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(eq(field("score"), field("rank"))) // Equality filters never match null + .where(equal(field("score"), field("rank"))) // Equality filters never match null val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -154,7 +153,7 @@ internal class NullSemanticsTests { val documents = listOf(doc1, doc2, doc3, doc4, doc5, doc6) val pipeline = - RealtimePipelineSource(db).collection("users").where(eq(field("score.bonus"), nullValue())) + RealtimePipelineSource(db).collection("users").where(equal(field("score.bonus"), nullValue())) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -173,7 +172,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(eq(field("score.bonus"), nullValue()), eq(field("rank"), nullValue()))) + .where(and(equal(field("score.bonus"), nullValue()), equal(field("rank"), nullValue()))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -187,7 +186,7 @@ internal class NullSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("k").where(eq(field("foo"), array(nullValue()))) + RealtimePipelineSource(db).collection("k").where(equal(field("foo"), array(nullValue()))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -204,7 +203,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), array(constant(1.0), nullValue()))) + .where(equal(field("foo"), array(constant(1.0), nullValue()))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -220,7 +219,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), array(nullValue(), constant(Double.NaN)))) + .where(equal(field("foo"), array(nullValue(), constant(Double.NaN)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -236,7 +235,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), map(mapOf("a" to nullValue())))) + .where(equal(field("foo"), map(mapOf("a" to nullValue())))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -253,7 +252,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), map(mapOf("a" to constant(1.0), "b" to nullValue())))) + .where(equal(field("foo"), map(mapOf("a" to constant(1.0), "b" to nullValue())))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -269,7 +268,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), map(mapOf("a" to nullValue(), "b" to constant(Double.NaN))))) + .where(equal(field("foo"), map(mapOf("a" to nullValue(), "b" to constant(Double.NaN))))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -289,7 +288,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), map(mapOf("a" to array(nullValue()))))) + .where(equal(field("foo"), map(mapOf("a" to array(nullValue()))))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -310,7 +309,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), map(mapOf("a" to array(constant(1.0), nullValue()))))) + .where(equal(field("foo"), map(mapOf("a" to array(constant(1.0), nullValue()))))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -330,7 +329,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(eq(field("foo"), map(mapOf("a" to array(nullValue(), constant(Double.NaN)))))) + .where(equal(field("foo"), map(mapOf("a" to array(nullValue(), constant(Double.NaN)))))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -345,7 +344,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(and(eq(field("score"), constant(42L)), eq(field("rank"), nullValue()))) + .where(and(equal(field("score"), constant(42L)), equal(field("rank"), nullValue()))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -361,7 +360,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(eqAny(field("score"), array(nullValue()))) // IN filters never match null + .where(equalAny(field("score"), array(nullValue()))) // IN filters never match null val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -379,7 +378,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(eqAny(field("score"), array(nullValue(), constant(100L)))) + .where(equalAny(field("score"), array(nullValue(), constant(100L)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc4) @@ -512,7 +511,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(neq(field("score"), nullValue())) // != null is not supported + .where(notEqual(field("score"), nullValue())) // != null is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -530,7 +529,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(neq(field("score"), field("rank"))) // != null is not supported + .where(notEqual(field("score"), field("rank"))) // != null is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -546,7 +545,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(neq(field("foo"), array(nullValue()))) // != [null] is not supported + .where(notEqual(field("foo"), array(nullValue()))) // != [null] is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc3)) @@ -564,7 +563,7 @@ internal class NullSemanticsTests { RealtimePipelineSource(db) .collection("k") .where( - neq(field("foo"), array(constant(1.0), nullValue())) + notEqual(field("foo"), array(constant(1.0), nullValue())) ) // != [1.0, null] is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -582,7 +581,7 @@ internal class NullSemanticsTests { RealtimePipelineSource(db) .collection("k") .where( - neq(field("foo"), array(nullValue(), constant(Double.NaN))) + notEqual(field("foo"), array(nullValue(), constant(Double.NaN))) ) // != [null, NaN] is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -599,7 +598,9 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(neq(field("foo"), map(mapOf("a" to nullValue())))) // != {a:null} is not supported + .where( + notEqual(field("foo"), map(mapOf("a" to nullValue()))) + ) // != {a:null} is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc3)) @@ -617,7 +618,7 @@ internal class NullSemanticsTests { RealtimePipelineSource(db) .collection("k") .where( - neq(field("foo"), map(mapOf("a" to constant(1.0), "b" to nullValue()))) + notEqual(field("foo"), map(mapOf("a" to constant(1.0), "b" to nullValue()))) ) // != {a:1.0,b:null} not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -635,7 +636,7 @@ internal class NullSemanticsTests { RealtimePipelineSource(db) .collection("k") .where( - neq(field("foo"), map(mapOf("a" to nullValue(), "b" to constant(Double.NaN)))) + notEqual(field("foo"), map(mapOf("a" to nullValue(), "b" to constant(Double.NaN)))) ) // != {a:null,b:NaN} not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -651,7 +652,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(notEqAny(field("score"), array(nullValue()))) // NOT IN [null] is not supported + .where(notEqualAny(field("score"), array(nullValue()))) // NOT IN [null] is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -669,7 +670,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(gt(field("score"), nullValue())) // > null is not supported + .where(greaterThan(field("score"), nullValue())) // > null is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -687,7 +688,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(gte(field("score"), nullValue())) // >= null is not supported + .where(greaterThanOrEqual(field("score"), nullValue())) // >= null is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -705,7 +706,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(lt(field("score"), nullValue())) // < null is not supported + .where(lessThan(field("score"), nullValue())) // < null is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -723,7 +724,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(lte(field("score"), nullValue())) // <= null is not supported + .where(lessThanOrEqual(field("score"), nullValue())) // <= null is not supported val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -740,7 +741,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(and(eq(field("a"), constant(true)), eq(field("b"), constant(true)))) + .where(and(equal(field("a"), constant(true)), equal(field("b"), constant(true)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc4) @@ -761,7 +762,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(isNull(and(eq(field("a"), constant(true)), eq(field("b"), constant(true))))) + .where(isNull(and(equal(field("a"), constant(true)), equal(field("b"), constant(true))))) // (a==true AND b==true) is NULL if: // (true AND null) -> null (doc6) // (null AND true) -> null (doc3) @@ -832,7 +833,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(isError(and(eq(field("a"), constant(true)), eq(field("b"), constant(true))))) + .where(isError(and(equal(field("a"), constant(true)), equal(field("b"), constant(true))))) // This happens if either a or b is missing. val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc5, doc8)) @@ -848,7 +849,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(or(eq(field("a"), constant(true)), eq(field("b"), constant(true)))) + .where(or(equal(field("a"), constant(true)), equal(field("b"), constant(true)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -869,7 +870,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(isNull(or(eq(field("a"), constant(true)), eq(field("b"), constant(true))))) + .where(isNull(or(equal(field("a"), constant(true)), equal(field("b"), constant(true))))) // (a==true OR b==true) is NULL if: // (false OR null) -> null (doc7) // (null OR false) -> null (doc4) @@ -936,7 +937,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(isError(or(eq(field("a"), constant(true)), eq(field("b"), constant(true))))) + .where(isError(or(equal(field("a"), constant(true)), equal(field("b"), constant(true))))) // This happens if either a or b is missing. val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc5, doc8)) @@ -954,7 +955,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(xor(eq(field("a"), constant(true)), eq(field("b"), constant(true)))) + .where(xor(equal(field("a"), constant(true)), equal(field("b"), constant(true)))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc4) @@ -975,7 +976,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(isNull(xor(eq(field("a"), constant(true)), eq(field("b"), constant(true))))) + .where(isNull(xor(equal(field("a"), constant(true)), equal(field("b"), constant(true))))) // (a==true XOR b==true) is NULL if: // (true XOR null) -> null (doc6) // (false XOR null) -> null (doc7) @@ -1043,7 +1044,7 @@ internal class NullSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("k") - .where(isError(xor(eq(field("a"), constant(true)), eq(field("b"), constant(true))))) + .where(isError(xor(equal(field("a"), constant(true)), equal(field("b"), constant(true))))) // This happens if either a or b is missing. val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc5, doc8)) @@ -1057,7 +1058,7 @@ internal class NullSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("k").where(not(eq(field("a"), constant(true)))) + RealtimePipelineSource(db).collection("k").where(not(equal(field("a"), constant(true)))) // Based on C++ test's interpretation of TS behavior for NOT val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -1072,7 +1073,9 @@ internal class NullSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("k").where(isNull(not(eq(field("a"), constant(true))))) + RealtimePipelineSource(db) + .collection("k") + .where(isNull(not(equal(field("a"), constant(true))))) // NOT(null_operand) -> null. So ISNULL(null) -> true. // NOT(true) -> false. ISNULL(false) -> false. // NOT(false) -> true. ISNULL(true) -> false. @@ -1095,7 +1098,9 @@ internal class NullSemanticsTests { val documents = listOf(doc1, doc2, doc3, doc4) val pipeline = - RealtimePipelineSource(db).collection("k").where(isError(not(eq(field("a"), constant(true))))) + RealtimePipelineSource(db) + .collection("k") + .where(isError(not(equal(field("a"), constant(true))))) // This happens if a is missing. val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc4) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NumberSemanticsTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NumberSemanticsTests.kt index 46d9834026e..9ff64cd33c4 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NumberSemanticsTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/NumberSemanticsTests.kt @@ -17,15 +17,14 @@ package com.google.firebase.firestore.pipeline import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContains -import com.google.firebase.firestore.pipeline.Expr.Companion.arrayContainsAny -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.notEqAny +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContains +import com.google.firebase.firestore.pipeline.Expression.Companion.arrayContainsAny +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.notEqualAny import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -45,7 +44,7 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc3, doc4, doc5) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("score").eq(constant(-0.0))) + RealtimePipelineSource(db).collection("users").where(field("score").equal(constant(-0.0))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3, doc4)) @@ -62,7 +61,7 @@ internal class NumberSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("score").eq(constant(0L))) // Firestore -0LL is 0L + .where(field("score").equal(constant(0L))) // Firestore -0LL is 0L val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3, doc4)) @@ -77,7 +76,7 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc3, doc4, doc5) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("score").eq(constant(0.0))) + RealtimePipelineSource(db).collection("users").where(field("score").equal(constant(0.0))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3, doc4)) @@ -92,7 +91,7 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc3, doc4, doc5) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("score").eq(constant(0L))) + RealtimePipelineSource(db).collection("users").where(field("score").equal(constant(0L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc3, doc4)) @@ -106,7 +105,7 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("age").eq(constant(Double.NaN))) + RealtimePipelineSource(db).collection("users").where(field("age").equal(constant(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -120,7 +119,9 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("age").lt(constant(Double.NaN))) + RealtimePipelineSource(db) + .collection("users") + .where(field("age").lessThan(constant(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -134,7 +135,9 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("age").lte(constant(Double.NaN))) + RealtimePipelineSource(db) + .collection("users") + .where(field("age").lessThanOrEqual(constant(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -148,7 +151,9 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("age").gte(constant(Double.NaN))) + RealtimePipelineSource(db) + .collection("users") + .where(field("age").greaterThanOrEqual(constant(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -162,7 +167,9 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("age").gt(constant(Double.NaN))) + RealtimePipelineSource(db) + .collection("users") + .where(field("age").greaterThan(constant(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -176,7 +183,9 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("age").neq(constant(Double.NaN))) + RealtimePipelineSource(db) + .collection("users") + .where(field("age").notEqual(constant(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc2, doc3)) @@ -192,7 +201,7 @@ internal class NumberSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("name").eqAny(array(Double.NaN, "alice"))) + .where(field("name").equalAny(array(Double.NaN, "alice"))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc1) @@ -206,7 +215,7 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2, doc3) val pipeline = - RealtimePipelineSource(db).collection("users").where(field("age").eqAny(array(Double.NaN))) + RealtimePipelineSource(db).collection("users").where(field("age").equalAny(array(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -259,7 +268,7 @@ internal class NumberSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(notEqAny(field("age"), array(Double.NaN, 42L))) + .where(notEqualAny(field("age"), array(Double.NaN, 42L))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc2, doc3)) @@ -275,7 +284,7 @@ internal class NumberSemanticsTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(notEqAny(field("age"), array(Double.NaN))) + .where(notEqualAny(field("age"), array(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactlyElementsIn(listOf(doc1, doc2, doc3)) @@ -288,7 +297,7 @@ internal class NumberSemanticsTests { val documents = listOf(doc1, doc2) val pipeline = - RealtimePipelineSource(db).collection("k").where(field("foo").eq(array(Double.NaN))) + RealtimePipelineSource(db).collection("k").where(field("foo").equal(array(Double.NaN))) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/PipelineTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/PipelineTests.kt index 01c1d3e2667..d06345ac13e 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/PipelineTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/PipelineTests.kt @@ -18,10 +18,9 @@ import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil import com.google.firebase.firestore.model.MutableDocument -import com.google.firebase.firestore.pipeline.Expr.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.field import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -33,7 +32,7 @@ internal class PipelineTests { @Test fun `runPipeline executes without error`(): Unit = runBlocking { val firestore = TestUtil.firestore() - val pipeline = RealtimePipelineSource(firestore).collection("foo").where(field("bar").eq(42)) + val pipeline = RealtimePipelineSource(firestore).collection("foo").where(field("bar").equal(42)) val doc1: MutableDocument = doc("foo/1", 0, mapOf("bar" to 42)) val doc2: MutableDocument = doc("foo/2", 0, mapOf("bar" to "43")) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/SortTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/SortTests.kt index 2e49b282d53..7cd313b237c 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/SortTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/SortTests.kt @@ -19,14 +19,13 @@ import com.google.firebase.firestore.FieldPath as PublicFieldPath import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil import com.google.firebase.firestore.model.MutableDocument -import com.google.firebase.firestore.pipeline.Expr.Companion.add -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.exists -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.add +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.exists +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.not import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -100,7 +99,7 @@ internal class SortTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("age").eq(10L)) + .where(field("age").equal(10L)) .sort(field("age").ascending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -138,7 +137,7 @@ internal class SortTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("age").eq(10L)) + .where(field("age").equal(10L)) .sort(field("age").descending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -206,7 +205,7 @@ internal class SortTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("age").gt(0.0)) + .where(field("age").greaterThan(0.0)) .sort(field("age").descending()) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3, doc1, doc2, doc4, doc5).inOrder() @@ -287,7 +286,7 @@ internal class SortTests { val pipeline = RealtimePipelineSource(db) .collection("users") - .where(field("age").eq(field("age"))) // Implicit exists age + .where(field("age").equal(field("age"))) // Implicit exists age .where(field("name").regexMatch(".*")) // Implicit exists name .sort(field("age").descending(), field("name").ascending()) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/StringTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/StringTests.kt index b0ea61da571..b287f0ad9bc 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/StringTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/StringTests.kt @@ -15,24 +15,23 @@ package com.google.firebase.firestore.pipeline import com.google.firebase.firestore.model.Values.encodeValue -import com.google.firebase.firestore.pipeline.Expr.Companion.blob -import com.google.firebase.firestore.pipeline.Expr.Companion.byteLength -import com.google.firebase.firestore.pipeline.Expr.Companion.charLength -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.endsWith -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.like -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue -import com.google.firebase.firestore.pipeline.Expr.Companion.regexContains -import com.google.firebase.firestore.pipeline.Expr.Companion.regexMatch -import com.google.firebase.firestore.pipeline.Expr.Companion.reverse -import com.google.firebase.firestore.pipeline.Expr.Companion.startsWith -import com.google.firebase.firestore.pipeline.Expr.Companion.strConcat -import com.google.firebase.firestore.pipeline.Expr.Companion.strContains -import com.google.firebase.firestore.pipeline.Expr.Companion.substr -import com.google.firebase.firestore.pipeline.Expr.Companion.toLower -import com.google.firebase.firestore.pipeline.Expr.Companion.toUpper -import com.google.firebase.firestore.pipeline.Expr.Companion.trim +import com.google.firebase.firestore.pipeline.Expression.Companion.byteLength +import com.google.firebase.firestore.pipeline.Expression.Companion.charLength +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.endsWith +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.like +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue +import com.google.firebase.firestore.pipeline.Expression.Companion.regexContains +import com.google.firebase.firestore.pipeline.Expression.Companion.regexMatch +import com.google.firebase.firestore.pipeline.Expression.Companion.reverse +import com.google.firebase.firestore.pipeline.Expression.Companion.startsWith +import com.google.firebase.firestore.pipeline.Expression.Companion.stringConcat +import com.google.firebase.firestore.pipeline.Expression.Companion.stringContains +import com.google.firebase.firestore.pipeline.Expression.Companion.substring +import com.google.firebase.firestore.pipeline.Expression.Companion.toLower +import com.google.firebase.firestore.pipeline.Expression.Companion.toUpper +import com.google.firebase.firestore.pipeline.Expression.Companion.trim import com.google.firebase.firestore.testutil.TestUtilKtx.doc import com.google.protobuf.ByteString import org.junit.Test @@ -52,7 +51,7 @@ internal class StringTests { @Test fun byteLength_emptyByte_returnsZero() { - val expr = byteLength(blob(byteArrayOf())) + val expr = byteLength(constant(byteArrayOf())) val result = evaluate(expr) assertEvaluatesTo(result, encodeValue(0L), "byteLength(blob(byteArrayOf()))") } @@ -66,7 +65,7 @@ internal class StringTests { // Test with a valid Blob val bytesForBlob = byteArrayOf(0x01.toByte(), 0x02.toByte(), 0x03.toByte()) val exprAsBlob = - byteLength(blob(bytesForBlob)) // Renamed exprBlob to avoid conflict if it was a var + byteLength(constant(bytesForBlob)) // Renamed exprBlob to avoid conflict if it was a var val resultBlob = evaluate(exprAsBlob) assertEvaluatesTo(resultBlob, encodeValue(3L), "byteLength(blob(1,2,3))") @@ -206,7 +205,7 @@ internal class StringTests { 0xbc.toByte() ) assertEvaluatesTo( - evaluate(byteLength(blob(bytesTwo))), + evaluate(byteLength(constant(bytesTwo))), encodeValue(10L), "byteLength(blob for \"éçñöü\")" ) @@ -234,7 +233,7 @@ internal class StringTests { 0x8c.toByte() ) assertEvaluatesTo( - evaluate(byteLength(blob(bytesThree))), + evaluate(byteLength(constant(bytesThree))), encodeValue(12L), "byteLength(blob for \"你好世界\")" ) @@ -257,7 +256,7 @@ internal class StringTests { 0xA1.toByte() ) assertEvaluatesTo( - evaluate(byteLength(blob(bytesFour))), + evaluate(byteLength(constant(bytesFour))), encodeValue(8L), "byteLength(blob for \"🀘🂡\")" ) @@ -286,7 +285,7 @@ internal class StringTests { 0xA1.toByte() ) assertEvaluatesTo( - evaluate(byteLength(blob(bytesMix))), + evaluate(byteLength(constant(bytesMix))), encodeValue(10L), "byteLength(blob for \"aé好🂡\")" ) @@ -304,7 +303,7 @@ internal class StringTests { fun charLength_bytesType_returnsError() { // charLength expects a string, not bytes/blob val charBlobBytes = byteArrayOf('a'.code.toByte(), 'b'.code.toByte(), 'c'.code.toByte()) - val expr = charLength(blob(charBlobBytes)) + val expr = charLength(constant(charBlobBytes)) val result = evaluate(expr) assertEvaluatesToError(result, "charLength(blob)") } @@ -447,48 +446,48 @@ internal class StringTests { // --- StrConcat Tests --- @Test - fun strConcat_multipleStringChildren_returnsCombination() { - val expr = strConcat(constant("foo"), constant(" "), constant("bar")) + fun stringConcat_multipleStringChildren_returnsCombination() { + val expr = stringConcat(constant("foo"), constant(" "), constant("bar")) val result = evaluate(expr) - assertEvaluatesTo(result, encodeValue("foo bar"), "strConcat(\"foo\", \" \", \"bar\")") + assertEvaluatesTo(result, encodeValue("foo bar"), "stringConcat(\"foo\", \" \", \"bar\")") } @Test - fun strConcat_multipleNonStringChildren_returnsError() { - // strConcat should only accept strings or expressions that evaluate to strings. - // The Kotlin `strConcat` vararg is `Any`, then converted via `toArrayOfExprOrConstant`. + fun stringConcat_multipleNonStringChildren_returnsError() { + // stringConcat should only accept strings or expressions that evaluate to strings. + // The Kotlin `stringConcat` vararg is `Any`, then converted via `toArrayOfExprOrConstant`. // `evaluateStrConcat` checks if all resolved params are strings. - val expr = strConcat(constant("foo"), constant(42L), constant("bar")) + val expr = stringConcat(constant("foo"), constant(42L), constant("bar")) val result = evaluate(expr) - assertEvaluatesToError(result, "strConcat(\"foo\", 42L, \"bar\")") + assertEvaluatesToError(result, "stringConcat(\"foo\", 42L, \"bar\")") } @Test - fun strConcat_multipleCalls() { - val expr = strConcat(constant("foo"), constant(" "), constant("bar")) - assertEvaluatesTo(evaluate(expr), encodeValue("foo bar"), "strConcat call 1") - assertEvaluatesTo(evaluate(expr), encodeValue("foo bar"), "strConcat call 2") - assertEvaluatesTo(evaluate(expr), encodeValue("foo bar"), "strConcat call 3") + fun stringConcat_multipleCalls() { + val expr = stringConcat(constant("foo"), constant(" "), constant("bar")) + assertEvaluatesTo(evaluate(expr), encodeValue("foo bar"), "stringConcat call 1") + assertEvaluatesTo(evaluate(expr), encodeValue("foo bar"), "stringConcat call 2") + assertEvaluatesTo(evaluate(expr), encodeValue("foo bar"), "stringConcat call 3") } @Test - fun strConcat_largeNumberOfInputs() { + fun stringConcat_largeNumberOfInputs() { val argCount = 500 val args = Array(argCount) { constant("a") } val expectedResult = "a".repeat(argCount) - val expr = strConcat(args.first(), *args.drop(1).toTypedArray()) // Pass varargs correctly + val expr = stringConcat(args.first(), *args.drop(1).toTypedArray()) // Pass varargs correctly val result = evaluate(expr) - assertEvaluatesTo(result, encodeValue(expectedResult), "strConcat large number of inputs") + assertEvaluatesTo(result, encodeValue(expectedResult), "stringConcat large number of inputs") } @Test - fun strConcat_largeStrings() { + fun stringConcat_largeStrings() { val a500 = "a".repeat(500) val b500 = "b".repeat(500) val c500 = "c".repeat(500) - val expr = strConcat(constant(a500), constant(b500), constant(c500)) + val expr = stringConcat(constant(a500), constant(b500), constant(c500)) val result = evaluate(expr) - assertEvaluatesTo(result, encodeValue(a500 + b500 + c500), "strConcat large strings") + assertEvaluatesTo(result, encodeValue(a500 + b500 + c500), "stringConcat large strings") } // --- EndsWith Tests --- @@ -617,13 +616,13 @@ internal class StringTests { @Test fun regexContains_getSubStringLiteral() { val expr = regexContains(constant("yummy good food"), constant("good")) - assertEvaluatesTo(evaluate(expr), true, "regexContains substring literal") + assertEvaluatesTo(evaluate(expr), true, "regexContains substringing literal") } @Test fun regexContains_getSubStringRegex() { val expr = regexContains(constant("yummy good food"), constant("go*d")) - assertEvaluatesTo(evaluate(expr), true, "regexContains substring regex") + assertEvaluatesTo(evaluate(expr), true, "regexContains substringing regex") } @Test @@ -666,13 +665,13 @@ internal class StringTests { @Test fun regexMatch_getSubStringLiteral() { val expr = regexMatch(constant("yummy good food"), constant("good")) - assertEvaluatesTo(evaluate(expr), false, "regexMatch substring literal (false)") + assertEvaluatesTo(evaluate(expr), false, "regexMatch substringing literal (false)") } @Test fun regexMatch_getSubStringRegex() { val expr = regexMatch(constant("yummy good food"), constant("go*d")) - assertEvaluatesTo(evaluate(expr), false, "regexMatch substring regex (false)") + assertEvaluatesTo(evaluate(expr), false, "regexMatch substringing regex (false)") } @Test @@ -740,67 +739,67 @@ internal class StringTests { // --- StrContains Tests --- @Test - fun strContains_valueNonString_isError() { - val expr = strContains(constant(42L), constant("value")) - assertEvaluatesToError(evaluate(expr), "strContains(42L, \"value\")") + fun stringContains_valueNonString_isError() { + val expr = stringContains(constant(42L), constant("value")) + assertEvaluatesToError(evaluate(expr), "stringContains(42L, \"value\")") } @Test - fun strContains_subStringNonString_isError() { - val expr = strContains(constant("search space"), constant(42L)) - assertEvaluatesToError(evaluate(expr), "strContains(\"search space\", 42L)") + fun stringContains_subStringNonString_isError() { + val expr = stringContains(constant("search space"), constant(42L)) + assertEvaluatesToError(evaluate(expr), "stringContains(\"search space\", 42L)") } @Test - fun strContains_executeTrue() { + fun stringContains_executeTrue() { assertEvaluatesTo( - evaluate(strContains(constant("abc"), constant("c"))), + evaluate(stringContains(constant("abc"), constant("c"))), true, - "strContains true 1" + "stringContains true 1" ) assertEvaluatesTo( - evaluate(strContains(constant("abc"), constant("bc"))), + evaluate(stringContains(constant("abc"), constant("bc"))), true, - "strContains true 2" + "stringContains true 2" ) assertEvaluatesTo( - evaluate(strContains(constant("abc"), constant("abc"))), + evaluate(stringContains(constant("abc"), constant("abc"))), true, - "strContains true 3" + "stringContains true 3" ) assertEvaluatesTo( - evaluate(strContains(constant("abc"), constant(""))), + evaluate(stringContains(constant("abc"), constant(""))), true, - "strContains true 4" - ) // Empty string is a substring + "stringContains true 4" + ) // Empty string is a substringing assertEvaluatesTo( - evaluate(strContains(constant(""), constant(""))), + evaluate(stringContains(constant(""), constant(""))), true, - "strContains true 5" + "stringContains true 5" ) // Empty string in empty string assertEvaluatesTo( - evaluate(strContains(constant("☃☃☃"), constant("☃"))), + evaluate(stringContains(constant("☃☃☃"), constant("☃"))), true, - "strContains true 6" + "stringContains true 6" ) } @Test - fun strContains_executeFalse() { + fun stringContains_executeFalse() { assertEvaluatesTo( - evaluate(strContains(constant("abc"), constant("abcd"))), + evaluate(stringContains(constant("abc"), constant("abcd"))), false, - "strContains false 1" + "stringContains false 1" ) assertEvaluatesTo( - evaluate(strContains(constant("abc"), constant("d"))), + evaluate(stringContains(constant("abc"), constant("d"))), false, - "strContains false 2" + "stringContains false 2" ) assertEvaluatesTo( - evaluate(strContains(constant(""), constant("a"))), + evaluate(stringContains(constant(""), constant("a"))), false, - "strContains false 3" + "stringContains false 3" ) } @@ -825,7 +824,7 @@ internal class StringTests { @Test fun toLower_null() { - val expr = toLower(nullValue()) // Use Expr.nullValue() for Firestore null + val expr = toLower(nullValue()) // Use Expression.nullValue() for Firestore null assertEvaluatesToNull(evaluate(expr), "toLower(null)") } @@ -926,271 +925,271 @@ internal class StringTests { } @Test - fun substr_onString_returnsSubstring() { - val expr = substr(constant("abc"), constant(1L), constant(2L)) - assertEvaluatesTo(evaluate(expr), encodeValue("bc"), "substr(\"abc\", 1, 2)") + fun substring_onString_returnsSubstring() { + val expr = substring(constant("abc"), constant(1L), constant(2L)) + assertEvaluatesTo(evaluate(expr), encodeValue("bc"), "substring(\"abc\", 1, 2)") } @Test - fun substr_onString_largePosition_returnsEmptyString() { - val expr = substr(constant("abc"), constant(Long.MAX_VALUE), constant(1L)) - assertEvaluatesTo(evaluate(expr), encodeValue(""), "substr('abc', Long.MAX_VALUE, 1)") + fun substring_onString_largePosition_returnsEmptyString() { + val expr = substring(constant("abc"), constant(Long.MAX_VALUE), constant(1L)) + assertEvaluatesTo(evaluate(expr), encodeValue(""), "substring('abc', Long.MAX_VALUE, 1)") } @Test - fun substr_onString_positionOnLast_returnsLastCharacter() { - val expr = substr(constant("abc"), constant(2L), constant(2L)) - assertEvaluatesTo(evaluate(expr), encodeValue("c"), "substr(\"abc\", 2, 2)") + fun substring_onString_positionOnLast_returnsLastCharacter() { + val expr = substring(constant("abc"), constant(2L), constant(2L)) + assertEvaluatesTo(evaluate(expr), encodeValue("c"), "substring(\"abc\", 2, 2)") } @Test - fun substr_onString_positionPastLast_returnsEmptyString() { - val expr = substr(constant("abc"), constant(3L), constant(2L)) - assertEvaluatesTo(evaluate(expr), encodeValue(""), "substr(\"abc\", 3, 2)") + fun substring_onString_positionPastLast_returnsEmptyString() { + val expr = substring(constant("abc"), constant(3L), constant(2L)) + assertEvaluatesTo(evaluate(expr), encodeValue(""), "substring(\"abc\", 3, 2)") } @Test - fun substr_onString_positionOnZero_startsFromZero() { - val expr = substr(constant("abc"), constant(0L), constant(6L)) - assertEvaluatesTo(evaluate(expr), encodeValue("abc"), "substr(\"abc\", 0, 6)") + fun substring_onString_positionOnZero_startsFromZero() { + val expr = substring(constant("abc"), constant(0L), constant(6L)) + assertEvaluatesTo(evaluate(expr), encodeValue("abc"), "substring(\"abc\", 0, 6)") } @Test - fun substr_onString_oversizedLength_returnsTruncatedString() { - val expr = substr(constant("abc"), constant(1L), constant(Long.MAX_VALUE)) - assertEvaluatesTo(evaluate(expr), encodeValue("bc"), "substr(\"abc\", 1, Long.MAX_VALUE)") + fun substring_onString_oversizedLength_returnsTruncatedString() { + val expr = substring(constant("abc"), constant(1L), constant(Long.MAX_VALUE)) + assertEvaluatesTo(evaluate(expr), encodeValue("bc"), "substring(\"abc\", 1, Long.MAX_VALUE)") } @Test - fun substr_onString_negativePosition() { - val expr = substr(constant("abcd"), constant(-3L), constant(2L)) - assertEvaluatesTo(evaluate(expr), encodeValue("bc"), "substr(\"abcd\", -3, 2)") + fun substring_onString_negativePosition() { + val expr = substring(constant("abcd"), constant(-3L), constant(2L)) + assertEvaluatesTo(evaluate(expr), encodeValue("bc"), "substring(\"abcd\", -3, 2)") } @Test - fun substr_onString_negativePosition_startsFromLast() { - val expr = substr(constant("abc"), constant(-1L), constant(1L)) - assertEvaluatesTo(evaluate(expr), encodeValue("c"), "substr(\"abc\", -1, 1)") + fun substring_onString_negativePosition_startsFromLast() { + val expr = substring(constant("abc"), constant(-1L), constant(1L)) + assertEvaluatesTo(evaluate(expr), encodeValue("c"), "substring(\"abc\", -1, 1)") } @Test - fun substr_onCodePoints_negativePosition_startsFromLast() { - val expr = substr(constant("㉇🀄"), constant(-1L), constant(1L)) - assertEvaluatesTo(evaluate(expr), encodeValue("🀄"), "substr(\"㉇🀄\", -1, 1)") + fun substring_onCodePoints_negativePosition_startsFromLast() { + val expr = substring(constant("㉇🀄"), constant(-1L), constant(1L)) + assertEvaluatesTo(evaluate(expr), encodeValue("🀄"), "substring(\"㉇🀄\", -1, 1)") } @Test - fun substr_onString_maxNegativePosition_startsFromZero() { - val expr = substr(blob("abc".toByteArray()), constant(-Long.MAX_VALUE), constant(2L)) + fun substring_onString_maxNegativePosition_startsFromZero() { + val expr = substring(constant("abc".toByteArray()), constant(-Long.MAX_VALUE), constant(2L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromBytes("ab".toByteArray())), - "substr(blob(abc), -Long.MAX_VALUE, 2)" + "substring(blob(abc), -Long.MAX_VALUE, 2)" ) } @Test - fun substr_onString_oversizedNegativePosition_startsFromZero() { - val expr = substr(blob("abc".toByteArray()), constant(-4L), constant(2L)) + fun substring_onString_oversizedNegativePosition_startsFromZero() { + val expr = substring(constant("abc".toByteArray()), constant(-4L), constant(2L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromBytes("ab".toByteArray())), - "substr(blob(abc), -4, 2)" + "substring(blob(abc), -4, 2)" ) } @Test - fun substr_onNonAsciiString() { - val expr = substr(constant("ϖϗϠ"), constant(1L), constant(1L)) - assertEvaluatesTo(evaluate(expr), encodeValue("ϗ"), "substr(\"ϖϗϠ\", 1, 1)") + fun substring_onNonAsciiString() { + val expr = substring(constant("ϖϗϠ"), constant(1L), constant(1L)) + assertEvaluatesTo(evaluate(expr), encodeValue("ϗ"), "substring(\"ϖϗϠ\", 1, 1)") } @Test - fun substr_onCharacterDecomposition_treatedAsSeparateCharacters() { + fun substring_onCharacterDecomposition_treatedAsSeparateCharacters() { val umlaut = String(charArrayOf(0x0308.toChar())) val decomposedChar = "u" + umlaut // Assert that the component characters of a decomposed character are trimmed correctly. - val expr1 = substr(constant(decomposedChar), constant(1), constant(2)) - assertEvaluatesTo(evaluate(expr1), encodeValue(umlaut), "substr(decomposed, 1, 2)") + val expr1 = substring(constant(decomposedChar), constant(1), constant(2)) + assertEvaluatesTo(evaluate(expr1), encodeValue(umlaut), "substring(decomposed, 1, 2)") - val expr2 = substr(constant(decomposedChar), constant(0), constant(1)) - assertEvaluatesTo(evaluate(expr2), encodeValue("u"), "substr(decomposed, 0, 1)") + val expr2 = substring(constant(decomposedChar), constant(0), constant(1)) + assertEvaluatesTo(evaluate(expr2), encodeValue("u"), "substring(decomposed, 0, 1)") } @Test - fun substr_onComposedCharacter_treatedAsSingleCharacter() { - val expr1 = substr(constant("ü"), constant(1), constant(1)) - assertEvaluatesTo(evaluate(expr1), encodeValue(""), "substr(\"ü\", 1, 1)") + fun substring_onComposedCharacter_treatedAsSingleCharacter() { + val expr1 = substring(constant("ü"), constant(1), constant(1)) + assertEvaluatesTo(evaluate(expr1), encodeValue(""), "substring(\"ü\", 1, 1)") - val expr2 = substr(constant("ü"), constant(0), constant(1)) - assertEvaluatesTo(evaluate(expr2), encodeValue("ü"), "substr(\"ü\", 0, 1)") + val expr2 = substring(constant("ü"), constant(0), constant(1)) + assertEvaluatesTo(evaluate(expr2), encodeValue("ü"), "substring(\"ü\", 0, 1)") } @Test - fun substr_mixedAsciiNonAsciiString_returnsSubstring() { - val expr = substr(constant("aϗbϖϗϠc"), constant(1), constant(3)) - assertEvaluatesTo(evaluate(expr), encodeValue("ϗbϖ"), "substr(\"aϗbϖϗϠc\", 1, 3)") + fun substring_mixedAsciiNonAsciiString_returnsSubstring() { + val expr = substring(constant("aϗbϖϗϠc"), constant(1), constant(3)) + assertEvaluatesTo(evaluate(expr), encodeValue("ϗbϖ"), "substring(\"aϗbϖϗϠc\", 1, 3)") } @Test - fun substr_mixedAsciiNonAsciiString_afterNonAscii() { - val expr = substr(constant("aϗbϖϗϠc"), constant(4), constant(2)) - assertEvaluatesTo(evaluate(expr), encodeValue("ϗϠ"), "substr(\"aϗbϖϗϠc\", 4, 2)") + fun substring_mixedAsciiNonAsciiString_afterNonAscii() { + val expr = substring(constant("aϗbϖϗϠc"), constant(4), constant(2)) + assertEvaluatesTo(evaluate(expr), encodeValue("ϗϠ"), "substring(\"aϗbϖϗϠc\", 4, 2)") } @Test - fun substr_onString_negativeLength_throws() { - val expr = substr(blob("abc".toByteArray()), constant(1L), constant(-1L)) - assertEvaluatesToError(evaluate(expr), "substr with negative length") + fun substring_onString_negativeLength_throws() { + val expr = substring(constant("abc".toByteArray()), constant(1L), constant(-1L)) + assertEvaluatesToError(evaluate(expr), "substring with negative length") } @Test - fun substr_onBytes_returnsSubstring() { - val expr = substr(blob("abc".toByteArray()), constant(1L), constant(2L)) + fun substring_onBytes_returnsSubstring() { + val expr = substring(constant("abc".toByteArray()), constant(1L), constant(2L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromBytes("bc".toByteArray())), - "substr(blob(abc), 1, 2)" + "substring(blob(abc), 1, 2)" ) } @Test - fun substr_onBytes_returnsInvalidUTF8Substring() { + fun substring_onBytes_returnsInvalidUTF8Substring() { val expr = - substr( - blob(ByteString.fromHex("F9FAFB").toByteArray()), + substring( + constant(ByteString.fromHex("F9FAFB").toByteArray()), constant(1L), constant(Long.MAX_VALUE) ) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromByteString(ByteString.fromHex("FAFB"))), - "substr invalid utf8" + "substring invalid utf8" ) } @Test - fun substr_onCodePoints_returnsSubstring() { + fun substring_onCodePoints_returnsSubstring() { val codePoints = "🌎㉇🀄⛹" - val expr = substr(constant(codePoints), constant(1L), constant(2L)) - assertEvaluatesTo(evaluate(expr), encodeValue("㉇🀄"), "substr(\"🌎㉇🀄⛹\", 1, 2)") + val expr = substring(constant(codePoints), constant(1L), constant(2L)) + assertEvaluatesTo(evaluate(expr), encodeValue("㉇🀄"), "substring(\"🌎㉇🀄⛹\", 1, 2)") } @Test - fun substr_onCodePoints_andAscii_returnsSubstring() { + fun substring_onCodePoints_andAscii_returnsSubstring() { val codePoints = "🌎㉇foo🀄bar⛹" - val expr = substr(constant(codePoints), constant(4L), constant(4L)) - assertEvaluatesTo(evaluate(expr), encodeValue("o🀄ba"), "substr(\"🌎㉇foo🀄bar⛹\", 4, 4)") + val expr = substring(constant(codePoints), constant(4L), constant(4L)) + assertEvaluatesTo(evaluate(expr), encodeValue("o🀄ba"), "substring(\"🌎㉇foo🀄bar⛹\", 4, 4)") } @Test - fun substr_onCodePoints_oversizedLength_returnsSubstring() { + fun substring_onCodePoints_oversizedLength_returnsSubstring() { val codePoints = "🌎㉇🀄⛹" - val expr = substr(constant(codePoints), constant(1L), constant(6L)) - assertEvaluatesTo(evaluate(expr), encodeValue("㉇🀄⛹"), "substr(\"🌎㉇🀄⛹\", 1, 6)") + val expr = substring(constant(codePoints), constant(1L), constant(6L)) + assertEvaluatesTo(evaluate(expr), encodeValue("㉇🀄⛹"), "substring(\"🌎㉇🀄⛹\", 1, 6)") } @Test - fun substr_onCodePoints_startingAtZero_returnsSubstring() { + fun substring_onCodePoints_startingAtZero_returnsSubstring() { val codePoints = "🌎㉇🀄⛹" - val expr = substr(constant(codePoints), constant(0L), constant(3L)) - assertEvaluatesTo(evaluate(expr), encodeValue("🌎㉇🀄"), "substr(\"🌎㉇🀄⛹\", 0, 3)") + val expr = substring(constant(codePoints), constant(0L), constant(3L)) + assertEvaluatesTo(evaluate(expr), encodeValue("🌎㉇🀄"), "substring(\"🌎㉇🀄⛹\", 0, 3)") } @Test - fun substr_onSingleCodePointGrapheme_doesNotSplit() { - val expr1 = substr(constant("🖖"), constant(0L), constant(1L)) - assertEvaluatesTo(evaluate(expr1), encodeValue("🖖"), "substr(\"🖖\", 0, 1)") - val expr2 = substr(constant("🖖"), constant(1L), constant(1L)) - assertEvaluatesTo(evaluate(expr2), encodeValue(""), "substr(\"🖖\", 1, 1)") + fun substring_onSingleCodePointGrapheme_doesNotSplit() { + val expr1 = substring(constant("🖖"), constant(0L), constant(1L)) + assertEvaluatesTo(evaluate(expr1), encodeValue("🖖"), "substring(\"🖖\", 0, 1)") + val expr2 = substring(constant("🖖"), constant(1L), constant(1L)) + assertEvaluatesTo(evaluate(expr2), encodeValue(""), "substring(\"🖖\", 1, 1)") } @Test - fun substr_onMultiCodePointGrapheme_splitsGrapheme() { - val expr1 = substr(constant("🖖🏻"), constant(0L), constant(1L)) - assertEvaluatesTo(evaluate(expr1), encodeValue("🖖"), "substr(\"🖖🏻\", 0, 1)") + fun substring_onMultiCodePointGrapheme_splitsGrapheme() { + val expr1 = substring(constant("🖖🏻"), constant(0L), constant(1L)) + assertEvaluatesTo(evaluate(expr1), encodeValue("🖖"), "substring(\"🖖🏻\", 0, 1)") // Asserting that when the second half is split, it only returns the skin tone code point. - val expr2 = substr(constant("🖖🏻"), constant(1L), constant(1L)) + val expr2 = substring(constant("🖖🏻"), constant(1L), constant(1L)) val skinTone = String(charArrayOf(0xD83C.toChar(), 0xDFFB.toChar())) - assertEvaluatesTo(evaluate(expr2), encodeValue(skinTone), "substr(\"🖖🏻\", 1, 1)") + assertEvaluatesTo(evaluate(expr2), encodeValue(skinTone), "substring(\"🖖🏻\", 1, 1)") } @Test - fun substr_onBytes_largePosition_returnsEmptyString() { - val expr = substr(blob("abc".toByteArray()), constant(Long.MAX_VALUE), constant(3L)) + fun substring_onBytes_largePosition_returnsEmptyString() { + val expr = substring(constant("abc".toByteArray()), constant(Long.MAX_VALUE), constant(3L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromByteString(ByteString.EMPTY)), - "substr(blob(abc), Long.MAX_VALUE, 3)" + "substring(blob(abc), Long.MAX_VALUE, 3)" ) } @Test - fun substr_onBytes_positionOnLast_returnsLastByte() { - val expr = substr(blob("abc".toByteArray()), constant(2L), constant(2L)) + fun substring_onBytes_positionOnLast_returnsLastByte() { + val expr = substring(constant("abc".toByteArray()), constant(2L), constant(2L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromBytes("c".toByteArray())), - "substr(blob(abc), 2, 2)" + "substring(blob(abc), 2, 2)" ) } @Test - fun substr_onBytes_positionPastLast_returnsEmptyByteString() { - val expr = substr(blob("abc".toByteArray()), constant(3L), constant(2L)) + fun substring_onBytes_positionPastLast_returnsEmptyByteString() { + val expr = substring(constant("abc".toByteArray()), constant(3L), constant(2L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromByteString(ByteString.EMPTY)), - "substr(blob(abc), 3, 2)" + "substring(blob(abc), 3, 2)" ) } @Test - fun substr_onBytes_positionOnZero_startsFromZero() { - val expr = substr(blob("abc".toByteArray()), constant(0L), constant(6L)) + fun substring_onBytes_positionOnZero_startsFromZero() { + val expr = substring(constant("abc".toByteArray()), constant(0L), constant(6L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromBytes("abc".toByteArray())), - "substr(blob(abc), 0, 6)" + "substring(blob(abc), 0, 6)" ) } @Test - fun substr_onBytes_negativePosition_startsFromLast() { - val expr = substr(blob("abc".toByteArray()), constant(-1L), constant(1L)) + fun substring_onBytes_negativePosition_startsFromLast() { + val expr = substring(constant("abc".toByteArray()), constant(-1L), constant(1L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromBytes("c".toByteArray())), - "substr(blob(abc), -1, 1)" + "substring(blob(abc), -1, 1)" ) } @Test - fun substr_onBytes_oversizedNegativePosition_startsFromZero() { - val expr = substr(blob("abc".toByteArray()), constant(-Long.MAX_VALUE), constant(3L)) + fun substring_onBytes_oversizedNegativePosition_startsFromZero() { + val expr = substring(constant("abc".toByteArray()), constant(-Long.MAX_VALUE), constant(3L)) assertEvaluatesTo( evaluate(expr), encodeValue(com.google.firebase.firestore.Blob.fromBytes("abc".toByteArray())), - "substr(blob(abc), -Long.MAX_VALUE, 3)" + "substring(blob(abc), -Long.MAX_VALUE, 3)" ) } @Test - fun substr_unknownValueType_returnsError() { - val expr = substr(constant(20L), constant(4L), constant(1L)) - assertEvaluatesToError(evaluate(expr), "substr on non-string/blob") + fun substring_unknownValueType_returnsError() { + val expr = substring(constant(20L), constant(4L), constant(1L)) + assertEvaluatesToError(evaluate(expr), "substring on non-string/blob") } @Test - fun substr_unknownPositionType_returnsError() { - val expr = substr(constant("abc"), constant("foo"), constant(1L)) - assertEvaluatesToError(evaluate(expr), "substr with non-integer position") + fun substring_unknownPositionType_returnsError() { + val expr = substring(constant("abc"), constant("foo"), constant(1L)) + assertEvaluatesToError(evaluate(expr), "substring with non-integer position") } @Test - fun substr_unknownLengthType_returnsError() { - val expr = substr(constant("abc"), constant(1L), constant("foo")) - assertEvaluatesToError(evaluate(expr), "substr with non-integer length") + fun substring_unknownLengthType_returnsError() { + val expr = substring(constant("abc"), constant(1L), constant("foo")) + assertEvaluatesToError(evaluate(expr), "substring with non-integer length") } } diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/TimestampTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/TimestampTests.kt index ec39dffce25..fadd17bc879 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/TimestampTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/TimestampTests.kt @@ -16,15 +16,15 @@ package com.google.firebase.firestore.pipeline import com.google.firebase.Timestamp import com.google.firebase.firestore.model.Values.encodeValue -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.nullValue // For null constant -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampAdd -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixMicros -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixMillis -import com.google.firebase.firestore.pipeline.Expr.Companion.timestampToUnixSeconds -import com.google.firebase.firestore.pipeline.Expr.Companion.unixMicrosToTimestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.unixMillisToTimestamp -import com.google.firebase.firestore.pipeline.Expr.Companion.unixSecondsToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.nullValue // For null constant +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampAdd +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixMicros +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixMillis +import com.google.firebase.firestore.pipeline.Expression.Companion.timestampToUnixSeconds +import com.google.firebase.firestore.pipeline.Expression.Companion.unixMicrosToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.unixMillisToTimestamp +import com.google.firebase.firestore.pipeline.Expression.Companion.unixSecondsToTimestamp import org.junit.Test import org.junit.runner.RunWith import org.robolectric.RobolectricTestRunner diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/UnicodeTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/UnicodeTests.kt index aa5cf98a092..eee42e83bbb 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/UnicodeTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/UnicodeTests.kt @@ -17,12 +17,11 @@ package com.google.firebase.firestore.pipeline import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.field import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -59,8 +58,8 @@ internal class UnicodeTests { .collection("users") // C++ uses DatabaseSource, "users" collection matches doc paths .where( and( - field("str").lte(constant("🄟")), - field("str").gte(constant("P")), + field("str").lessThanOrEqual(constant("🄟")), + field("str").greaterThanOrEqual(constant("P")), ) ) .sort(field("str").ascending()) diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/WhereTests.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/WhereTests.kt index 6fe3196a061..e07e4771e38 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/WhereTests.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/WhereTests.kt @@ -18,18 +18,17 @@ import com.google.common.truth.Truth.assertThat import com.google.firebase.firestore.RealtimePipelineSource import com.google.firebase.firestore.TestUtil import com.google.firebase.firestore.model.MutableDocument -import com.google.firebase.firestore.pipeline.Expr.Companion.and -import com.google.firebase.firestore.pipeline.Expr.Companion.array -import com.google.firebase.firestore.pipeline.Expr.Companion.constant -import com.google.firebase.firestore.pipeline.Expr.Companion.eqAny -import com.google.firebase.firestore.pipeline.Expr.Companion.exists -import com.google.firebase.firestore.pipeline.Expr.Companion.field -import com.google.firebase.firestore.pipeline.Expr.Companion.not -import com.google.firebase.firestore.pipeline.Expr.Companion.or -import com.google.firebase.firestore.pipeline.Expr.Companion.xor +import com.google.firebase.firestore.pipeline.Expression.Companion.and +import com.google.firebase.firestore.pipeline.Expression.Companion.array +import com.google.firebase.firestore.pipeline.Expression.Companion.constant +import com.google.firebase.firestore.pipeline.Expression.Companion.equalAny +import com.google.firebase.firestore.pipeline.Expression.Companion.exists +import com.google.firebase.firestore.pipeline.Expression.Companion.field +import com.google.firebase.firestore.pipeline.Expression.Companion.not +import com.google.firebase.firestore.pipeline.Expression.Companion.or +import com.google.firebase.firestore.pipeline.Expression.Companion.xor import com.google.firebase.firestore.runPipeline import com.google.firebase.firestore.testutil.TestUtilKtx.doc -import kotlinx.coroutines.flow.toList import kotlinx.coroutines.runBlocking import org.junit.Test import org.junit.runner.RunWith @@ -44,7 +43,9 @@ internal class WhereTests { fun `empty database returns no results`(): Unit = runBlocking { val documents = emptyList() val pipeline = - RealtimePipelineSource(TestUtil.firestore()).collection("users").where(field("age").gte(10L)) + RealtimePipelineSource(TestUtil.firestore()) + .collection("users") + .where(field("age").greaterThanOrEqual(10L)) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).isEmpty() @@ -62,7 +63,7 @@ internal class WhereTests { val pipeline = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(and(field("age").gte(10.0), field("age").gte(20.0))) + .where(and(field("age").greaterThanOrEqual(10.0), field("age").greaterThanOrEqual(20.0))) // age >= 10.0 AND age >= 20.0 => age >= 20.0 // Matches: doc1 (75.5), doc2 (25.0), doc3 (100.0) val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() @@ -77,12 +78,14 @@ internal class WhereTests { val documents = listOf(doc1, doc2, doc3) val pipeline1 = - RealtimePipelineSource(TestUtil.firestore()).collection("users").where(field("age").eq(25.0)) + RealtimePipelineSource(TestUtil.firestore()) + .collection("users") + .where(field("age").equal(25.0)) val pipeline2 = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(constant(25.0).eq(field("age"))) + .where(constant(25.0).equal(field("age"))) val result1 = runPipeline(pipeline1, listOf(*documents.toTypedArray())).toList() val result2 = runPipeline(pipeline2, listOf(*documents.toTypedArray())).toList() @@ -101,12 +104,12 @@ internal class WhereTests { val pipeline1 = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(and(field("age").gt(10.0), field("age").lt(70.0))) + .where(and(field("age").greaterThan(10.0), field("age").lessThan(70.0))) val pipeline2 = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(and(field("age").lt(70.0), field("age").gt(10.0))) + .where(and(field("age").lessThan(70.0), field("age").greaterThan(10.0))) val result1 = runPipeline(pipeline1, listOf(*documents.toTypedArray())).toList() val result2 = runPipeline(pipeline2, listOf(*documents.toTypedArray())).toList() @@ -125,12 +128,12 @@ internal class WhereTests { val pipeline1 = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(or(field("age").lt(10.0), field("age").gt(80.0))) + .where(or(field("age").lessThan(10.0), field("age").greaterThan(80.0))) val pipeline2 = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(or(field("age").gt(80.0), field("age").lt(10.0))) + .where(or(field("age").greaterThan(80.0), field("age").lessThan(10.0))) val result1 = runPipeline(pipeline1, listOf(*documents.toTypedArray())).toList() val result2 = runPipeline(pipeline2, listOf(*documents.toTypedArray())).toList() @@ -150,12 +153,12 @@ internal class WhereTests { val pipeline1 = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(field("name").eqAny(values)) + .where(field("name").equalAny(values)) val pipeline2 = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(eqAny(field("name"), array(values))) + .where(equalAny(field("name"), array(values))) val result1 = runPipeline(pipeline1, listOf(*documents.toTypedArray())).toList() val result2 = runPipeline(pipeline2, listOf(*documents.toTypedArray())).toList() @@ -176,8 +179,8 @@ internal class WhereTests { val pipeline = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(field("age").gte(10.0)) - .where(field("age").gte(20.0)) + .where(field("age").greaterThanOrEqual(10.0)) + .where(field("age").greaterThanOrEqual(20.0)) // age >= 10.0 THEN age >= 20.0 => age >= 20.0 // Matches: doc1 (75.5), doc2 (25.0), doc3 (100.0) @@ -197,8 +200,8 @@ internal class WhereTests { val pipeline = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(field("age").eq(75L)) - .where(field("height").eq(55L)) // 55L will also match 55.0 + .where(field("age").equal(75L)) + .where(field("height").equal(55L)) // 55L will also match 55.0 val result = runPipeline(pipeline, listOf(*documents.toTypedArray())).toList() assertThat(result).containsExactly(doc3) @@ -216,8 +219,8 @@ internal class WhereTests { val pipeline = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(field("age").gt(50L)) - .where(field("height").lt(75L)) + .where(field("age").greaterThan(50L)) + .where(field("height").lessThan(75L)) // age > 50 AND height < 75 // doc1: 75 > 50 (T) AND 60 < 75 (T) -> True @@ -293,8 +296,8 @@ internal class WhereTests { val pipeline = RealtimePipelineSource(TestUtil.firestore()) .collection("users") - .where(field("age").eq(75L)) - .where(field("height").gt(45L)) + .where(field("age").equal(75L)) + .where(field("height").greaterThan(45L)) .where(field("last").regexMatch(".*er$")) // ends with 'er' // age == 75 AND height > 45 AND last ends with 'er' @@ -563,8 +566,8 @@ internal class WhereTests { val doc3 = doc("users/c", 1000, mapOf("a" to 2L, "b" to 2L)) val documents = listOf(doc1, doc2, doc3) - val equalityArgument1 = field("a").eq(1L) - val equalityArgument2 = field("b").eq(2L) + val equalityArgument1 = field("a").equal(1L) + val equalityArgument2 = field("b").equal(2L) // Combined AND val pipelineAnd1 = diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/testUtil.kt b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/testUtil.kt index edf9437c3f9..911a9ef2128 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/testUtil.kt +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/pipeline/testUtil.kt @@ -34,9 +34,9 @@ internal val EVALUATION_CONTEXT: EvaluationContext = RealtimePipeline(null, RemoteSerializer(FAKE_DATABASE_ID), FAKE_USER_DATA_READER, emptyList()) ) -internal fun evaluate(expr: Expr): EvaluateResult = evaluate(expr, EMPTY_DOC) +internal fun evaluate(expr: Expression): EvaluateResult = evaluate(expr, EMPTY_DOC) -internal fun evaluate(expr: Expr, doc: MutableDocument): EvaluateResult { +internal fun evaluate(expr: Expression, doc: MutableDocument): EvaluateResult { val function = expr.evaluateFunction(EVALUATION_CONTEXT) return function(doc) } diff --git a/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/SpecTestCase.java b/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/SpecTestCase.java index 3b5daa088c9..39652b04e14 100644 --- a/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/SpecTestCase.java +++ b/firebase-firestore/src/test/java/com/google/firebase/firestore/spec/SpecTestCase.java @@ -1089,11 +1089,11 @@ private void validateExpectedSnapshotEvents(@Nullable JSONArray expectedEventsJs if (usePipelineMode) { return leftQuery .toRealtimePipeline(db, new UserDataReader(databaseInfo.getDatabaseId())) - .canonicalId() + .toString() .compareTo( rightQuery .toRealtimePipeline(db, new UserDataReader(databaseInfo.getDatabaseId())) - .canonicalId()); + .toString()); } return leftQuery.getCanonicalId().compareTo(rightQuery.getCanonicalId());