/*
(non-Javadoc)

@see
com.impetus.kundera.generator.AutoGenerator#generate(com.impetus.kundera
.client.Client, java.lang.Object)
16088
@Override
    public Object generate(Client<?> client, String dataType)
    {
        return UUID.randomUUID().toString();
    }
510160
@Override
	public void generateLiveData(TypeSpec.Builder classBuilder, SQLiteModelMethod method) {
		SQLiteDaoDefinition daoDefinition = method.getParent();
		Set<JQLProjection> fieldList = JQLChecker.getInstance().extractProjections(method, method.jql.value, method.getEntity());

		// generate method code
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(method.getName().replaceAll(LIVE_DATA_PREFIX, "")).addAnnotation(Override.class).addModifiers(Modifier.PUBLIC);

		methodBuilder.addJavadoc("<h2>Live data</h2>\n");
		methodBuilder.addJavadoc("<p>This method open a connection internally.</p>\n\n");

		generateCommonPart(method, classBuilder, methodBuilder, fieldList, GenerationType.NO_CONTENT, method.liveDataReturnClass, true, false);

		boolean pagedLiveData = method.isPagedLiveData();

		if (pagedLiveData) {
			SelectType.PAGED_RESULT.generate(classBuilder, method);

			String pageResultName = SelectPaginatedResultHelper.getCurrentPagedResultClass();
			SelectPaginatedResultHelper.createPagedResult(method, pageResultName, methodBuilder);
		}

		ClassName dataSourceClazz = BindDataSourceBuilder.generateDataSourceName(daoDefinition.getParent());
		ClassName daoFactoryClazz = TypeUtility.className(BindDaoFactoryBuilder.generateDaoFactoryName(daoDefinition.getParent()));
		ClassName batchClazz = TypeUtility.mergeTypeNameWithSuffix(dataSourceClazz, ".Batch");

		List<Pair<String, TypeName>> methodParameters = method.getParameters();
		StringBuilder buffer = new StringBuilder();
		String separator = "";

		for (Pair<String, TypeName> item : methodParameters) {
			buffer.append(separator + item.value0);
			separator = ", ";
		}

		ClassName handlerClass = KriptonLiveDataManager.getInstance().getLiveDataHandlerClazz();
		if (pagedLiveData) {
			handlerClass = KriptonLiveDataManager.getInstance().getPagedLiveDataHandlerClazz();

			TypeSpec batchBuilder = TypeSpec.anonymousClassBuilder("").addSuperinterface(ParameterizedTypeName.get(batchClazz, method.getReturnClass()))
					.addMethod(
							MethodSpec.methodBuilder("onExecute").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC).addParameter(ParameterSpec.builder(daoFactoryClazz, "daoFactory").build())
									.returns(method.getReturnClass()).addStatement("return paginatedResult.execute(daoFactory)").build())
					.build();

			// return
			TypeSpec.Builder liveDataBuilderBuilder = TypeSpec.anonymousClassBuilder("paginatedResult")
					.addSuperinterface(ParameterizedTypeName.get(handlerClass, method.getReturnClass())).addMethod(MethodSpec.methodBuilder("compute").addAnnotation(Override.class)
							.addModifiers(Modifier.PROTECTED).returns(method.getReturnClass()).addStatement("return $T.getInstance().executeBatch($L)", dataSourceClazz, batchBuilder).build());
			TypeSpec liveDataBuilder = liveDataBuilderBuilder.build();

			methodBuilder.addStatement("final $T builder=$L", ParameterizedTypeName.get(handlerClass, method.getReturnClass()), liveDataBuilder);
		} else {
			TypeSpec batchBuilder = TypeSpec.anonymousClassBuilder("").addSuperinterface(ParameterizedTypeName.get(batchClazz, method.getReturnClass()))
					.addMethod(MethodSpec.methodBuilder("onExecute").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC)
							.addParameter(ParameterSpec.builder(daoFactoryClazz, "daoFactory").build()).returns(method.getReturnClass())
							.addStatement("return daoFactory.get$L().$L($L)", daoDefinition.getName(), method.getName() + LIVE_DATA_PREFIX, buffer.toString()).build())
					.build();

			TypeSpec.Builder liveDataBuilderBuilder = TypeSpec.anonymousClassBuilder("").addSuperinterface(ParameterizedTypeName.get(handlerClass, method.getReturnClass()))
					.addMethod(MethodSpec.methodBuilder("compute").addAnnotation(Override.class).addModifiers(Modifier.PROTECTED).returns(method.getReturnClass())
							.addStatement("return $T.getInstance().executeBatch($L)", dataSourceClazz, batchBuilder).build());
			TypeSpec liveDataBuilder = liveDataBuilderBuilder.build();

			methodBuilder.addStatement("final $T builder=$L", ParameterizedTypeName.get(handlerClass, method.getReturnClass()), liveDataBuilder);
		}

		methodBuilder.addStatement("registryLiveData(builder)");
		methodBuilder.addStatement("return builder.getLiveData()");

		classBuilder.addMethod(methodBuilder.build());
	}
1043749
private static void generateParseOnJackson(BindTypeContext context, BindEntity entity) {
		// @formatter:off
		MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("parseOnJackson").addJavadoc("parse with jackson\n")
				.addAnnotation(Override.class).addModifiers(Modifier.PUBLIC)
				// .addParameter(typeName(AbstractJacksonContext.class),
				// "context")
				.addParameter(typeName(JsonParser.class), "jacksonParser").returns(typeName(entity.getElement()))
				.addException(Exception.class);
		// @formatter:on

		boolean mutableObject = entity.isMutablePojo();

		if (mutableObject) {
			methodBuilder.addStatement("$T instance = new $T()", entity.getElement(), entity.getElement());
		} else {
			ImmutableUtility.generateImmutableVariableInit(entity, methodBuilder);
		}
		methodBuilder.addStatement("String fieldName");

		methodBuilder.beginControlFlow("if (jacksonParser.currentToken() == null)");
		methodBuilder.addStatement("jacksonParser.nextToken()");
		methodBuilder.endControlFlow();

		methodBuilder.beginControlFlow("if (jacksonParser.currentToken() != $T.START_OBJECT)", JsonToken.class);
		methodBuilder.addStatement("jacksonParser.skipChildren()");
		if (!mutableObject) {
			ImmutableUtility.generateImmutableEntityCreation(entity, methodBuilder, "instance", true);
		}
		methodBuilder.addStatement("return instance");
		methodBuilder.endControlFlow();

		methodBuilder.beginControlFlow("while (jacksonParser.nextToken() != $T.END_OBJECT)", JsonToken.class);
		methodBuilder.addStatement("fieldName = jacksonParser.getCurrentName()");
		methodBuilder.addStatement("jacksonParser.nextToken()");

		if (entity.getCollection().size() > 0) {
			methodBuilder.addCode("\n// Parse fields:\n");
			methodBuilder.beginControlFlow("switch (fieldName)$>");

			BindTransform bindTransform;
			for (BindProperty item : entity.getCollection()) {
				bindTransform = BindTransformer.lookup(item);

				methodBuilder.addCode("case $S:\n$>", item.label);
				methodBuilder.addCode("// field $L (mapped with $S)\n", item.getName(), item.label);

				bindTransform.generateParseOnJackson(context, methodBuilder, "jacksonParser",
						item.getPropertyType().getTypeName(), "instance", item);

				methodBuilder.addCode("$<break;\n");
			}

			methodBuilder.addCode("default:$>\n");
			methodBuilder.addStatement("jacksonParser.skipChildren()");
			methodBuilder.addCode("$<break;");

			methodBuilder.addCode("$<");
			methodBuilder.endControlFlow();
		} else {
			methodBuilder.addCode("\n// No field to parse\n");
		}

		methodBuilder.endControlFlow();

		if (!mutableObject) {
			ImmutableUtility.generateImmutableEntityCreation(entity, methodBuilder, "instance", true);
		}
		methodBuilder.addStatement("return instance");

		context.builder.addMethod(methodBuilder.build());

	}
1292799
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 != XmlType.VALUE && property.xmlInfo.xmlType != XmlType.VALUE_CDATA)
				continue;

			count++;
			methodBuilder.beginControlFlow("if (elementName!=null && $L.hasText())", parserName);
			methodBuilder.addCode("// property $L\n", property.getName());
			bindTransform = BindTransformer.lookup(property);
			bindTransform.generateParseOnXml(context, methodBuilder, parserName,
					property.getPropertyType().getTypeName(), "instance", property);
			methodBuilder.endControlFlow();
		}

		if (count == 0) {
			methodBuilder.addCode("// no property is binded to VALUE o CDATA ");
		}
	}
402148
public MultipleObjectsBundle generate() {
    // we actually need some clusters.
    if(generators.isEmpty()) {
      throw new AbortException("No clusters specified.");
    }
    // Assert that cluster dimensions agree.
    final int dim = generators.get(0).getDim();
    for(GeneratorInterface c : generators) {
      if(c.getDim() != dim) {
        throw new AbortException("Cluster dimensions do not agree.");
      }
    }
    // Prepare result bundle
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<>(DoubleVector.FACTORY, dim);
    bundle.appendColumn(type, new ArrayList<>());
    bundle.appendColumn(TypeUtil.CLASSLABEL, new ArrayList<>());
    bundle.appendColumn(Model.TYPE, new ArrayList<Model>());

    // generate clusters
    ClassLabel[] labels = new ClassLabel[generators.size()];
    Model[] models = new Model[generators.size()];
    initLabelsAndModels(generators, labels, models, relabelClusters);
    final AssignPoint assignment;
    if(!testAgainstModel) {
      assignment = new AssignPoint();
    }
    else if(relabelClusters == null) {
      assignment = new TestModel();
    }
    else if(!relabelDistance) {
      assignment = new AssignLabelsByDensity(labels);
    }
    else {
      assignment = new AssignLabelsByDistance(labels);
    }
    for(int i = 0; i < labels.length; i++) {
      final GeneratorInterface curclus = generators.get(i);
      assignment.newCluster(i, curclus);
      // Only dynamic generators allow rejection / model testing:
      GeneratorInterfaceDynamic cursclus = (curclus instanceof GeneratorInterfaceDynamic) ? (GeneratorInterfaceDynamic) curclus : null;
      int kept = 0;
      while(kept < curclus.getSize()) {
        // generate the "missing" number of points
        List<double[]> newp = curclus.generate(curclus.getSize() - kept);
        for(double[] p : newp) {
          int bestc = assignment.getAssignment(i, p);
          if(bestc < 0) {
            cursclus.incrementDiscarded();
            continue;
          }
          bundle.appendSimple(DoubleVector.wrap(p), labels[bestc], models[bestc]);
          ++kept;
        }
      }
    }
    return bundle;
  }
17841
private void generateEncode(TypeToken<?> outputType, Schema schema) {
    TypeToken<?> callOutputType = getCallTypeToken(outputType, schema);

    Method encodeMethod = getMethod(void.class, "encode", callOutputType.getRawType(), Encoder.class);

    if (!Object.class.equals(callOutputType.getRawType())) {
      // Generate the synthetic method for the bridging
      Method method = getMethod(void.class, "encode", Object.class, Encoder.class);
      GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC + Opcodes.ACC_BRIDGE + Opcodes.ACC_SYNTHETIC,
                                                 method, null, new Type[] {Type.getType(IOException.class)},
                                                 classWriter);

      mg.loadThis();
      mg.loadArg(0);
      mg.checkCast(Type.getType(callOutputType.getRawType()));
      mg.loadArg(1);
      mg.invokeVirtual(classType, encodeMethod);
      mg.returnValue();
      mg.endMethod();
    }

    // Generate the top level public encode method
    String methodSignature = null;
    if (callOutputType.getType() instanceof ParameterizedType) {
      methodSignature = Signatures.getMethodSignature(encodeMethod, new TypeToken[]{callOutputType, null});
    }
    GeneratorAdapter mg = new GeneratorAdapter(Opcodes.ACC_PUBLIC, encodeMethod, methodSignature,
                              new Type[] {Type.getType(IOException.class)}, classWriter);

    // Delegate to the actual encode method(value, encoder, schema, Sets.newIdentityHashSet());
    mg.loadThis();
    mg.loadArg(0);
    mg.loadArg(1);
    mg.loadThis();
    mg.getField(classType, "schema", Type.getType(Schema.class));
    // seenRefs Set
    mg.invokeStatic(Type.getType(Sets.class), getMethod(Set.class, "newIdentityHashSet"));
    mg.invokeVirtual(classType, getEncodeMethod(outputType, schema));
    mg.returnValue();
    mg.endMethod();
  }
446010
@Override
    public void initialize(Map<String, Object> externalProperty)
    {
        reader = new CassandraEntityReader(kunderaMetadata);
        initializePropertyReader();
        setExternalProperties(externalProperty);

        configuration = new CassandraHostConfiguration(externalProperties, CassandraPropertyReader.csmd,
                getPersistenceUnit(), kunderaMetadata);

        // initialize timestamp generator.
        initializeTimestampGenerator(externalProperty);
    }
816187
public static String generate(Filer filer, BindEntity item) throws IOException {
		Elements elementUtils = BaseProcessor.elementUtils;

		String beanClassName = item.getSimpleName().toString();

		boolean needSuffix = true;
		if (beanClassName.endsWith(SUFFIX)) {
			needSuffix = false;
		}

		String className = PREFIX + beanClassName + (needSuffix ? SUFFIX : "");

		PackageElement pkg = elementUtils.getPackageOf(item.getElement());
		String packageName = pkg.isUnnamed() ? "" : pkg.getQualifiedName().toString();

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindType.class, packageName, className);

		// @formatter:off
		TypeSpec.Builder builder = TypeSpec.classBuilder(className)
				.addAnnotation(AnnotationSpec.builder(BindMap.class)
						.addMember("value", "$T.class", typeName(item.getElement().asType())).build())
				.addModifiers(Modifier.PUBLIC).superclass(TypeUtility
						.parameterizedTypeName(className(AbstractMapper.class), typeName(item.getElement().asType())));

		BindTypeContext context = new BindTypeContext(builder, TypeUtility.typeName(packageName, className),
				Modifier.PRIVATE);
		// @formatter:on
		builder.addJavadoc("This class is binder map for $T\n\n", item.getElement());
		JavadocUtility.generateJavadocGeneratedBy(builder);
		builder.addJavadoc("@see $T\n", item.getElement());

		// order item by order, property typeName
		Collections.sort(item.getCollection(), new Comparator<BindProperty>() {

			@Override
			public int compare(BindProperty lhs, BindProperty rhs) {
				int c1 = lhs.order - rhs.order;
				if (c1 != 0)
					return c1;

				return lhs.getName().compareTo(rhs.getName());
			}
		});

		// generate serializeOnJackson
		generateSerializeOnJackson(context, item);

		// generate serializeOnJacksonAsString
		generateSerializeOnJacksonAsString(context, item);

		// order item by type (attribute, element, value), order, xmlName
		Collections.sort(item.getCollection(), new Comparator<BindProperty>() {

			@Override
			public int compare(BindProperty lhs, BindProperty rhs) {
				int c1 = lhs.xmlInfo.xmlType.ordinal() - rhs.xmlInfo.xmlType.ordinal();
				if (c1 != 0)
					return c1;

				c1 = lhs.order - rhs.order;
				if (c1 != 0)
					return c1;

				return lhs.label.compareTo(rhs.label);
			}
		});

		// generate serializeOnXml
		generateSerializeOnXml(context, item);

		// generate parseOnJackson
		generateParseOnJackson(context, item);

		// generate parseOnJacksonAsString
		generateParseOnJacksonAsString(context, item);

		// generate parseOnXml
		generateParseOnXml(context, item);

		TypeSpec typeSpec = builder.build();

		JavaWriterHelper.writeJava2File(filer, packageName, typeSpec);

		return className;
	}
327956
private static ClientFactory instantiateClientFactory(String persistenceUnit, Map<String, Object> puProperties,
            final KunderaMetadata kunderaMetadata)
    {
        ClientFactory clientFactory = null;
        logger.info("Initializing client factory for: " + persistenceUnit);
        PersistenceUnitMetadata persistenceUnitMetadata = kunderaMetadata.getApplicationMetadata()
                .getPersistenceUnitMetadata(persistenceUnit);
        String kunderaClientFactory = puProperties != null ? (String) puProperties
                .get(PersistenceProperties.KUNDERA_CLIENT_FACTORY) : null;
        if (kunderaClientFactory == null)
        {
            kunderaClientFactory = persistenceUnitMetadata.getProperties().getProperty(
                    PersistenceProperties.KUNDERA_CLIENT_FACTORY);
        }

        if (kunderaClientFactory == null)
        {
            throw new ClientResolverException(
                    "<kundera.client.lookup.class> is missing from persistence.xml, please provide specific client factory. e.g., <property name=\"kundera.client.lookup.class\" value=\"com.impetus.client.cassandra.pelops.PelopsClientFactory\" />");
        }
        try
        {
            clientFactory = (ClientFactory) Class.forName(kunderaClientFactory).newInstance();

            Method m = GenericClientFactory.class.getDeclaredMethod("setPersistenceUnit", String.class);
            if (!m.isAccessible())
            {
                m.setAccessible(true);
            }

            m.invoke(clientFactory, persistenceUnit);

            m = GenericClientFactory.class.getDeclaredMethod("setExternalProperties", Map.class);
            if (!m.isAccessible())
            {
                m.setAccessible(true);
            }

            m.invoke(clientFactory, puProperties);
            
            m = GenericClientFactory.class.getDeclaredMethod("setKunderaMetadata", KunderaMetadata.class);
            if (!m.isAccessible())
            {
                m.setAccessible(true);
            }

            m.invoke(clientFactory, kunderaMetadata);
            
        }
        catch (InstantiationException e)
        {
            onError(e);
        }
        catch (IllegalAccessException e)
        {
            onError(e);
        }
        catch (ClassNotFoundException e)
        {
            onError(e);
        }
        catch (SecurityException e)
        {
            onError(e);
        }
        catch (NoSuchMethodException e)
        {
            onError(e);
        }
        catch (IllegalArgumentException e)
        {
            onError(e);
        }
        catch (InvocationTargetException e)
        {
            onError(e);
        }

        if (clientFactory == null)
        {
            logger.error("Client Factory Not Configured For Specified Client Type : ");
            throw new ClientResolverException("Client Factory Not Configured For Specified Client Type.");
        }
        logger.info("Finishing factory initialization");
        return clientFactory;
    }
63043
public void generate(GeneratorOutput genOut) throws CodeGenerationException
    {
        //
        // Create a new VelocityContext
        //
        VelocityContext vc = new VelocityContext();

        //
        // Transfer any code generation properties excepted by the templates into the context
        // 
        HashMap<String,Object> genContext = genOut.getContext();
        for(String key : genContext.keySet())
            vc.put(key, genContext.get(key));

        try
        {
            Writer genWriter = genOut.getWriter();
            Template template = getTemplate(genOut.getTemplateName());
            template.merge(vc, genWriter);    
            genWriter.close();
        }
        // never wrap RuntimeException
        catch (RuntimeException re) {
            throw re;
        }
        catch (Exception e) {
            throw new CodeGenerationException(e);
        }
    }
317403
public void generateJavaDoc(MethodSpec.Builder methodBuilder, final SQLiteModelMethod method, TypeName returnType,
			List<SQLProperty> listUsedProperty, ModelProperty primaryKey) {
		// transform JQL to SQL
		String sqlInsert = JQLChecker.getInstance().replace(method, method.jql, new JQLReplacerListenerImpl(method) {

			@Override
			public String onColumnName(String columnName) {
				Set<SQLProperty> property = currentSchema.getPropertyBySimpleName(columnName);

				SQLProperty tempProperty = property.iterator().next();
				AssertKripton.assertTrueOrUnknownPropertyInJQLException(tempProperty != null, method, columnName);

				return tempProperty.columnName;
			}

			@Override
			public String onBindParameter(String bindParameterName, boolean inStatement) {
				String resolvedParamName = method.findParameterNameByAlias(bindParameterName);

				return SqlAnalyzer.PARAM_PREFIX + resolvedParamName + SqlAnalyzer.PARAM_SUFFIX;
			}

		});

		// generate javadoc and result
		{
			String beanNameParameter = method.findParameterAliasByName(method.getParameters().get(0).value0);

			methodBuilder.addJavadoc("<h2>SQL insert</h2>\n");
			methodBuilder.addJavadoc("<pre>$L</pre>\n\n", sqlInsert);
			methodBuilder.addJavadoc(
					"<p><code>$L.$L</code> is automatically updated because it is the primary key</p>\n",
					beanNameParameter, primaryKey.getName());
			methodBuilder.addJavadoc("\n");

			// list of inserted fields
			methodBuilder.addJavadoc("<p><strong>Inserted columns:</strong></p>\n");
			methodBuilder.addJavadoc("<dl>\n");
			for (SQLProperty property : listUsedProperty) {
				methodBuilder.addJavadoc("\t<dt>$L</dt>", property.columnName);
				methodBuilder.addJavadoc("<dd>is mapped to <strong>$L</strong></dd>\n",
						SqlAnalyzer.PARAM_PREFIX + method.findParameterAliasByName(method.getParameters().get(0).value0)
								+ "." + method.findParameterNameByAlias(property.getName()) + SqlAnalyzer.PARAM_SUFFIX);
			}
			methodBuilder.addJavadoc("</dl>\n\n");

			// update bean have only one parameter: the bean to update
			for (Pair<String, TypeName> param : method.getParameters()) {
				methodBuilder.addJavadoc("@param $L", param.value0);
				methodBuilder.addJavadoc("\n\tis mapped to parameter <strong>$L</strong>\n",
						method.findParameterAliasByName(param.value0));
			}

			InsertRawHelper.generateJavaDocReturnType(methodBuilder, returnType);
		}
	}
676374
public static String generate(Elements elementUtils, Filer filer, PrefsEntity entity) throws IOException {
		com.abubusoft.kripton.common.Converter<String, String> converter = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.LOWER_CAMEL);
		String beanClassName = entity.getElement().getSimpleName().toString();
		String className = getBuildPreferenceName(entity);
		ModelAnnotation annotation = entity.getAnnotation(BindSharedPreferences.class);
		String sharedPreferenceName = annotation.getAttribute(AnnotationAttributeType.VALUE);
		boolean generateRx = entity.hasRxProperties();
		boolean generateLiveData = entity.hasLiveDataProperties();

		PackageElement pkg = elementUtils.getPackageOf(entity.getElement());
		String packageName = pkg.isUnnamed() ? "" : pkg.getQualifiedName().toString();

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindSharedPreferences.class, packageName, className);
		// @formatter:off
		builder = TypeSpec.classBuilder(className).addModifiers(Modifier.PUBLIC)
				.superclass(AbstractSharedPreference.class);

		BindTypeContext context = new BindTypeContext(builder, TypeUtility.typeName(entity.getElement()),
				Modifier.PRIVATE);

		// @formatter:on	
		builder.addJavadoc("This class is the shared preference binder defined for $T\n\n", entity.getElement());
		JavadocUtility.generateJavadocGeneratedBy(builder);
		builder.addJavadoc("@see $T\n", entity.getElement());

		if (StringUtils.hasText(sharedPreferenceName)) {
			builder.addField(FieldSpec.builder(String.class, "SHARED_PREFERENCE_NAME", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
					.initializer("$S", converter.convert(entity.getSimpleName().toString())).addJavadoc("shared preferences typeName for $T\n", entity.getElement()).build());
		}

		builder.addField(FieldSpec.builder(className(beanClassName), "defaultBean", Modifier.PRIVATE, Modifier.FINAL).addJavadoc("working instance of bean\n").build());

		{
			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder("edit").addJavadoc("create an editor to modify shared preferences\n").returns(typeName("BindEditor"))
					.addModifiers(Modifier.PUBLIC);
			methodBuilder.addStatement("return new $T()", typeName("BindEditor"));
			builder.addMethod(methodBuilder.build());
		}

		generateEditor(entity);

		generateCreate(sharedPreferenceName, beanClassName, generateRx, generateLiveData);

		generateConstructor(entity, sharedPreferenceName, beanClassName);

		generateRefresh(sharedPreferenceName, className);

		generateRxSupport(sharedPreferenceName, beanClassName, generateRx, entity);

		generateLiveDataSupport(sharedPreferenceName, beanClassName, generateLiveData, entity);

		generateResetMethod(entity);

		generateReadMethod(entity);

		generateWriteMethod(entity);

		generateSingleReadMethod(entity);

		// generate all needed writer and reader
		List<PrefsProperty> fields = entity.getCollection();
		List<PrefsProperty> filteredFields = new ArrayList<>();

		// we need to avoid generation of persists values
		for (PrefsProperty item : fields) {
			if (SetPrefsTransformation.isStringSet(item)) {
				continue;
			} else {
				filteredFields.add(item);
			}
		}

		// avoid to consider StringSet
		ManagedPropertyPersistenceHelper.generateFieldPersistance(context, filteredFields, PersistType.STRING, false, Modifier.PROTECTED);

		generateInstance(className);

		TypeSpec typeSpec = builder.build();
		JavaWriterHelper.writeJava2File(filer, packageName, typeSpec);

		return className;
	}
909416
private void generatePopulate(SQLiteDatabaseSchema schema, MethodSpec.Builder methodBuilder, boolean instance) {

		methodBuilder.beginControlFlow("try");
		methodBuilder.addStatement("instance.openWritableDatabase()");
		methodBuilder.addStatement("instance.close()");

		if ((instance && schema.configPopulatorClazz != null) || (!instance)) {
			methodBuilder.addComment("force database DDL run");
			methodBuilder.beginControlFlow("if (options.populator!=null && instance.justCreated)");
			methodBuilder.addComment("run populator only a time");
			methodBuilder.addStatement("instance.justCreated=false");

			// populator manage its connection
			// methodBuilder.beginControlFlow("try");
			// methodBuilder.addStatement("$T
			// currentDb=instance.openWritableDatabase()",
			// SQLiteDatabase.class);
			methodBuilder.addComment("run populator");
			methodBuilder.addStatement("options.populator.execute()");

			// methodBuilder.nextControlFlow("finally");
			// methodBuilder.addStatement("instance.close()");
			// methodBuilder.endControlFlow();

			methodBuilder.endControlFlow();
		}
		methodBuilder.nextControlFlow("catch($T e)", Throwable.class);
		methodBuilder.addStatement("$T.error(e.getMessage())", Logger.class);
		methodBuilder.addStatement("e.printStackTrace()");

		methodBuilder.endControlFlow();
	}
1244418
public void generate() throws CodeGenerationException
    {
        for (AnnotationTypeDeclaration atd : _atds)
        {
            Collection<Declaration> decls = getAnnotationProcessorEnvironment().getDeclarationsAnnotatedWith(atd);
            for (Declaration decl : decls)
            {
                generate(decl);
            }
        }
    }
549896
protected void _generate(SarlAnnotationType annotation, PyAppendable it, IExtraLanguageGeneratorContext context) {
		generateTypeDeclaration(
				this.qualifiedNameProvider.getFullyQualifiedName(annotation).toString(),
				annotation.getName(), false, Collections.emptyList(),
				getTypeBuilder().getDocumentation(annotation),
				true,
				annotation.getMembers(), it, context, null);
	}
1111766
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 = BindDaoFactoryBuilder.generateDaoFactoryName(schema);

		BindDataSourceBuilder visitorDao = new BindDataSourceBuilder(elementUtils, filer, schema);
		visitorDao.buildDataSource(elementUtils, filer, schema, daoFactoryName);

		generateSchema(schema);
	}
337904
public void generateReport (ClientObject caller, String type,
                                PeerService.ResultListener listener)
        throws InvocationException
    {
        listener.requestProcessed(_repmgr.generateReport(type));
    }