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 'cacheable' operation.
021 *
022 * @author Costin Leau
023 * @author Phillip Webb
024 * @author Marcin Kamionowski
025 * @since 3.1
026 */
027public class CacheableOperation extends CacheOperation {
028
029        private final String unless;
030
031        private final boolean sync;
032
033
034        /**
035         * @since 4.3
036         */
037        public CacheableOperation(CacheableOperation.Builder b) {
038                super(b);
039                this.unless = b.unless;
040                this.sync = b.sync;
041        }
042
043
044        public String getUnless() {
045                return this.unless;
046        }
047
048        public boolean isSync() {
049                return this.sync;
050        }
051
052
053        /**
054         * @since 4.3
055         */
056        public static class Builder extends CacheOperation.Builder {
057
058                private String unless;
059
060                private boolean sync;
061
062                public void setUnless(String unless) {
063                        this.unless = unless;
064                }
065
066                public void setSync(boolean sync) {
067                        this.sync = sync;
068                }
069
070                @Override
071                protected StringBuilder getOperationDescription() {
072                        StringBuilder sb = super.getOperationDescription();
073                        sb.append(" | unless='");
074                        sb.append(this.unless);
075                        sb.append("'");
076                        sb.append(" | sync='");
077                        sb.append(this.sync);
078                        sb.append("'");
079                        return sb;
080                }
081
082                @Override
083                public CacheableOperation build() {
084                        return new CacheableOperation(this);
085                }
086        }
087
088}