public final class AttributeUtil extends Object
AstAttribute
.Modifier and Type | Method and Description |
---|---|
static boolean |
checkFieldType(DmdlSemantics environment,
PropertyDeclaration declaration,
AstAttribute attribute,
BasicTypeKind... types)
Checks field type and report diagnostics.
|
static boolean |
checkPresent(DmdlSemantics environment,
AstNode targetNode,
String targetLabel,
String value)
Checks which string is not null and report diagnostics.
|
static boolean |
checkRange(DmdlSemantics environment,
AstNode targetNode,
String targetLabel,
BigInteger value,
Long minimum,
Long maximum)
Checks integer range and report diagnostics.
|
static Map<String,AstAttributeElement> |
getElementMap(AstAttribute attribute)
Extract the attributes into (name, element) pairs.
|
static boolean |
hasFieldType(PropertyDeclaration declaration,
BasicTypeKind... candidates)
Returns whether or not the given field has one of the given types.
|
static List<Diagnostic> |
reportInvalidElements(AstAttribute attribute,
Collection<? extends AstAttributeElement> elements)
Returns erroneous diagnostics for the undefined
attribut elements . |
static AstLiteral |
takeLiteral(DmdlSemantics environment,
AstAttribute attribute,
Map<String,AstAttributeElement> elements,
String elementName,
LiteralKind literalKind,
boolean mandatory)
Removes
AstAttributeElement from elements and extracts string value from it. |
static String |
takeString(DmdlSemantics environment,
AstAttribute attribute,
Map<String,AstAttributeElement> elements,
String elementName,
boolean mandatory)
Removes
AstAttributeElement from elements and extracts string value from it. |
public static Map<String,AstAttributeElement> getElementMap(AstAttribute attribute)
The result map can be modified in user programs.
attribute
- the target attributeIllegalArgumentException
- if some parameters were null
public static List<Diagnostic> reportInvalidElements(AstAttribute attribute, Collection<? extends AstAttributeElement> elements)
attribut elements
.attribute
- the elements' ownerelements
- the invalid elementsIllegalArgumentException
- if some parameters were null
public static AstLiteral takeLiteral(DmdlSemantics environment, AstAttribute attribute, Map<String,AstAttributeElement> elements, String elementName, LiteralKind literalKind, boolean mandatory)
AstAttributeElement
from elements
and extracts string value from it.
If the element is not a string literal, this reports error into the environment
.environment
- current environmentattribute
- target attributeelements
- elements in target attributeelementName
- target element nameliteralKind
- target element kindmandatory
- true
for mandatory element (report error if the element is not in map)null
if is not defined or not a valid literalIllegalArgumentException
- if some parameters were null
public static String takeString(DmdlSemantics environment, AstAttribute attribute, Map<String,AstAttributeElement> elements, String elementName, boolean mandatory)
AstAttributeElement
from elements
and extracts string value from it.
If the element is not a string literal, this reports error into the environment
.environment
- current environmentattribute
- target attributeelements
- elements in target attributeelementName
- target element namemandatory
- true
for mandatory element (report error if the element is not in map)null
if is not defined or not a stringIllegalArgumentException
- if some parameters were null
public static boolean hasFieldType(PropertyDeclaration declaration, BasicTypeKind... candidates)
declaration
- the target propertycandidates
- the type candidatestrue
if the property has a type, otherwise false
public static boolean checkFieldType(DmdlSemantics environment, PropertyDeclaration declaration, AstAttribute attribute, BasicTypeKind... types)
environment
- the current environmentdeclaration
- the target declarationattribute
- the target attributetypes
- expected typestrue
if check is successfully completed, otherwise false
public static boolean checkPresent(DmdlSemantics environment, AstNode targetNode, String targetLabel, String value)
environment
- the current environmenttargetNode
- the target nodetargetLabel
- the target labelvalue
- the target valuetrue
if check is successfully completed, otherwise false
public static boolean checkRange(DmdlSemantics environment, AstNode targetNode, String targetLabel, BigInteger value, Long minimum, Long maximum)
environment
- the current environmenttargetNode
- the target nodetargetLabel
- the target labelvalue
- the target valueminimum
- the minimum value (inclusive), or null
to unlimitedmaximum
- the maximum value (inclusive), or null
to unlimitedtrue
if check is successfully completed, otherwise false
Copyright © 2011–2019 Asakusa Framework Team. All rights reserved.