public abstract class AbstractReadAccessor extends AbstractAddon implements IReadAccessor
IReadAccessor.Standalone
Constructor and Description |
---|
AbstractReadAccessor() |
Modifier and Type | Method and Description |
---|---|
protected Object |
castToExpected(Object ret,
Class<?> expectedType,
Class<?> expectedGenericType)
Utility method allowing to cast result to what's expected.
|
AbstractReadAccessor |
clone()
Clones the Addon.
|
abstract <G,C extends Collection<G>> |
compileCollection(ICompilationContext ctxt,
Class<C> expectedType,
Class<G> expectedGenericType)
Implementation to handle case when expected result is a Collection.
|
void |
compileRead(ICompilationContext ctxt)
Compiles this accessor to retrieve a value or a Collection, with no constraint.
|
void |
compileRead(ICompilationContext ctxt,
Class<?> expectedType)
Compiles this accessor to retrieve a value or a Collection, for witch generic type should be automatically detected if possible.
|
<G,C extends Collection<G>> |
compileRead(ICompilationContext ctxt,
Class<C> expectedType,
Class<G> expectedGenericType)
Compiles this accessor to retrieve a collection, for witch generic type should be automatically detected if not provided and possible.
|
void |
compileRead(ICompilationContext ctxt,
IAccessor accessor)
Compiles this accessor to retrieve a value or a Collection, in order to conform to what the provided one awaits for.
|
abstract void |
compileValue(ICompilationContext ctxt,
Class<?> expectedType)
Implementation to handle case when expected result is a single value.
|
Object |
get(IExecutionContext ctxt)
This method handles in / out logging and redirects to
internalGet(IExecutionContext) for specific implementation. |
Class<?>[] |
getGenericTypes(IContext ctxt)
By default, creates a 1 cell array with
IAccessor.getGenericCollectionType(IContext) return value if any,
or null if no value. |
protected abstract Object |
internalGet(IExecutionContext ctxt)
Specific addon implementation must be here.
|
boolean |
isConstantValue()
Default implementation returns "false".
|
boolean |
isShouldBeWrappedToConstantValue()
Default implementation returns
isConstantValue() && ! |
static boolean |
isShouldNotCache(ICompilationContext ctxt,
AddonInfo info)
For optimization purpose, checks if results should be effectively cached.
|
getInternalCacheIdentifier, isCacheUsed, isInternalCacheIdentifierNeeded, optimize, resetCachedData, setInternalCacheIdentifier, toString, wasRegistered
getDebugInfo, getDescription, getName, setDebugInfo, setDescription, setName
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getEstimatedReadCost, isShouldIterate
getGenericCollectionType, getType
getImplementationId, getInternalCacheIdentifier, isCacheUsed, isInternalCacheIdentifierNeeded, optimize, resetCachedData, setInternalCacheIdentifier, wasRegistered
getDebugInfo, getDescription, getName, setDebugInfo, setDescription, setName
public void compileRead(ICompilationContext ctxt) throws MRuleValidationException
IReadAccessor
compileRead
in interface IReadAccessor
ctxt
- Compilation context.MRuleValidationException
- if validation problem detected.public void compileRead(ICompilationContext ctxt, IAccessor accessor) throws MRuleValidationException
IReadAccessor
compileRead
in interface IReadAccessor
ctxt
- Compilation context.accessor
- Compilation base.MRuleValidationException
- if validation problem detected.public void compileRead(ICompilationContext ctxt, Class<?> expectedType) throws MRuleValidationException
IReadAccessor
compileRead
in interface IReadAccessor
ctxt
- Compilation context.expectedType
- If any type is expected. Null if none.MRuleValidationException
- if validation problem detected.public <G,C extends Collection<G>> void compileRead(ICompilationContext ctxt, Class<C> expectedType, Class<G> expectedGenericType) throws MRuleValidationException
IReadAccessor
compileRead
in interface IReadAccessor
ctxt
- Compilation context.expectedType
- If any specific implem is expected for the collection. Null (or "Collection.class") if none.expectedGenericType
- If any generic type is expected for the collection. Null if none.MRuleValidationException
- if validation problem detected.public abstract void compileValue(ICompilationContext ctxt, Class<?> expectedType) throws MRuleValidationException
MRuleValidationException
public abstract <G,C extends Collection<G>> void compileCollection(ICompilationContext ctxt, Class<C> expectedType, Class<G> expectedGenericType) throws MRuleValidationException
MRuleValidationException
public Object get(IExecutionContext ctxt) throws MAccessorException
internalGet(IExecutionContext)
for specific implementation.get
in interface IReadAccessor
ctxt
- Compilation context.MAccessorException
protected abstract Object internalGet(IExecutionContext ctxt) throws MAccessorException
MAccessorException
protected Object castToExpected(Object ret, Class<?> expectedType, Class<?> expectedGenericType) throws MAccessorException
MAccessorException
public static boolean isShouldNotCache(ICompilationContext ctxt, AddonInfo info)
public boolean isConstantValue()
isConstantValue
in interface IReadAccessor
public boolean isShouldBeWrappedToConstantValue()
isConstantValue()
&& ! IReadAccessor.isShouldIterate()
.isShouldBeWrappedToConstantValue
in interface IReadAccessor
public AbstractReadAccessor clone()
IAddon
clone
in interface IAccessor
clone
in interface IReadAccessor
clone
in interface IAddon
clone
in interface IMRulesObject
clone
in class AbstractAddon
public Class<?>[] getGenericTypes(IContext ctxt) throws MAccessorException
IAccessor.getGenericCollectionType(IContext)
return value if any,
or null if no value.getGenericTypes
in interface IAccessor
MAccessorException