001/*
002 * Copyright 2002-2016 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.cache.interceptor;
018
019/**
020 * Class describing a cache 'put' operation.
021 *
022 * @author Costin Leau
023 * @author Phillip Webb
024 * @author Marcin Kamionowski
025 * @since 3.1
026 */
027public class CachePutOperation extends CacheOperation {
028
029        private final String unless;
030
031
032        /**
033         * @since 4.3
034         */
035        public CachePutOperation(CachePutOperation.Builder b) {
036                super(b);
037                this.unless = b.unless;
038        }
039
040
041        public String getUnless() {
042                return this.unless;
043        }
044
045
046        /**
047         * @since 4.3
048         */
049        public static class Builder extends CacheOperation.Builder {
050
051                private String unless;
052
053                public void setUnless(String unless) {
054                        this.unless = unless;
055                }
056
057                @Override
058                protected StringBuilder getOperationDescription() {
059                        StringBuilder sb = super.getOperationDescription();
060                        sb.append(" | unless='");
061                        sb.append(this.unless);
062                        sb.append("'");
063                        return sb;
064                }
065
066                public CachePutOperation build() {
067                        return new CachePutOperation(this);
068                }
069        }
070
071}