"owner != null",
"utils.isContractAnnotation(annotation)"
})
protected ContractAnnotationModel createContractModel(Element parent,
AnnotationMirror annotation, boolean primary, ClassName owner) {
ContractAnnotationModel model = createBlankContractModel(
parent, annotation, primary, owner);
List<Long> lineNumbers = null;
if (rootLineNumberIterator == null) {
lineNumbers = getLineNumbers(parent, annotation);
}
AnnotationValue lastAnnotationValue = null;
for (AnnotationValue annotationValue :
annotation.getElementValues().values()) {
@SuppressWarnings("unchecked")
List<? extends AnnotationValue> values =
(List<? extends AnnotationValue>) annotationValue.getValue();
Iterator<? extends AnnotationValue> iterValue = values.iterator();
Iterator<Long> iterLineNumber;
if (rootLineNumberIterator != null) {
iterLineNumber = rootLineNumberIterator;
} else {
iterLineNumber = lineNumbers.iterator();
}
while (iterValue.hasNext()) {
String value = (String) iterValue.next().getValue();
Long lineNumber =
iterLineNumber.hasNext() ? iterLineNumber.next() : null;
model.addValue(value, lineNumber);
}
lastAnnotationValue = annotationValue;
}
if (model.getValues().isEmpty()) {
diagnosticManager.warning("No contracts specified in annotation.",
null, 0, 0, 0,
parent, annotation, lastAnnotationValue);
return null;
}
AnnotationSourceInfo sourceInfo =
new AnnotationSourceInfo(parent, annotation, lastAnnotationValue,
model.getValues());
model.setSourceInfo(sourceInfo);
return model;
}