Package com.netflix.discovery.util
Class DeserializerStringCache
- java.lang.Object
-
- com.netflix.discovery.util.DeserializerStringCache
-
- All Implemented Interfaces:
java.util.function.Function<java.lang.String,java.lang.String>
public class DeserializerStringCache extends java.lang.Object implements java.util.function.Function<java.lang.String,java.lang.String>A non-locking alternative toString.intern()andStringCachethat works with Jackson's DeserializationContext. Definitely NOT thread-safe, intended to avoid the costs associated with thread synchronization and short-lived heap allocations (e.g., Strings)
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDeserializerStringCache.CacheScope
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Stringapply(com.fasterxml.jackson.core.JsonParser jp)returns a String read from the JsonParser argument's current position.java.lang.Stringapply(com.fasterxml.jackson.core.JsonParser jp, DeserializerStringCache.CacheScope cacheScope)java.lang.Stringapply(com.fasterxml.jackson.core.JsonParser jp, DeserializerStringCache.CacheScope cacheScope, java.util.function.Supplier<java.lang.String> source)returns a String read from the JsonParser argument's current position.java.lang.Stringapply(com.netflix.discovery.util.DeserializerStringCache.CharBuffer charValue)returns a String that may be interned at app-scope to reduce heap consumptionjava.lang.Stringapply(com.netflix.discovery.util.DeserializerStringCache.CharBuffer charValue, DeserializerStringCache.CacheScope cacheScope)returns a object of type T that may be interned at the specified scope to reduce heap consumptionjava.lang.Stringapply(java.lang.String stringValue)returns a String that may be interned at the app-scope to reduce heap consumptionjava.lang.Stringapply(java.lang.String stringValue, DeserializerStringCache.CacheScope cacheScope)returns a String that may be interned at the given scope to reduce heap consumptionstatic voidclear(com.fasterxml.jackson.databind.DeserializationContext context)clears app-scoped cache entries from the specified DeserializationContextstatic voidclear(com.fasterxml.jackson.databind.DeserializationContext context, DeserializerStringCache.CacheScope scope)clears cache entries in the given scope from the specified DeserializationContext.static voidclear(com.fasterxml.jackson.databind.ObjectReader reader)clears app-scoped cache entries from the specified ObjectReaderstatic voidclear(com.fasterxml.jackson.databind.ObjectReader reader, DeserializerStringCache.CacheScope scope)clears cache entries in the given scope from the specified ObjectReader.static DeserializerStringCachefrom(com.fasterxml.jackson.databind.DeserializationContext context)extracts a DeserializerStringCache from the DeserializationContextstatic com.fasterxml.jackson.databind.ObjectReaderinit(com.fasterxml.jackson.databind.ObjectReader reader)adds a new DeserializerStringCache to the passed-in ObjectReaderstatic com.fasterxml.jackson.databind.ObjectReaderinit(com.fasterxml.jackson.databind.ObjectReader reader, com.fasterxml.jackson.databind.DeserializationContext context)adds an existing DeserializerStringCache from the DeserializationContext to an ObjectReadercom.fasterxml.jackson.databind.ObjectReaderinitReader(com.fasterxml.jackson.databind.ObjectReader reader)intsize()
-
-
-
Method Detail
-
init
public static com.fasterxml.jackson.databind.ObjectReader init(com.fasterxml.jackson.databind.ObjectReader reader)
adds a new DeserializerStringCache to the passed-in ObjectReader- Parameters:
reader-- Returns:
- a wrapped ObjectReader with the string cache attribute
-
init
public static com.fasterxml.jackson.databind.ObjectReader init(com.fasterxml.jackson.databind.ObjectReader reader, com.fasterxml.jackson.databind.DeserializationContext context)adds an existing DeserializerStringCache from the DeserializationContext to an ObjectReader- Parameters:
reader- a new ObjectReadercontext- an existing DeserializationContext containing a DeserializerStringCache- Returns:
- a wrapped ObjectReader with the string cache attribute
-
from
public static DeserializerStringCache from(com.fasterxml.jackson.databind.DeserializationContext context)
extracts a DeserializerStringCache from the DeserializationContext- Parameters:
context- an existing DeserializationContext containing a DeserializerStringCache- Returns:
- a wrapped ObjectReader with the string cache attribute
-
clear
public static void clear(com.fasterxml.jackson.databind.ObjectReader reader)
clears app-scoped cache entries from the specified ObjectReader- Parameters:
reader-
-
clear
public static void clear(com.fasterxml.jackson.databind.ObjectReader reader, DeserializerStringCache.CacheScope scope)clears cache entries in the given scope from the specified ObjectReader. Always clears app-scoped entries.- Parameters:
reader-scope-
-
clear
public static void clear(com.fasterxml.jackson.databind.DeserializationContext context)
clears app-scoped cache entries from the specified DeserializationContext- Parameters:
context-
-
clear
public static void clear(com.fasterxml.jackson.databind.DeserializationContext context, DeserializerStringCache.CacheScope scope)clears cache entries in the given scope from the specified DeserializationContext. Always clears app-scoped entries.- Parameters:
context-scope-
-
initReader
public com.fasterxml.jackson.databind.ObjectReader initReader(com.fasterxml.jackson.databind.ObjectReader reader)
-
apply
public java.lang.String apply(com.fasterxml.jackson.core.JsonParser jp) throws java.io.IOExceptionreturns a String read from the JsonParser argument's current position. The returned value may be interned at the app scope to reduce heap consumption- Parameters:
jp-- Returns:
- a possibly interned String
- Throws:
java.io.IOException
-
apply
public java.lang.String apply(com.fasterxml.jackson.core.JsonParser jp, DeserializerStringCache.CacheScope cacheScope) throws java.io.IOException- Throws:
java.io.IOException
-
apply
public java.lang.String apply(com.fasterxml.jackson.core.JsonParser jp, DeserializerStringCache.CacheScope cacheScope, java.util.function.Supplier<java.lang.String> source) throws java.io.IOExceptionreturns a String read from the JsonParser argument's current position. The returned value may be interned at the given cacheScope to reduce heap consumption- Parameters:
jp-cacheScope-- Returns:
- a possibly interned String
- Throws:
java.io.IOException
-
apply
public java.lang.String apply(com.netflix.discovery.util.DeserializerStringCache.CharBuffer charValue)
returns a String that may be interned at app-scope to reduce heap consumption- Parameters:
charValue-- Returns:
- a possibly interned String
-
apply
public java.lang.String apply(com.netflix.discovery.util.DeserializerStringCache.CharBuffer charValue, DeserializerStringCache.CacheScope cacheScope)returns a object of type T that may be interned at the specified scope to reduce heap consumption- Parameters:
charValue-cacheScope-trabsform-- Returns:
- a possibly interned instance of T
-
apply
public java.lang.String apply(java.lang.String stringValue)
returns a String that may be interned at the app-scope to reduce heap consumption- Specified by:
applyin interfacejava.util.function.Function<java.lang.String,java.lang.String>- Parameters:
stringValue-- Returns:
- a possibly interned String
-
apply
public java.lang.String apply(java.lang.String stringValue, DeserializerStringCache.CacheScope cacheScope)returns a String that may be interned at the given scope to reduce heap consumption- Parameters:
stringValue-cacheScope-- Returns:
- a possibly interned String
-
size
public int size()
-
-