001/*
002 * Copyright 2002-2013 the original author or authors.
003 * 
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
005 * the License. You may obtain a copy of the License at
006 * 
007 * https://www.apache.org/licenses/LICENSE-2.0
008 * 
009 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
010 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
011 * specific language governing permissions and limitations under the License.
012 */
013package org.springframework.batch.item.data;
014
015import org.springframework.batch.item.SpELItemKeyMapper;
016import org.springframework.util.Assert;
017
018/**
019 * A convenient {@link GemfireItemWriter} implementation that uses a {@link SpELItemKeyMapper}
020 * 
021 * @author David Turanski
022 * @since 2.2
023 */
024public class SpELMappingGemfireItemWriter<K, V> extends GemfireItemWriter<K, V> {
025        /**
026         * A constructor that accepts a SpEL expression used to derive the key
027         * @param keyExpression
028         */
029        SpELMappingGemfireItemWriter(String keyExpression) {
030                super();
031                Assert.hasText(keyExpression, "a valid keyExpression is required.");
032                setItemKeyMapper(new SpELItemKeyMapper<K, V>(keyExpression));
033        }
034}