Search in sources :

Example 21 with One

use of com.abubusoft.kripton.common.One in project kripton by xcesco.

the class AnnotationUtility method extractAsStringArray.

/**
 * Extract from an annotation of a method the attribute value specified.
 *
 * @param elementUtils
 * @param method
 *            method to analyze
 * @param annotationClass
 *            annotation to analyze
 * @param attributeName
 *            attribute typeName to analyze
 * @return attribute value as list of string
 */
public static List<String> extractAsStringArray(ModelMethod method, ModelAnnotation annotationClass, AnnotationAttributeType attribute) {
    final Elements elementUtils = BaseProcessor.elementUtils;
    final One<List<String>> result = new One<List<String>>();
    extractAttributeValue(elementUtils, method.getElement(), annotationClass.getName(), attribute, new OnAttributeFoundListener() {

        @Override
        public void onFound(String value) {
            result.value0 = AnnotationUtility.extractAsArrayOfString(value);
        }
    });
    return result.value0;
}
Also used : One(com.abubusoft.kripton.common.One) ArrayList(java.util.ArrayList) List(java.util.List) Elements(javax.lang.model.util.Elements)

Example 22 with One

use of com.abubusoft.kripton.common.One in project kripton by xcesco.

the class AnnotationUtility method extractAsBoolean.

/**
 * Estract from an annotation of a method the attribute value specified
 *
 * @param elementUtils
 * @param item
 *            entity to analyze
 * @param annotation
 *            annotation to analyze
 * @param attributeName
 *            attribute typeName to analyze
 */
public static <E extends ModelEntity<?>> boolean extractAsBoolean(E item, ModelAnnotation annotation, AnnotationAttributeType attribute) {
    final Elements elementUtils = BaseProcessor.elementUtils;
    final One<Boolean> result = new One<Boolean>(false);
    extractAttributeValue(elementUtils, item.getElement(), annotation.getName(), attribute, new OnAttributeFoundListener() {

        @Override
        public void onFound(String value) {
            result.value0 = Boolean.valueOf(value);
        }
    });
    return result.value0;
}
Also used : One(com.abubusoft.kripton.common.One) Elements(javax.lang.model.util.Elements)

Example 23 with One

use of com.abubusoft.kripton.common.One in project kripton by xcesco.

the class AnnotationUtility method extractAsEnumerationValue.

/**
 * Estract from an annotation of a property the attribute value specified
 *
 * @param elementUtils
 * @param property
 *            property to analyze
 * @param annotationClass
 *            annotation to analyze
 * @param attributeName
 *            attribute typeName to analyze
 * @return attribute value as list of string
 */
public static String extractAsEnumerationValue(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attribute) {
    final Elements elementUtils = BindDataSourceSubProcessor.elementUtils;
    final One<String> result = new One<String>();
    extractAttributeValue(elementUtils, item, annotationClass.getName(), attribute, new OnAttributeFoundListener() {

        @Override
        public void onFound(String value) {
            if (value.indexOf(".") >= 0)
                result.value0 = value.substring(value.lastIndexOf(".") + 1);
        }
    });
    return result.value0;
}
Also used : One(com.abubusoft.kripton.common.One) Elements(javax.lang.model.util.Elements)

Example 24 with One

use of com.abubusoft.kripton.common.One in project kripton by xcesco.

the class AnnotationUtility method extractAsClassName.

/**
 * Extract from an annotation of a method the attribute value specified.
 *
 * @param elementUtils
 * @param item
 * @param annotationClass
 * @param attributeName
 * @return attribute value extracted as class typeName
 */
public static String extractAsClassName(Element item, Class<? extends Annotation> annotationClass, AnnotationAttributeType attributeName) {
    final Elements elementUtils = BindDataSourceSubProcessor.elementUtils;
    final One<String> result = new One<String>();
    extractString(elementUtils, item, annotationClass, attributeName, new OnAttributeFoundListener() {

        @Override
        public void onFound(String value) {
            result.value0 = AnnotationUtility.extractAsArrayOfClassName(value).get(0);
        }
    });
    return result.value0;
}
Also used : One(com.abubusoft.kripton.common.One) Elements(javax.lang.model.util.Elements)

Example 25 with One

use of com.abubusoft.kripton.common.One in project kripton by xcesco.

the class AnnotationUtility method extractAsString.

/**
 * Extract from an annotation of a method the attribute value specified.
 *
 * @param elementUtils
 * @param item
 * @param annotationClass
 * @param attributeName
 * @return attribute value extracted as class typeName
 */
public static String extractAsString(final Element item, final Class<? extends Annotation> annotationClass, final AnnotationAttributeType attributeName) {
    final Elements elementUtils = BaseProcessor.elementUtils;
    final One<String> result = new One<String>();
    extractString(elementUtils, item, annotationClass, attributeName, new OnAttributeFoundListener() {

        @Override
        public void onFound(String value) {
            List<String> list = AnnotationUtility.extractAsArrayOfString(value);
            if (list.size() > 0)
                result.value0 = list.get(0);
            else
                result.value0 = value;
        }
    });
    return result.value0;
}
Also used : One(com.abubusoft.kripton.common.One) ArrayList(java.util.ArrayList) List(java.util.List) Elements(javax.lang.model.util.Elements)

Aggregations

One (com.abubusoft.kripton.common.One)36 ArrayList (java.util.ArrayList)13 JQLReplacerListenerImpl (com.abubusoft.kripton.processor.sqlite.grammars.jql.JQLReplacerListenerImpl)12 SQLProperty (com.abubusoft.kripton.processor.sqlite.model.SQLProperty)10 Elements (javax.lang.model.util.Elements)9 Where_stmtContext (com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Where_stmtContext)8 SQLiteDaoDefinition (com.abubusoft.kripton.processor.sqlite.model.SQLiteDaoDefinition)8 JQLChecker (com.abubusoft.kripton.processor.sqlite.grammars.jql.JQLChecker)7 JQLReplaceVariableStatementListenerImpl (com.abubusoft.kripton.processor.sqlite.grammars.jql.JQLReplaceVariableStatementListenerImpl)7 JqlBaseListener (com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlBaseListener)7 Pair (com.abubusoft.kripton.common.Pair)5 SQLiteEntity (com.abubusoft.kripton.processor.sqlite.model.SQLiteEntity)5 Bind_parameterContext (com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Bind_parameterContext)4 Projected_columnsContext (com.abubusoft.kripton.processor.sqlite.grammars.jsql.JqlParser.Projected_columnsContext)4 TypeName (com.squareup.javapoet.TypeName)4 LinkedHashSet (java.util.LinkedHashSet)4 List (java.util.List)4 Test (org.junit.Test)4 BaseAndroidTest (base.BaseAndroidTest)3 TransactionResult (com.abubusoft.kripton.android.sqlite.TransactionResult)3