001/*
002 * Copyright 2002-2017 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.support;
018
019import java.io.Serializable;
020
021/**
022 * Simple serializable class that serves as a {@code null} replacement
023 * for cache stores which otherwise do not support {@code null} values.
024 *
025 * @author Juergen Hoeller
026 * @since 4.2.2
027 * @see AbstractValueAdaptingCache
028 */
029public final class NullValue implements Serializable {
030
031        /**
032         * The canonical representation of a {@code null} replacement, as used by the
033         * default implementation of {@link AbstractValueAdaptingCache#toStoreValue}/
034         * {@link AbstractValueAdaptingCache#fromStoreValue}.
035         * @since 4.3.10
036         */
037        public static final Object INSTANCE = new NullValue();
038
039        private static final long serialVersionUID = 1L;
040
041
042        private NullValue() {
043        }
044
045        private Object readResolve() {
046                return INSTANCE;
047        }
048
049}