@Test public void testGetValueThrowsCacheExceptionOnAccessingNonSerializableValue() { Object key = new Object() { @Override public String toString() { return "daKey"; } }; Object value = new Object() { @Override public String toString() { return "HOHO!"; } }; Element element = new Element(key, value); try { element.getValue(); fail(); } catch (CacheException e) { assertThat(e.getMessage(), equalTo("The value HOHO! for key daKey is not Serializable. Consider using Element.getObjectValue()")); } }
@Deprecated public final Serializable getValue() throws CacheException { try { return (Serializable) getObjectValue(); } catch (ClassCastException e) { throw new CacheException("The value " + getObjectValue() + " for key " + getObjectKey() + " is not Serializable. Consider using Element.getObjectValue()"); } }
Element implements Serializable, Cloneable { @Deprecated public final Serializable getValue() throws CacheException { try { return (Serializable) getObjectValue(); } catch (ClassCastException e) { throw new CacheException("The value " + getObjectValue() + " for key " + getObjectKey() + " is not Serializable. Consider using Element.getObjectValue()"); } } }
Element implements Serializable, Cloneable { @Deprecated public final Serializable getValue() throws CacheException { try { return (Serializable) getObjectValue(); } catch (ClassCastException e) { throw new CacheException("The value " + getObjectValue() + " for key " + getObjectKey() + " is not Serializable. Consider using Element.getObjectValue()"); } } Element(final Serializable key, final Serializable value, final long version);  Element(final Object key, final Object value, final long version); @Deprecated  Element(final Object key, final Object value, final long version,
                   final long creationTime, final long lastAccessTime, final long nextToLastAccessTime,
                   final long lastUpdateTime, final long hitCount);  Element(final Object key, final Object value, final long version,
                   final long creationTime, final long lastAccessTime,
                   final long lastUpdateTime, final long hitCount);  Element(final Object key, final Object value, final long version, final long creationTime,
            final long lastAccessTime, final long hitCount, final boolean cacheDefaultLifespan,
            final int timeToLive, final int timeToIdle, final long lastUpdateTime);  Element(final Object key, final Object value,
                   final int timeToIdleSeconds, final int timeToLiveSeconds);  Element(final Object key, final Object value, final boolean eternal); @Deprecated  Element(final Object key, final Object value,
                   final Boolean eternal, final Integer timeToIdleSeconds, final Integer timeToLiveSeconds);  Element(final Serializable key, final Serializable value);  Element(final Object key, final Object value); }
Element implements Serializable, Cloneable { @Deprecated public final Serializable getValue() throws CacheException { try { return (Serializable) getObjectValue(); } catch (ClassCastException e) { throw new CacheException("The value " + getObjectValue() + " for key " + getObjectKey() + " is not Serializable. Consider using Element.getObjectValue()"); } } Element(final Serializable key, final Serializable value, final long version);  Element(final Object key, final Object value, final long version); @Deprecated  Element(final Object key, final Object value, final long version,
                   final long creationTime, final long lastAccessTime, final long nextToLastAccessTime,
                   final long lastUpdateTime, final long hitCount);  Element(final Object key, final Object value, final long version,
                   final long creationTime, final long lastAccessTime,
                   final long lastUpdateTime, final long hitCount);  Element(final Object key, final Object value, final long version, final long creationTime,
            final long lastAccessTime, final long hitCount, final boolean cacheDefaultLifespan,
            final int timeToLive, final int timeToIdle, final long lastUpdateTime);  Element(final Object key, final Object value,
                   final int timeToIdleSeconds, final int timeToLiveSeconds);  Element(final Object key, final Object value, final boolean eternal); @Deprecated  Element(final Object key, final Object value,
                   final Boolean eternal, final Integer timeToIdleSeconds, final Integer timeToLiveSeconds);  Element(final Serializable key, final Serializable value);  Element(final Object key, final Object value); @Deprecated final Serializable getKey(); final Object getObjectKey(); @Deprecated final Serializable getValue(); final Object getObjectValue(); @Override final boolean equals(final Object object); void setTimeToLive(final int timeToLiveSeconds); void setTimeToIdle(final int timeToIdleSeconds); @Override final int hashCode(); final void setVersion(final long version); @Deprecated final void setCreateTime(); final long getCreationTime(); final long getLatestOfCreationAndUpdateTime(); final long getVersion(); final long getLastAccessTime(); @Deprecated final long getNextToLastAccessTime(); final long getHitCount(); final void resetAccessStatistics(); final void updateAccessStatistics(); final void updateUpdateStatistics(); @Override final String toString(); @Override final Object clone(); final long getSerializedSize(); final boolean isSerializable(); final boolean isKeySerializable(); long getLastUpdateTime(); boolean isExpired(); boolean isExpired(CacheConfiguration config); long getExpirationTime(); boolean isEternal(); void setEternal(final boolean eternal); boolean isLifespanSet(); int getTimeToLive(); int getTimeToIdle(); boolean usesCacheDefaultLifespan(); }
Element implements Serializable, Cloneable { @Deprecated public final Serializable getValue() throws CacheException { try { return (Serializable) getObjectValue(); } catch (ClassCastException e) { throw new CacheException("The value " + getObjectValue() + " for key " + getObjectKey() + " is not Serializable. Consider using Element.getObjectValue()"); } } Element(final Serializable key, final Serializable value, final long version);  Element(final Object key, final Object value, final long version); @Deprecated  Element(final Object key, final Object value, final long version,
                   final long creationTime, final long lastAccessTime, final long nextToLastAccessTime,
                   final long lastUpdateTime, final long hitCount);  Element(final Object key, final Object value, final long version,
                   final long creationTime, final long lastAccessTime,
                   final long lastUpdateTime, final long hitCount);  Element(final Object key, final Object value, final long version, final long creationTime,
            final long lastAccessTime, final long hitCount, final boolean cacheDefaultLifespan,
            final int timeToLive, final int timeToIdle, final long lastUpdateTime);  Element(final Object key, final Object value,
                   final int timeToIdleSeconds, final int timeToLiveSeconds);  Element(final Object key, final Object value, final boolean eternal); @Deprecated  Element(final Object key, final Object value,
                   final Boolean eternal, final Integer timeToIdleSeconds, final Integer timeToLiveSeconds);  Element(final Serializable key, final Serializable value);  Element(final Object key, final Object value); @Deprecated final Serializable getKey(); final Object getObjectKey(); @Deprecated final Serializable getValue(); final Object getObjectValue(); @Override final boolean equals(final Object object); void setTimeToLive(final int timeToLiveSeconds); void setTimeToIdle(final int timeToIdleSeconds); @Override final int hashCode(); final void setVersion(final long version); @Deprecated final void setCreateTime(); final long getCreationTime(); final long getLatestOfCreationAndUpdateTime(); final long getVersion(); final long getLastAccessTime(); @Deprecated final long getNextToLastAccessTime(); final long getHitCount(); final void resetAccessStatistics(); final void updateAccessStatistics(); final void updateUpdateStatistics(); @Override final String toString(); @Override final Object clone(); final long getSerializedSize(); final boolean isSerializable(); final boolean isKeySerializable(); long getLastUpdateTime(); boolean isExpired(); boolean isExpired(CacheConfiguration config); long getExpirationTime(); boolean isEternal(); void setEternal(final boolean eternal); boolean isLifespanSet(); int getTimeToLive(); int getTimeToIdle(); boolean usesCacheDefaultLifespan();  }