Search in sources :

Example 31 with FieldMask

use of com.google.protobuf.FieldMask in project core-java by SpineEventEngine.

the class QueryFactory method allWithMask.

/**
 * Creates a {@link Query} to read all entity states with the {@link FieldMask}
 * applied to each of the results.
 *
 * <p>Allows to set property paths for a {@link FieldMask}, applied to each of the query
 * results. This processing is performed according to the
 * <a href="https://goo.gl/tW5wIU">FieldMask specs</a>.
 *
 * <p>In case the {@code paths} array contains entries inapplicable to the resulting entity
 * (e.g. a {@code path} references a missing field), such invalid paths
 * are silently ignored.
 *
 * @param entityClass the class of a target entity
 * @param maskPaths   the property paths for the {@code FieldMask} applied
 *                    to each of results
 * @return an instance of {@code Query} formed according to the passed parameters
 */
public Query allWithMask(Class<? extends Message> entityClass, String... maskPaths) {
    final FieldMask fieldMask = FieldMask.newBuilder().addAllPaths(Arrays.asList(maskPaths)).build();
    final Query result = composeQuery(entityClass, null, null, fieldMask);
    return result;
}
Also used : FieldMask(com.google.protobuf.FieldMask)

Aggregations

FieldMask (com.google.protobuf.FieldMask)31 Test (org.junit.Test)22 Any (com.google.protobuf.Any)7 EntityRecord (io.spine.server.entity.EntityRecord)7 Descriptors (com.google.protobuf.Descriptors)5 Message (com.google.protobuf.Message)5 Project (io.spine.test.aggregate.Project)5 LinkedList (java.util.LinkedList)4 EntityFilters (io.spine.client.EntityFilters)3 Project (io.spine.test.storage.Project)3 Matchers.containsString (org.hamcrest.Matchers.containsString)3 ImmutableList (com.google.common.collect.ImmutableList)2 Query (io.spine.client.Query)2 Target (io.spine.client.Target)2 Version (io.spine.core.Version)2 GivenVersion (io.spine.core.given.GivenVersion)2 TenantAwareTest (io.spine.server.tenant.TenantAwareTest)2 TestEntity (io.spine.test.client.TestEntity)2 Customer (io.spine.test.commandservice.customer.Customer)2 CustomerId (io.spine.test.commandservice.customer.CustomerId)2