modules/ballerina-core/src/main/java/org/ballerinalang/util/semantics/SemanticAnalyzer.java
private void populateDefaultValues(AnnotationAttachment annotation, AnnotationDef annotationDef) {
        Map<String, AnnotationAttributeValue> attributeValPairs = annotation.getAttributeNameValuePairs();
        for (AnnotationAttributeDef attributeDef : annotationDef.getAttributeDefs()) {
            String attributeName = attributeDef.getName();
            
            // if the current attribute is not defined in the annotation attachment, populate it with default value
            if (!attributeValPairs.containsKey(attributeName)) {
                BasicLiteral defaultValue = attributeDef.getAttributeValue();
                if (defaultValue != null) {
                    annotation.addAttributeNameValuePair(attributeName,
                        new AnnotationAttributeValue(defaultValue.getBValue(), defaultValue.getTypeName(), null));
                }
                continue;
            }

            // If the annotation attachment contains the current attribute, and if the value is another 
            // annotationAttachment, then recursively populate its default values
            AnnotationAttributeValue attributeValue = attributeValPairs.get(attributeName);
            SimpleTypeName valueType = attributeValue.getType();
            if (valueType.isArrayType()) {
                AnnotationAttributeValue[] valuesArray = attributeValue.getValueArray();
                for (AnnotationAttributeValue value : valuesArray) {
                    AnnotationAttachment annotationTypeVal = value.getAnnotationValue();

                    // skip if the array element is not an annotation
                    if (annotationTypeVal == null) {
                        continue;
                    }

                    SimpleTypeName attributeType = attributeDef.getTypeName();
                    BLangSymbol attributeTypeSymbol = annotationDef.resolve(
                            new SymbolName(attributeType.getName(), attributeType.getPackagePath()));
                    if (attributeTypeSymbol instanceof AnnotationDef) {
                        populateDefaultValues(annotationTypeVal, (AnnotationDef) attributeTypeSymbol);
                    }
                }
            } else {
                AnnotationAttachment annotationTypeVal = attributeValue.getAnnotationValue();

                // skip if the value is not an annotation
                if (annotationTypeVal == null) {
                    continue;
                }

                BLangSymbol attributeTypeSymbol = annotationDef.resolve(attributeDef.getTypeName().getSymbolName());
                if (attributeTypeSymbol instanceof AnnotationDef) {
                    populateDefaultValues(annotationTypeVal, (AnnotationDef) attributeTypeSymbol);
                }
            }
        }
    }
/**
     * Populate default values to the annotation attributes.
     * 
     * @param annotation Annotation attachment to populate default values
     * @param annotationDef Definition of the annotation corresponds to the provided annotation attachment
     */
Populate default values to the annotation attributes.

@param annotation Annotation attachment to populate default values
@param annotationDef Definition of the annotation corresponds to the provided annotation attachment
Populate default values to the annotation attributes . @param annotation Annotation attachment to populate default values @param annotationDef Definition of the annotation corresponds to the provided annotation attachment
private void populateDefaultValues(AnnotationAttachment annotation, AnnotationDef annotationDef) {
        Map<String, AnnotationAttributeValue> attributeValPairs = annotation.getAttributeNameValuePairs();
        for (AnnotationAttributeDef attributeDef : annotationDef.getAttributeDefs()) {
            String attributeName = attributeDef.getName();
            if (!attributeValPairs.containsKey(attributeName)) {
                BasicLiteral defaultValue = attributeDef.getAttributeValue();
                if (defaultValue != null) {
                    annotation.addAttributeNameValuePair(attributeName,
                        new AnnotationAttributeValue(defaultValue.getBValue(), defaultValue.getTypeName(), null));
                }
                continue;
            }
            AnnotationAttributeValue attributeValue = attributeValPairs.get(attributeName);
            SimpleTypeName valueType = attributeValue.getType();
            if (valueType.isArrayType()) {
                AnnotationAttributeValue[] valuesArray = attributeValue.getValueArray();
                for (AnnotationAttributeValue value : valuesArray) {
                    AnnotationAttachment annotationTypeVal = value.getAnnotationValue();
                    if (annotationTypeVal == null) {
                        continue;
                    }
                    SimpleTypeName attributeType = attributeDef.getTypeName();
                    BLangSymbol attributeTypeSymbol = annotationDef.resolve(
                            new SymbolName(attributeType.getName(), attributeType.getPackagePath()));
                    if (attributeTypeSymbol instanceof AnnotationDef) {
                        populateDefaultValues(annotationTypeVal, (AnnotationDef) attributeTypeSymbol);
                    }
                }
            } else {
                AnnotationAttachment annotationTypeVal = attributeValue.getAnnotationValue();
                if (annotationTypeVal == null) {
                    continue;
                }
                BLangSymbol attributeTypeSymbol = annotationDef.resolve(attributeDef.getTypeName().getSymbolName());
                if (attributeTypeSymbol instanceof AnnotationDef) {
                    populateDefaultValues(annotationTypeVal, (AnnotationDef) attributeTypeSymbol);
                }
            }
        }
    }
private void populateDefaultValues ( AnnotationAttachment annotation , AnnotationDef annotationDef ) { Map < String , AnnotationAttributeValue > attributeValPairs = annotation . getAttributeNameValuePairs ( ) ; for ( AnnotationAttributeDef attributeDef : annotationDef . getAttributeDefs ( ) ) { String attributeName = attributeDef . getName ( ) ; if ( ! attributeValPairs . containsKey ( attributeName ) ) { BasicLiteral defaultValue = attributeDef . getAttributeValue ( ) ; if ( defaultValue != null ) { annotation . addAttributeNameValuePair ( attributeName , new AnnotationAttributeValue ( defaultValue . getBValue ( ) , defaultValue . getTypeName ( ) , null ) ) ; } continue ; } AnnotationAttributeValue attributeValue = attributeValPairs . get ( attributeName ) ; SimpleTypeName valueType = attributeValue . getType ( ) ; if ( valueType . isArrayType ( ) ) { AnnotationAttributeValue [ ] valuesArray = attributeValue . getValueArray ( ) ; for ( AnnotationAttributeValue value : valuesArray ) { AnnotationAttachment annotationTypeVal = value . getAnnotationValue ( ) ; if ( annotationTypeVal == null ) { continue ; } SimpleTypeName attributeType = attributeDef . getTypeName ( ) ; BLangSymbol attributeTypeSymbol = annotationDef . resolve ( new SymbolName ( attributeType . getName ( ) , attributeType . getPackagePath ( ) ) ) ; if ( attributeTypeSymbol instanceof AnnotationDef ) { populateDefaultValues ( annotationTypeVal , ( AnnotationDef ) attributeTypeSymbol ) ; } } } else { AnnotationAttachment annotationTypeVal = attributeValue . getAnnotationValue ( ) ; if ( annotationTypeVal == null ) { continue ; } BLangSymbol attributeTypeSymbol = annotationDef . resolve ( attributeDef . getTypeName ( ) . getSymbolName ( ) ) ; if ( attributeTypeSymbol instanceof AnnotationDef ) { populateDefaultValues ( annotationTypeVal , ( AnnotationDef ) attributeTypeSymbol ) ; } } } }
Populate default values to the annotation attributes.
Populate default values to the annotation attributes .
// if the current attribute is not defined in the annotation attachment, populate it with default value // If the annotation attachment contains the current attribute, and if the value is another  // annotationAttachment, then recursively populate its default values // skip if the array element is not an annotation // skip if the value is not an annotation