idx
int64
0
165k
question
stringlengths
73
5.81k
target
stringlengths
5
918
128,100
public static void generateImmutableCollectionIfPossible ( ModelClass < ? > entity , Builder methodBuilder , String name , TypeName typeName ) { if ( TypeUtility . isList ( typeName ) && ( ( ParameterizedTypeName ) typeName ) . rawType . equals ( ClassName . get ( List . class ) ) ) { methodBuilder . addCode ( "($L==nu...
used for example for dao select result
128,101
public T get ( int index ) { T item = mStorage . get ( index ) ; if ( item != null ) { mLastItem = item ; } return item ; }
Get the item in the list of loaded items at the provided index .
128,102
public void loadAround ( int index ) { mLastLoad = index + getPositionOffset ( ) ; loadAroundInternal ( index ) ; mLowestIndexAccessed = Math . min ( mLowestIndexAccessed , index ) ; mHighestIndexAccessed = Math . max ( mHighestIndexAccessed , index ) ; tryDispatchBoundaryCallbacks ( true ) ; }
Load adjacent items to passed index .
128,103
void deferBoundaryCallbacks ( final boolean deferEmpty , final boolean deferBegin , final boolean deferEnd ) { if ( mBoundaryCallback == null ) { throw new IllegalStateException ( "Can't defer BoundaryCallback, no instance" ) ; } if ( mLowestIndexAccessed == Integer . MAX_VALUE ) { mLowestIndexAccessed = mStorage . siz...
Safe to access main thread only state - no other thread has reference during construction
128,104
void resolveTypeVariable ( SQLiteModelMethod value ) { for ( Pair < String , TypeName > item : value . getParameters ( ) ) { item . value1 = typeVariableResolver . resolve ( item . value1 ) ; } value . setReturnClass ( typeVariableResolver . resolve ( value . getReturnClass ( ) ) ) ; }
Convert type variable in correct type . This must be done before work on SQLMethod
128,105
String buildPreparedStatementName ( String methodName ) { String name = methodName + "PreparedStatement" + preparedStatementNames . size ( ) ; preparedStatementNames . add ( name ) ; return name ; }
Build and register prepared statement name .
128,106
public String generateJava2ContentSerializer ( TypeName paramTypeName ) { if ( ! managedParams . containsKey ( paramTypeName ) ) { managedParams . put ( paramTypeName , "" + ( managedParams . size ( ) + 1 ) ) ; } return PARAM_SERIALIZER_PREFIX + managedParams . get ( paramTypeName ) ; }
Generate java 2 content serializer .
128,107
public String generateJava2ContentParser ( TypeName paramTypeName ) { if ( ! managedParams . containsKey ( paramTypeName ) ) { managedParams . put ( paramTypeName , "" + ( managedParams . size ( ) + 1 ) ) ; } return PARAM_PARSER_PREFIX + managedParams . get ( paramTypeName ) ; }
Generate java 2 content parser .
128,108
public boolean hasSamePackageOfSchema ( ) { String packageName = getPackageName ( ) ; String schemaPackageName = getParent ( ) . getPackageName ( ) ; return packageName . equals ( schemaPackageName ) ; }
Returns true if dao and schema stay in same package
128,109
public static void generateSubjectNext ( SQLiteEntity entity , MethodSpec . Builder methodBuilder , SubjectType subjectType , String value ) { String subInsertType = "" ; if ( subjectType == SubjectType . INSERT ) { if ( entity . getPrimaryKey ( ) . isType ( String . class ) ) { subInsertType = "WithUid" ; } else { sub...
Generate subject next .
128,110
public static Boolean readBoolean ( String value , Boolean defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Boolean . valueOf ( value ) ; }
Read boolean .
128,111
public static Byte readByte ( String value , Byte defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Byte . valueOf ( value ) ; }
Read byte .
128,112
public static Character readCharacter ( String value , Character defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Character . valueOf ( ( char ) Integer . parseInt ( value ) ) ; }
Read character .
128,113
public static Short readShort ( String value , Short defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Short . valueOf ( value ) ; }
Read short .
128,114
public static Integer readInteger ( String value , Integer defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Integer . valueOf ( value ) ; }
Read integer .
128,115
public static Long readLong ( String value , Long defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Long . valueOf ( value ) ; }
Read long .
128,116
public static Float readFloat ( String value , Float defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Float . valueOf ( value ) ; }
Read float .
128,117
public static Double readDouble ( String value , Double defaultValue ) { if ( ! StringUtils . hasText ( value ) ) return defaultValue ; return Double . valueOf ( value ) ; }
Read double .
128,118
public static String writeBoolean ( Boolean value ) { if ( value == null ) return null ; return Boolean . toString ( value ) ; }
Write boolean .
128,119
public static String writeCharacter ( Character value ) { if ( value == null ) return null ; return Integer . toString ( ( int ) value ) ; }
Write character .
128,120
public static String writeShort ( Short value ) { if ( value == null ) return null ; return Short . toString ( value ) ; }
Write short .
128,121
public static String writeInteger ( Integer value ) { if ( value == null ) return null ; return Integer . toString ( value ) ; }
Write integer .
128,122
public static String writeLong ( Long value ) { if ( value == null ) return null ; return Long . toString ( value ) ; }
Write long .
128,123
public static String writeFloat ( Float value ) { if ( value == null ) return null ; return Float . toString ( value ) ; }
Write float .
128,124
public static String writeDouble ( Double value ) { if ( value == null ) return null ; return Double . toString ( value ) ; }
Write double .
128,125
protected List < SQLiteUpdateTask > buildTaskList ( int previousVersion , int currentVersion ) { List < SQLiteUpdateTask > result = new ArrayList < > ( ) ; for ( Pair < Integer , ? extends SQLiteUpdateTask > item : this . options . updateTasks ) { if ( item . value0 - 1 == previousVersion ) { result . add ( item . valu...
Builds the task list .
128,126
protected void createHelper ( DataSourceOptions options ) { if ( KriptonLibrary . getContext ( ) == null ) throw new KriptonRuntimeException ( "Kripton library is not properly initialized. Please use KriptonLibrary.init(context) somewhere at application startup" ) ; if ( options . inMemory ) { Logger . info ( "In-memor...
Creates the helper .
128,127
public void onDowngrade ( SQLiteDatabase db , int oldVersion , int newVersion ) { if ( AbstractDataSource . this . options . databaseLifecycleHandler != null ) { AbstractDataSource . this . options . databaseLifecycleHandler . onUpdate ( db , oldVersion , newVersion , false ) ; versionChanged = true ; } }
On downgrade .
128,128
public void onUpgrade ( SQLiteDatabase db , int oldVersion , int newVersion ) { if ( AbstractDataSource . this . options . databaseLifecycleHandler != null ) { AbstractDataSource . this . options . databaseLifecycleHandler . onUpdate ( db , oldVersion , newVersion , true ) ; versionChanged = true ; } }
On upgrade .
128,129
public static void assertTrue ( boolean expression , String messageFormat , Object ... args ) { if ( ! expression ) throw ( new KriptonProcessorException ( String . format ( messageFormat , args ) ) ) ; }
Assertion which generate an exception if expression is not true .
128,130
public static void assertTrueOrInvalidMethodSignException ( boolean expression , SQLiteModelMethod method , String messageFormat , Object ... args ) { if ( ! expression ) throw ( new InvalidMethodSignException ( method , String . format ( messageFormat , args ) ) ) ; }
Assert true or invalid method sign exception .
128,131
public static void failWithInvalidMethodSignException ( boolean expression , SQLiteModelMethod method , String messageFormat , Object ... args ) { assertTrueOrInvalidMethodSignException ( ! expression , method , messageFormat , args ) ; }
if expression is true it fails . It is the opposite of assert
128,132
public static void failIncompatibleAttributesInAnnotationException ( String messageFormat , Object ... args ) { throw ( new IncompatibleAttributesInAnnotationException ( String . format ( messageFormat , args ) ) ) ; }
Fail incompatible attributes in annotation exception .
128,133
public static void fail ( boolean expression , String messageFormat , Object ... args ) { assertTrue ( ! expression , messageFormat , args ) ; }
Fails if expression is true .
128,134
public static void assertTrueOrInvalidKindForAnnotationException ( boolean expression , Element element , Class < ? extends Annotation > annotationClazz ) { if ( ! expression ) { String msg = String . format ( "%s %s, only class can be annotated with @%s annotation" , element . getKind ( ) , element , annotationClazz ....
Assert true or invalid kind for annotation exception .
128,135
public static void assertTrueOrInvalidTypeForAnnotationMethodParameterException ( boolean expression , Element classElement , ExecutableElement methodElement , VariableElement parameterElement , Class < ? extends Annotation > annotationClazz ) { if ( ! expression ) { String msg = String . format ( "In method '%s.%s', p...
In case a method s parameters is of a type incompatible with specific annotation .
128,136
public static void assertTrueOrUnknownPropertyInJQLException ( boolean expression , JQLContext method , String columnName ) { if ( ! expression ) { throw ( new UnknownPropertyInJQLException ( method , columnName ) ) ; } }
Assert true or unknown property in JQL exception .
128,137
public static void assertTrueOrUnknownClassInJQLException ( boolean expression , SQLiteModelMethod method , String className ) { if ( ! expression ) { throw ( new UnknownClassInJQLException ( method , className ) ) ; } }
Assert true or unknown class in JQL exception .
128,138
public static void assertTrueOrUnknownParamInJQLException ( boolean expression , SQLiteModelMethod method , String paramName ) { if ( ! expression ) { throw ( new UnknownParamUsedInJQLException ( method , paramName ) ) ; } }
Assert true or unknown param in JQL exception .
128,139
public static void failUnknownPropertyInJQLException ( SQLiteModelMethod method , Class < ? extends Annotation > annotationClazz , AnnotationAttributeType attribute , String fieldName ) { throw ( new UnknownPropertyInJQLException ( method , annotationClazz , attribute , fieldName ) ) ; }
Fail unknown property in JQL exception .
128,140
public static void assertTrueOrInvalidPropertyName ( boolean expression , SQLProperty item1 , SQLProperty item2 ) { if ( ! expression ) { String msg = String . format ( "Properties '%s#%s' and '%s#%s' must have same column name" , item1 . getParent ( ) . name , item1 . name , item2 . getParent ( ) . name , item2 . name...
Assert true or invalid property name .
128,141
public static void asserTrueOrForeignKeyNotFound ( boolean expression , SQLiteEntity currentEntity , ClassName entity ) { if ( ! expression ) { throw ( new ForeignKeyNotFoundException ( currentEntity , entity ) ) ; } }
Asser true or foreign key not found .
128,142
public static void asserTrueOrMissedAnnotationOnClassException ( boolean expression , TypeElement daoElement , String entityName ) { if ( ! expression ) { String msg = String . format ( "Dao '%s' referes a bean '%s' without @%s or @%s annotation" , daoElement . getQualifiedName ( ) , TypeUtility . className ( entityNam...
Asser true or missed annotation on class exception .
128,143
public static void asserTrueOrUnspecifiedBeanException ( boolean expression , SQLiteDatabaseSchema schema , SQLiteEntity entity , String foreignClassName ) { if ( ! expression ) { String msg = String . format ( "In dao definition '%s' is referred a bean definition '%s' that is not defined in '%s' schema" , entity . get...
Asser true or unspecified bean exception .
128,144
public static void assertTrueOfInvalidDefinition ( boolean expression , ModelProperty property , String message ) { if ( ! expression ) { String msg = String . format ( "In class '%s', property '%s' has invalid definition: %s" , property . getParent ( ) . getElement ( ) . asType ( ) . toString ( ) , property . getName ...
Assert true of invalid definition .
128,145
public static void assertTrueOrInvalidGlobalTypeApdaterException ( boolean expression , SQLiteDatabaseSchema sqLiteDatabaseSchema , String typeAdapter , String typeAdapter2 ) { if ( ! expression ) { String msg = String . format ( "In data source '%s', there are two or more global type adapter that cover type '%s': '%s'...
Assert true or invalid global type apdater exception .
128,146
@ SuppressWarnings ( "unchecked" ) static VisitorStatusType visitList ( String name , List < Object > list , BindMapListener listener , VisitorStatusType status ) { int i = 0 ; for ( Object item : list ) { if ( item == null || item instanceof String ) { visit ( name + "." + i , ( String ) item , listener , status ) ; }...
Visit list .
128,147
public static List < SQLProperty > extractUsedProperties ( Builder methodBuilder , SQLiteModelMethod method , Class < ? extends Annotation > annotationClazz ) { SQLiteEntity entity = method . getEntity ( ) ; List < SQLProperty > listPropertyInContentValue = new ArrayList < SQLProperty > ( ) ; Set < String > foundColumn...
Generate code necessary to put bean properties in content values map . Return primary key
128,148
private < L extends UriBaseListener > void analyzePathInternal ( final String input , L listener ) { pathSegmentIndex = - 1 ; walker . walk ( listener , preparePath ( input ) . value0 ) ; }
Analyze path internal .
128,149
public Map < String , ContentUriPlaceHolder > extractAsMap ( String input ) { HashMap < String , ContentUriPlaceHolder > result = new HashMap < > ( ) ; ArrayList < ContentUriPlaceHolder > list = extractPlaceHoldersFromURI ( input , new ArrayList < ContentUriPlaceHolder > ( ) ) ; for ( ContentUriPlaceHolder item : list ...
Extract all parameters from URI as a map .
128,150
public List < ContentUriPlaceHolder > extractFromPath ( String input ) { final List < ContentUriPlaceHolder > result = new ArrayList < > ( ) ; final One < Boolean > valid = new One < > ( ) ; valid . value0 = false ; analyzePathInternal ( input , new UriBaseListener ( ) { public void enterBind_parameter ( Bind_parameter...
Extract from path .
128,151
private < L extends Collection < ContentUriPlaceHolder > > L extractPlaceHoldersFromURI ( String uri , final L result ) { final One < Boolean > valid = new One < > ( ) ; valid . value0 = false ; analyzeInternal ( uri , new UriBaseListener ( ) { public void enterBind_parameter ( Bind_parameterContext ctx ) { result . ad...
Extract place holders from URI .
128,152
private Pair < ParserRuleContext , CommonTokenStream > preparePath ( final String input ) { UriLexer lexer = new UriLexer ( CharStreams . fromString ( input ) ) ; CommonTokenStream tokens = new CommonTokenStream ( lexer ) ; UriParser parser = new UriParser ( tokens ) ; parser . removeErrorListeners ( ) ; parser . addEr...
Prepare path .
128,153
private Pair < ParserRuleContext , CommonTokenStream > prepareUri ( final String input ) { UriLexer lexer = new UriLexer ( CharStreams . fromString ( input ) ) ; CommonTokenStream tokens = new CommonTokenStream ( lexer ) ; UriParser parser = new UriParser ( tokens ) ; parser . removeErrorListeners ( ) ; parser . addErr...
Prepare uri .
128,154
private String replaceInternalFromUri ( String input , final List < Triple < Token , Token , String > > replace , UriBaseListener rewriterListener ) { Pair < ParserRuleContext , CommonTokenStream > parser = prepareUri ( input ) ; pathSegmentIndex = - 1 ; walker . walk ( rewriterListener , parser . value0 ) ; TokenStrea...
Replace internal from uri .
128,155
protected void parseBindType ( RoundEnvironment roundEnv ) { for ( Element item : roundEnv . getElementsAnnotatedWith ( BindType . class ) ) { AssertKripton . assertTrueOrInvalidKindForAnnotationException ( item . getKind ( ) == ElementKind . CLASS , item , BindType . class ) ; globalBeanElements . put ( item . toStrin...
build bindType elements map .
128,156
private static void generateParserOnXmlEndElement ( BindTypeContext context , MethodSpec . Builder methodBuilder , String instanceName , String parserName , BindEntity entity ) { methodBuilder . beginControlFlow ( "if (elementName.equals($L.getName()))" , parserName ) ; methodBuilder . addStatement ( "currentTag = elem...
Generate parser on xml end element .
128,157
private static void generateParseOnXmlAttributes ( BindTypeContext context , MethodSpec . Builder methodBuilder , BindEntity entity ) { BindTransform bindTransform ; int count = 0 ; { for ( BindProperty property : entity . getCollection ( ) ) { if ( property . xmlInfo . xmlType != XmlType . ATTRIBUTE ) continue ; count...
Generate parse on xml attributes .
128,158
private static void generateParserOnXmlStartElement ( BindTypeContext context , MethodSpec . Builder methodBuilder , String instanceName , String parserName , BindEntity entity ) { BindTransform bindTransform ; methodBuilder . addStatement ( "currentTag = xmlParser.getName().toString()" ) ; int count = 0 ; { for ( Bind...
Generate parser on xml start element .
128,159
private static void generateParserOnXmlCharacters ( BindTypeContext context , MethodSpec . Builder methodBuilder , String instanceName , String parserName , BindEntity entity ) { BindTransform bindTransform ; int count = 0 ; for ( BindProperty property : entity . getCollection ( ) ) { if ( property . xmlInfo . xmlType ...
Parse entity properties and write code to read only CData Text fields .
128,160
private static void generateParseOnJackson ( BindTypeContext context , BindEntity entity ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "parseOnJackson" ) . addJavadoc ( "parse with jackson\n" ) . addAnnotation ( Override . class ) . addModifiers ( Modifier . PUBLIC ) . addParameter ( typeName ( ...
Generate parse on jackson .
128,161
private static void generateSerializeOnJackson ( BindTypeContext context , BindEntity entity ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "serializeOnJackson" ) . addAnnotation ( Override . class ) . addModifiers ( Modifier . PUBLIC ) . addParameter ( typeName ( entity . getElement ( ) ) , "obj...
Generate serialize on jackson .
128,162
private static void generateSerializeOnXml ( BindTypeContext context , BindEntity entity ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "serializeOnXml" ) . addJavadoc ( "method for xml serialization\n" ) . addAnnotation ( Override . class ) . addModifiers ( Modifier . PUBLIC ) . addParameter ( t...
Generate serialize on xml .
128,163
public void nextPage ( ) { if ( ! paged ) { this . firstPage ( ) ; paged = true ; } else if ( ! isLast ( ) ) { offset = ( getPageNumber ( ) + 1 ) * pageSize ; execute ( ) ; } }
Next page .
128,164
public static JQL buildJQL ( final SQLiteModelMethod method , String preparedJql ) { Map < JQLDynamicStatementType , String > dynamicReplace = new HashMap < > ( ) ; final JQL result = new JQL ( ) ; forEachParameter ( method , new OnMethodParameterListener ( ) { public void onMethodParameter ( VariableElement item ) { i...
Builds the JQL .
128,165
private static void checkFieldsDefinitions ( SQLiteModelMethod method , Class < ? extends Annotation > annotation ) { List < String > includedFields = AnnotationUtility . extractAsStringArray ( method . getElement ( ) , annotation , AnnotationAttributeType . FIELDS ) ; List < String > excludedFields = AnnotationUtility...
Check fields definitions .
128,166
private static < A extends Annotation > LinkedHashSet < String > extractFieldsFromAnnotation ( final SQLiteModelMethod method , Class < A > annotationClazz , final boolean includePrimaryKey ) { final SQLiteEntity entity = method . getEntity ( ) ; List < String > annotatedFieldValues = AnnotationUtility . extractAsStrin...
Extract fields from annotation .
128,167
private static boolean isInSet ( String value , Set < JQLPlaceHolder > parametersUsedInWhereConditions ) { for ( JQLPlaceHolder ph : parametersUsedInWhereConditions ) { if ( ph . value . equals ( value ) ) return true ; } return false ; }
Checks if is in set .
128,168
private static < L extends Annotation > String defineOrderByStatement ( final SQLiteModelMethod method , final JQL result , Class < L > annotation , Map < JQLDynamicStatementType , String > dynamicReplace ) { StringBuilder builder = new StringBuilder ( ) ; String orderBy = AnnotationUtility . extractAsString ( method ....
Define ORDER BY statement .
128,169
private static void forEachParameter ( SQLiteModelMethod method , OnMethodParameterListener listener ) { for ( VariableElement p : method . getElement ( ) . getParameters ( ) ) { listener . onMethodParameter ( p ) ; } }
For each parameter .
128,170
public static void infoOnGeneratedClasses ( Class < ? extends Annotation > annotation , String packageName , String className ) { String msg = String . format ( "class '%s' in package '%s' is generated by '@%s' annotation processor" , className , packageName , annotation . getSimpleName ( ) ) ; printMessage ( msg ) ; }
KRIPTON_DEBUG info about generated classes .
128,171
public static void infoOnGeneratedFile ( Class < BindDataSource > annotation , File schemaCreateFile ) { String msg = String . format ( "file '%s' in directory '%s' is generated by '@%s' annotation processor" , schemaCreateFile . getName ( ) , schemaCreateFile . getParentFile ( ) , annotation . getSimpleName ( ) ) ; pr...
Info on generated file .
128,172
public static String getNameParameterOfType ( ModelMethod method , TypeName parameter ) { for ( Pair < String , TypeName > item : method . getParameters ( ) ) { if ( item . value1 . equals ( parameter ) ) { return item . value0 ; } } return null ; }
Gets the name parameter of type .
128,173
public static void generateSelect ( Builder builder , SQLiteModelMethod method ) throws ClassNotFoundException { SelectType selectResultType = SelectBuilderUtility . detectSelectType ( method ) ; selectResultType . generate ( builder , method ) ; if ( method . hasLiveData ( ) ) { selectResultType . generateLiveData ( b...
Generate select .
128,174
public static String convertJQL2SQL ( final SQLiteModelMethod method , final boolean replaceWithQuestion ) { JQLChecker jqlChecker = JQLChecker . getInstance ( ) ; String sql = jqlChecker . replace ( method , method . jql , new JQLReplacerListenerImpl ( method ) { public String onBindParameter ( String bindParameterNam...
Convert JQL 2 SQL .
128,175
public Iterator < Map . Entry < K , V > > descendingIterator ( ) { DescendingIterator < K , V > iterator = new DescendingIterator < > ( mEnd , mStart ) ; mIterators . put ( iterator , false ) ; return iterator ; }
Descending iterator .
128,176
public IteratorWithAdditions iteratorWithAdditions ( ) { @ SuppressWarnings ( "unchecked" ) IteratorWithAdditions iterator = new IteratorWithAdditions ( ) ; mIterators . put ( iterator , false ) ; return iterator ; }
return an iterator with additions .
128,177
public static void generateJavadocGeneratedBy ( Builder builder ) { if ( ! BindDataSourceSubProcessor . JUNIT_TEST_MODE ) { builder . addJavadoc ( "<p><strong>This class is generated by Kripton Annotation Processor - v. $L</strong></p>\n" , Version . getVersion ( ) ) ; builder . addJavadoc ( "<p><strong>Generation-time...
Generate javadoc generated by .
128,178
public static String generateColumnCheckSet ( TypeSpec . Builder builder , SQLiteModelMethod method , Set < String > columnNames ) { String columnNameSet = method . contentProviderMethodName + "ColumnSet" ; StringBuilder initBuilder = new StringBuilder ( ) ; String temp = "" ; for ( String item : columnNames ) { initBu...
check used columns .
128,179
static List < JQLPlaceHolder > removeDynamicPlaceHolder ( List < JQLPlaceHolder > placeHolders ) { List < JQLPlaceHolder > result = new ArrayList < > ( ) ; for ( JQLPlaceHolder item : placeHolders ) { if ( item . type != JQLPlaceHolderType . DYNAMIC_SQL ) { result . add ( item ) ; } } return result ; }
Removes the dynamic place holder .
128,180
static boolean validate ( String value , List < JQLPlaceHolder > placeHolders , int pos ) { return placeHolders . get ( pos ) . value . equals ( value ) ; }
look for variable name in place holders defined through path of content provider .
128,181
public static void generateJavaDocForContentProvider ( final SQLiteModelMethod method , MethodSpec . Builder methodBuilder ) { String operation = method . jql . operationType . toString ( ) ; methodBuilder . addJavadoc ( "<h1>Content provider URI ($L operation):</h1>\n" , operation ) ; methodBuilder . addJavadoc ( "<pr...
Generate java doc for content provider .
128,182
public static void forEachMethods ( TypeElement typeElement , MethodFoundListener listener ) { Elements elementUtils = BaseProcessor . elementUtils ; List < ? extends Element > list = elementUtils . getAllMembers ( typeElement ) ; for ( Element item : list ) { if ( item . getKind ( ) == ElementKind . METHOD ) { listene...
Iterate over methods .
128,183
public static Pair < String , TypeName > searchInEachParameter ( ModelMethod method , OnParameterListener listener ) { for ( Pair < String , TypeName > item : method . getParameters ( ) ) { if ( listener . onParameter ( item ) ) { return item ; } } return null ; }
Iterate for each method s parameter
128,184
public static int countParameterOfType ( ModelMethod method , TypeName parameter ) { int counter = 0 ; for ( Pair < String , TypeName > item : method . getParameters ( ) ) { if ( item . value1 . equals ( parameter ) ) { counter ++ ; } } return counter ; }
Count parameter of type .
128,185
public static void generateLogForContentValuesContentProvider ( SQLiteModelMethod method , MethodSpec . Builder methodBuilder ) { methodBuilder . addCode ( "\n// log for content values -- BEGIN\n" ) ; methodBuilder . addStatement ( "Object _contentValue" ) ; methodBuilder . beginControlFlow ( "for (String _contentKey:_...
Generate log for content values content provider .
128,186
public static List < Pair < String , TypeName > > orderContentValues ( final SQLiteModelMethod method , final List < Pair < String , TypeName > > updateableParams ) { final List < Pair < String , TypeName > > result = new ArrayList < Pair < String , TypeName > > ( ) ; JQLChecker checker = JQLChecker . getInstance ( ) ;...
Order content values .
128,187
public static TypeName extractReturnType ( final SQLiteModelMethod method ) { SQLiteEntity daoEntity = method . getParent ( ) . getEntity ( ) ; TypeName returnTypeName = method . getReturnClass ( ) ; TypeName result = null ; if ( TypeUtility . isTypeIncludedIn ( returnTypeName , Void . class , Void . TYPE ) ) { Pair < ...
Detect result type .
128,188
private void generateDaoPart ( M2MEntity entity ) { String daoClassName = entity . daoName . simpleName ( ) ; String daoPackageName = entity . daoName . packageName ( ) ; String entityPackageName = entity . getPackageName ( ) ; String generatedDaoClassName = "Generated" + daoClassName ; AnnotationProcessorUtilis . info...
Generate dao part .
128,189
private boolean isMethodAlreadyDefined ( M2MEntity entity , final String methodName ) { final One < Boolean > found = new One < Boolean > ( false ) ; SqlBuilderHelper . forEachMethods ( entity . daoElement , new MethodFoundListener ( ) { public void onMethod ( ExecutableElement executableMethod ) { if ( executableMetho...
analyze DAO definition to check if method is already defined .
128,190
private void generateInsert ( M2MEntity entity , String packageName ) { if ( ! isMethodAlreadyDefined ( entity , "insert" ) ) { MethodSpec methodSpec = MethodSpec . methodBuilder ( "insert" ) . addModifiers ( Modifier . PUBLIC ) . addModifiers ( Modifier . ABSTRACT ) . addAnnotation ( AnnotationSpec . builder ( BindSql...
Generate insert .
128,191
public static void generate ( Elements elementUtils , Filer filer , SQLiteDatabaseSchema schema ) throws Exception { BindDaoFactoryBuilder visitor = new BindDaoFactoryBuilder ( elementUtils , filer , schema ) ; visitor . buildDaoFactoryInterface ( elementUtils , filer , schema ) ; String daoFactoryName = BindDaoFactory...
Generate database .
128,192
static String defineFileName ( SQLiteDatabaseSchema model ) { int lastIndex = model . fileName . lastIndexOf ( "." ) ; String schemaName = model . fileName ; if ( lastIndex > - 1 ) { schemaName = model . fileName . substring ( 0 , lastIndex ) ; } schemaName = schemaName . toLowerCase ( ) + "_schema_" + model . version ...
Define file name .
128,193
public static ClassName generateDataSourceName ( SQLiteDatabaseSchema schema ) { String dataSourceName = schema . getName ( ) ; dataSourceName = PREFIX + dataSourceName ; PackageElement pkg = BaseProcessor . elementUtils . getPackageOf ( schema . getElement ( ) ) ; String packageName = pkg . isUnnamed ( ) ? "" : pkg . ...
Generate dataSource name .
128,194
public static void generateDaoUids ( TypeSpec . Builder classBuilder , SQLiteDatabaseSchema schema ) { for ( SQLiteDaoDefinition dao : schema . getCollection ( ) ) { classBuilder . addField ( FieldSpec . builder ( Integer . TYPE , dao . daoUidName , Modifier . FINAL , Modifier . STATIC , Modifier . PUBLIC ) . initializ...
Generate Dao s UID . If specified prefix will be used to
128,195
private String extractDaoFieldNameForInternalDataSource ( SQLiteDaoDefinition dao ) { return "_" + CaseFormat . UPPER_CAMEL . to ( CaseFormat . LOWER_CAMEL , dao . getName ( ) ) ; }
Extract dao field name for internal data source .
128,196
private void generatePopulate ( SQLiteDatabaseSchema schema , MethodSpec . Builder methodBuilder , boolean instance ) { methodBuilder . beginControlFlow ( "try" ) ; methodBuilder . addStatement ( "instance.openWritableDatabase()" ) ; methodBuilder . addStatement ( "instance.close()" ) ; if ( ( instance && schema . conf...
Generate populate .
128,197
private void generateOpen ( String schemaName ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "open" ) . addModifiers ( Modifier . PUBLIC , Modifier . STATIC ) . returns ( className ( schemaName ) ) ; methodBuilder . addJavadoc ( "Retrieve data source instance and open it.\n" ) ; methodBuilder . a...
Generate open .
128,198
private void generateOnConfigure ( boolean useForeignKey ) { MethodSpec . Builder methodBuilder = MethodSpec . methodBuilder ( "onConfigure" ) . addAnnotation ( Override . class ) . addModifiers ( Modifier . PUBLIC ) ; methodBuilder . addParameter ( SQLiteDatabase . class , "database" ) ; methodBuilder . addJavadoc ( "...
Generate on configure .
128,199
public static List < SQLiteEntity > orderEntitiesList ( SQLiteDatabaseSchema schema ) { List < SQLiteEntity > entities = schema . getEntitiesAsList ( ) ; Collections . sort ( entities , new Comparator < SQLiteEntity > ( ) { public int compare ( SQLiteEntity lhs , SQLiteEntity rhs ) { return lhs . getTableName ( ) . com...
Generate ordered entities list .