Package gw.lang.parser.coercers
Class BasePrimitiveCoercer
- java.lang.Object
-
- gw.lang.parser.coercers.BaseCoercer
-
- gw.lang.parser.coercers.StandardCoercer
-
- gw.lang.parser.coercers.BasePrimitiveCoercer
-
- All Implemented Interfaces:
ICoercer,IResolvingCoercer
public class BasePrimitiveCoercer extends StandardCoercer implements IResolvingCoercer
-
-
Field Summary
Fields Modifier and Type Field Description static LockingLazyVar<BasePrimitiveCoercer>BooleanPCoercerstatic LockingLazyVar<BasePrimitiveCoercer>BytePCoercerstatic LockingLazyVar<BasePrimitiveCoercer>CharPCoercerstatic LockingLazyVar<BasePrimitiveCoercer>DoublePCoercerstatic LockingLazyVar<BasePrimitiveCoercer>FloatPCoercerstatic LockingLazyVar<BasePrimitiveCoercer>IntPCoercerstatic LockingLazyVar<BasePrimitiveCoercer>LongPCoercerstatic LockingLazyVar<BasePrimitiveCoercer>ShortPCoercer-
Fields inherited from interface gw.lang.parser.ICoercer
MAX_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description BasePrimitiveCoercer(ICoercer nonPrimitiveCoercer, IType primitiveType, IType nonPrimitiveType)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ObjectcoerceValue(IType typeToCoerceTo, Object value)intgetPriority(IType to, IType from)static intgetPriorityOf(IType to, IType from)booleanhandlesNull()static intlosesInformation(IType from, IType to)ITyperesolveType(IType target, IType source)This method should produce a more appropriately parameterized type for the given target type for this coercion.-
Methods inherited from class gw.lang.parser.coercers.StandardCoercer
isCoercingDimensionWithSameType, isExplicitCoercion
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface gw.lang.parser.ICoercer
isExplicitCoercion
-
-
-
-
Field Detail
-
DoublePCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> DoublePCoercer
-
FloatPCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> FloatPCoercer
-
BooleanPCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> BooleanPCoercer
-
BytePCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> BytePCoercer
-
ShortPCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> ShortPCoercer
-
CharPCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> CharPCoercer
-
IntPCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> IntPCoercer
-
LongPCoercer
public static final LockingLazyVar<BasePrimitiveCoercer> LongPCoercer
-
-
Method Detail
-
coerceValue
public final Object coerceValue(IType typeToCoerceTo, Object value)
- Specified by:
coerceValuein interfaceICoercer
-
handlesNull
public boolean handlesNull()
- Specified by:
handlesNullin interfaceICoercer- Overrides:
handlesNullin classStandardCoercer- Returns:
- true if this coercer knows how to handle the null value.
-
resolveType
public IType resolveType(IType target, IType source)
Description copied from interface:IResolvingCoercerThis method should produce a more appropriately parameterized type for the given target type for this coercion. This allows a coercion to communicate type information through the coercion process. An example is the MetaType-to-Class coercion. MetaType
should be interpreted as Class from a type inference perspective, so this give the coercer a chance to let the compiler know so. If no more appropriate inference type exists, this method should return the source type.
- Specified by:
resolveTypein interfaceIResolvingCoercer- Parameters:
target- type- Returns:
- a possibly more appropriately parameterized type or the source type if not
-
getPriority
public int getPriority(IType to, IType from)
- Specified by:
getPriorityin interfaceICoercer- Overrides:
getPriorityin classStandardCoercer- Returns:
- a value between 0 and MAX_PRIORITY, inclusive that indicates the priority of this coercer when resolving overloaded methods. Typically a coercer should return 0, but coercers that have a high affinity between the target and coerced type, such as primitives, can have higher priorities.
-
-