001/* 002 * JKNIV, utils - Helper utilities for jdk code. 003 * 004 * Copyright (C) 2017, the original author or authors. 005 * 006 * This library is free software; you can redistribute it and/or 007 * modify it under the terms of the GNU Lesser General Public 008 * License as published by the Free Software Foundation; either 009 * version 2.1 of the License. 010 * 011 * This library is distributed in the hope that it will be useful, 012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 014 * Lesser General Public License for more details. 015 * 016 * You should have received a copy of the GNU Lesser General Public 017 * License along with this library; if not, write to the Free Software Foundation, Inc., 018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 019 */ 020package net.sf.jkniv.cache; 021 022import java.util.Set; 023 024public class NoCache<K, V> implements Cacheable<K, V> 025{ 026 private static final String name = "NoCache"; 027 private static final CachePolicy policy = new TTLCachePolicy(0L); 028 private static final Cacheable<Object,Object> instance = new NoCache<Object,Object>(); 029 030 private NoCache() 031 { 032 } 033 034 @SuppressWarnings("unchecked") 035 public static <K,V> Cacheable<K,V> getInstance() 036 { 037 return (Cacheable<K,V>)instance; 038 } 039 040 @Override 041 public String getName() 042 { 043 return name; 044 } 045 046 @Override 047 public CachePolicy getPolicy() 048 { 049 return policy; 050 } 051 052 @Override 053 public void setPolicy(CachePolicy policy) 054 { 055 } 056 057 @Override 058 public V put(K key, V object) 059 { 060 return null; 061 } 062 063 @Override 064 public V get(K key) 065 { 066 return null; 067 } 068 069 @Override 070 public Cacheable.Entry<V> getEntry(K key) 071 { 072 return null; 073 } 074 075 @Override 076 public Set<java.util.Map.Entry<K, net.sf.jkniv.cache.Cacheable.Entry<V>>> entrySet() 077 { 078 return null; 079 } 080 081 @Override 082 public Cacheable.Entry<V> remove(K key) 083 { 084 return null; 085 } 086 087 @Override 088 public void clear() 089 { 090 } 091 092 @Override 093 public long size() 094 { 095 return 0; 096 } 097 098}