public abstract class BaseTraitStyle<T extends Trait> extends Object
Handles caching and excluding names and types.
Modifier and Type | Field and Description |
---|---|
protected LogUtils.Log |
mLog |
Modifier | Constructor and Description |
---|---|
protected |
BaseTraitStyle(BaseTraitStyleConfig config) |
Modifier and Type | Method and Description |
---|---|
protected void |
cacheTraits(String type,
Map<String,T> traits) |
void |
clearCache()
SPI for tools such as FakeReplace that
need to clear the cache.
|
protected Map<String,T> |
getCachedTraits(String type) |
protected Map<String,T> |
getTraits(String type) |
protected abstract Map<String,T> |
getUncachedTraits(String type) |
protected boolean |
isExcluded(Class<?> classToExclude,
String name,
Class<?> returnType)
Whether to exclude the given trait, of the given type, in the given class, when searching
for traits.
|
protected boolean |
isExcludedBaseType(Class<?> classToExclude)
Whether to exclude the given base type when searching up the model inheritance chain.
|
protected boolean |
isExcludedName(String name)
Whether to exclude the given name when searching for traits.
|
protected boolean |
isExcludedReturnType(Class<?> clazz)
Whether to exclude the given return type when searching for traits.
|
protected final LogUtils.Log mLog
protected BaseTraitStyle(BaseTraitStyleConfig config)
public void clearCache()
This does not affect immutability, as our external behaviour is unchanged (we will just be a little slower the next time we are called, while we re-cache).
protected final boolean isExcluded(Class<?> classToExclude, String name, Class<?> returnType)
This can be useful when the convention or base class define traits that are framework-specific, and should be filtered out from 'real' business model traits.
By default, calls isExcludedReturnType
and isExcludedName
and
returns true if either of them return true. Returns false otherwise.
protected boolean isExcludedBaseType(Class<?> classToExclude)
This can be useful when the base types define traits that are framework-specific, and should be filtered out from 'real' business model traits.
By default, excludes any base types from BaseTraitStyleConfig.setExcludeBaseType
.
protected boolean isExcludedReturnType(Class<?> clazz)
This can be useful when the convention or base class define traits that are framework-specific, and should be filtered out from 'real' business model traits.
By default, excludes any return types from
BaseTraitStyleConfig.setExcludeReturnType
.
clazz
- return type to consider for exclusionprotected boolean isExcludedName(String name)
This can be useful when the convention defines traits that are framework-specific (eg.
getClass()
), and should be filtered out from 'real' business model traits.
By default, excludes any names from BaseTraitStyleConfig.setExcludeName
.
name
- to consider for exclusionCopyright © 2015. All Rights Reserved.