Package org.hl7.cql.model
Class GenericClassSignatureParser
- java.lang.Object
-
- org.hl7.cql.model.GenericClassSignatureParser
-
public class GenericClassSignatureParser extends java.lang.ObjectThe GenericClassSignatureParser is a convenience class for the parsing of generic signature and the creation of the corresponding CQL DataTypes, namely, GenericClassType and GenericClassProfileType. The former is used to capture the declaration of a GenericClass such as List<T>. The latter is used to capture a new type such as 'IntegerList' formed by binding types to generic parameters such as List<Integer>.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.CharSequenceCLOSE_BRACKETstatic java.lang.StringEXTENDSstatic java.lang.CharSequenceOPEN_BRACKET
-
Constructor Summary
Constructors Constructor Description GenericClassSignatureParser(java.lang.String genericSignature, java.lang.String baseType, java.lang.String boundGenericTypeName, java.util.Map<java.lang.String,DataType> resolvedTypes)GenericClassSignatureParser(java.lang.String genericSignature, java.util.Map<java.lang.String,DataType> resolvedTypes)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetBaseType()java.lang.StringgetBoundGenericTypeName()java.lang.StringgetGenericSignature()protected DataTypehandleBoundType(java.lang.String boundGenericSignature)Method resolves bound type if it exists or else creates it and adds it to the resolved type index.protected TypeParameterhandleParameterDeclaration(java.lang.String parameterString)Method handles a generic parameter declaration such as T, or T extends MyType.booleanisValidGenericSignature()Returns true if the generic signature assigned to this object is well-formed.booleanisValidGenericSignature(java.lang.String genericSignature)Returns true if the generic signature passed as an argument is well-formed.ClassTypeparseGenericSignature()Parses a generic type declaration such as Map<K,V>.protected DataTyperesolveTypeName(java.lang.String parameterType)Identifies the data type for the named type.voidsetBaseType(java.lang.String baseType)voidsetBoundGenericTypeName(java.lang.String boundGenericTypeName)voidsetGenericSignature(java.lang.String genericSignature)
-
-
-
Field Detail
-
OPEN_BRACKET
public static final java.lang.CharSequence OPEN_BRACKET
-
CLOSE_BRACKET
public static final java.lang.CharSequence CLOSE_BRACKET
-
EXTENDS
public static final java.lang.String EXTENDS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GenericClassSignatureParser
public GenericClassSignatureParser(java.lang.String genericSignature, java.lang.String baseType, java.lang.String boundGenericTypeName, java.util.Map<java.lang.String,DataType> resolvedTypes)
-
GenericClassSignatureParser
public GenericClassSignatureParser(java.lang.String genericSignature, java.util.Map<java.lang.String,DataType> resolvedTypes)
-
-
Method Detail
-
getGenericSignature
public java.lang.String getGenericSignature()
-
setGenericSignature
public void setGenericSignature(java.lang.String genericSignature)
-
getBaseType
public java.lang.String getBaseType()
-
setBaseType
public void setBaseType(java.lang.String baseType)
-
getBoundGenericTypeName
public java.lang.String getBoundGenericTypeName()
-
setBoundGenericTypeName
public void setBoundGenericTypeName(java.lang.String boundGenericTypeName)
-
parseGenericSignature
public ClassType parseGenericSignature()
Parses a generic type declaration such as Map<K,V>.- Returns:
- Generic class constructed from this definition.
-
handleParameterDeclaration
protected TypeParameter handleParameterDeclaration(java.lang.String parameterString)
Method handles a generic parameter declaration such as T, or T extends MyType.- Parameters:
parameterString-- Returns:
- Type parameter for this parameter for this string declaration.
-
resolveTypeName
protected DataType resolveTypeName(java.lang.String parameterType)
Identifies the data type for the named type. If the argument is null, the return type will be null.- Parameters:
parameterType-- Returns:
- The parameter's type
-
handleBoundType
protected DataType handleBoundType(java.lang.String boundGenericSignature)
Method resolves bound type if it exists or else creates it and adds it to the resolved type index.- Parameters:
boundGenericSignature-- Returns:
- The bound type created or resolved
-
isValidGenericSignature
public boolean isValidGenericSignature()
Returns true if the generic signature assigned to this object is well-formed.- Returns:
- True if the generic signature is valid
-
isValidGenericSignature
public boolean isValidGenericSignature(java.lang.String genericSignature)
Returns true if the generic signature passed as an argument is well-formed.- Parameters:
genericSignature-- Returns:
- True if the generic signature is valid
-
-