All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.projection.Projections Maven / Gradle / Ivy

There is a newer version: 4.5.4
Show newest version
/*
 * Copyright (c) 2008-2018, Hazelcast, Inc. All Rights Reserved.
 *
 * 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.hazelcast.projection;

import com.hazelcast.projection.impl.IdentityProjection;
import com.hazelcast.projection.impl.MultiAttributeProjection;
import com.hazelcast.projection.impl.SingleAttributeProjection;

/**
 * A utility class to create basic {@link com.hazelcast.projection.Projection} instances.
 *
 * @since 3.8
 */
public final class Projections {

    private Projections() {
    }

    /**
     * Returns a projection that does no transformation.
     * 

* If you use the returned projection in a 3.9 cluster it may cause a serialization exception. * * @since 3.10 */ public static Projection identity() { return (IdentityProjection) IdentityProjection.INSTANCE; } /** * Returns a projection that extracts the value of the given {@code attributePath}. * * @param attributePath single attribute path, path must not be null or empty * @param Output type */ public static Projection singleAttribute(String attributePath) { return new SingleAttributeProjection(attributePath); } /** * Returns a projection that extracts the value of the given {@code attributePaths}. * The attribute values will be returned as an {@code Object[]} array from each projection call. * * @param attributePaths attribute paths, paths must not be null or empty */ public static Projection multiAttribute(String... attributePaths) { return new MultiAttributeProjection(attributePaths); } }