Builds a builder for REST data views
168544
function ResourceView(opts) {
	var view = this;

	var compute_keys;
	if(opts && opts.compute_keys) {
		compute_keys = opts.compute_keys;
	}

	var element_keys;
	if(opts && opts.element_keys) {
		element_keys = opts.element_keys;
	}

	var collection_keys;
	if(opts && opts.collection_keys) {
		collection_keys = opts.collection_keys;
	}

	var element_post;
	if(opts && opts.element_post) {
		element_post = opts.element_post;
	}

	var collection_post;
	if(opts && opts.collection_post) {
		collection_post = opts.collection_post;
	}

	opts = copy(opts || {});

	debug.assert(opts).is('object');
	debug.assert(opts.path).is('string');

	view.opts = {};
	view.opts.keys = opts.keys || ['$id', '$type', '$ref'];
	view.opts.path = opts.path;
	view.opts.elementPath = opts.elementPath;

	view.Type = opts.Type;

	if(is.obj(compute_keys)) {
		view.compute_keys = compute_keys;
	}

	if(is.obj(element_keys)) {
		view.element_keys = element_keys;
	}

	if(is.obj(collection_keys)) {
		view.collection_keys = collection_keys;
	}

	if(is.func(element_post)) {
		view.element_post = element_post;
	}

	if(is.func(collection_post)) {
		view.collection_post = collection_post;
	}

	//debug.log("view.opts = ", view.opts);
}
266195
def build(self, builder):
        """"""
        params = dict()

        if self.variable_oid is not None:
            params["VariableOID"] = self.variable_oid

        if self.data_format is not None:
            params["DataFormat"] = self.data_format

        if self.folder_oid is not None:
            params["FolderOID"] = self.folder_oid

        if self.field_oid is not None:
            params["FieldOID"] = self.field_oid

        if self.form_oid is not None:
            params["FormOID"] = self.form_oid

        if self.static_value is not None:
            params["StaticValue"] = self.static_value

        if self.function is not None:
            params["Function"] = self.function.value

        if self.custom_function is not None:
            params["CustomFunction"] = self.custom_function

        if self.record_position is not None:
            params["RecordPosition"] = str(self.record_position)

        if self.form_repeat_number is not None:
            params["FormRepeatNumber"] = str(self.form_repeat_number)

        if self.folder_repeat_number is not None:
            params["FolderRepeatNumber"] = str(self.folder_repeat_number)

        if self.logical_record_position is not None:
            params["LogicalRecordPosition"] = self.logical_record_position.value

        builder.start("mdsol:CheckStep", params)
        builder.end("mdsol:CheckStep")
1127348
def view_create(self, data, **kwargs):
        ""
        api_path = "/api/v2/views.json"
        return self.call(api_path, method="POST", data=data, **kwargs)
1200004
def build_filters(self, view, filters=None):
        
        query_builder = self.get_query_builder(backend=self, view=view)
        return query_builder.build_query(**(filters if filters else {}))
59024
public Builder toBuilder() {
		return builder(_version, _creator)
			.metadata(_metadata)
			.wayPoints(_wayPoints)
			.routes(_routes)
			.tracks(_tracks);
	}
115280
@Override
	public void generate(TypeSpec.Builder classBuilder, boolean mapFields, SQLiteModelMethod method) {
		// SQLiteDaoDefinition daoDefinition = method.getParent();
		String pagedResultName = buildSpecializedPagedResultClass(classBuilder, method);

		Set<JQLProjection> fieldList = JQLChecker.getInstance().extractProjections(method, method.jql.value, method.getEntity());

		{
			MethodSpec.Builder methodBuilder = generateMethodBuilder(method);

			// create PaginatedResult
			createPagedResult(method, pagedResultName, methodBuilder);

			generateCommonPart(method, classBuilder, methodBuilder, fieldList, GenerationType.NO_CONTENT, null, true, false);
			methodBuilder.addStatement("return paginatedResult");

			if (!method.isPagedLiveData()) {
				classBuilder.addMethod(methodBuilder.build());
			}
		}
		
		String selectTotalCountMethodName=method.getName() + "TotalCount";

		// generate paged result method
		{
			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(method.getName()).addModifiers(Modifier.PRIVATE);
			generateMethodSignature(method, methodBuilder, TypeUtility.parameterizedTypeName(TypeUtility.className(List.class), TypeUtility.typeName(method.getEntity().getElement())),
					ParameterSpec.builder(TypeUtility.typeName(pagedResultName), "paginatedResult").build());
			
			generateTotalCountUsage(method, methodBuilder, "paginatedResult", selectTotalCountMethodName);

			generateCommonPart(method, classBuilder, methodBuilder, fieldList, GenerationType.NO_METHOD_SIGN, null, false, false,
					JavadocPart.build(JavadocPartType.ADD_PARAMETER, "paginatedResult", "handler of paginated result"), JavadocPart.build(JavadocPartType.RETURN, "", "result list"));

			methodBuilder.addComment("Specialized part II - $L - BEGIN", this.getClass().getSimpleName());
			generateSpecializedPart(method, classBuilder, methodBuilder, fieldList, selectType.isMapFields());
			methodBuilder.addComment("Specialized part II - $L - END", this.getClass().getSimpleName());

			classBuilder.addMethod(methodBuilder.build());
		}

		// generate select count method
		{
			Set<JQLProjection> countfields = new HashSet<>();
			countfields.add(JQLProjection.ProjectionBuilder.create().expression("count(*)").build());

			MethodSpec.Builder methodBuilder = MethodSpec.methodBuilder(selectTotalCountMethodName).addModifiers(Modifier.PRIVATE);
			generateMethodSignature(method, methodBuilder, TypeName.INT, ParameterSpec.builder(TypeUtility.typeName(pagedResultName), "paginatedResult").build());

			generateCommonPart(method, classBuilder, methodBuilder, countfields, GenerationType.NO_METHOD_SIGN, TypeName.INT, false, true,
					JavadocPart.build(JavadocPartType.ADD_PARAMETER, "paginatedResult", "handler of paginated result"), JavadocPart.build(JavadocPartType.RETURN, "", "total row count"));

			methodBuilder.addComment("Specialized part II - $L - BEGIN", this.getClass().getSimpleName());
			generateTotalSpecializedPart(method, methodBuilder);
			methodBuilder.addComment("Specialized part II - $L - END", this.getClass().getSimpleName());

			classBuilder.addMethod(methodBuilder.build());
		}

	}
44649
def build(self, builder):
        
        builder.start("ReasonForChange", {})
        builder.data(self.reason)
        builder.end("ReasonForChange")
671760
@SuppressWarnings("unchecked")
    public List<T> build() {
        final List<T> retValue = new ArrayList<T>();
        for (final RESTBaseElementV1<?> element : entities) {
            final T wrapper = RESTEntityWrapperBuilder.newBuilder()
                    .providerFactory(providerFactory)
                    .entity(element)
                    .isRevision(isRevisionList)
                    .wrapperInterface(wrapperClass)
                    .parent(parent)
                    .build();
            retValue.add(wrapper);
        }

        return retValue;
    }
1160017
def build(_resource, _cache=True, **kwargs):
    
    return _SCHEMAFACTORY.build(_resource=_resource, _cache=True, **kwargs)
696180
public void build(Elements elementUtils, Filer filer, SQLiteDatabaseSchema schema) throws Exception {
		uriSet.clear();

		String dataSourceName = schema.getName();
		String dataSourceNameClazz = BindDataSourceBuilder.PREFIX + dataSourceName;
		String contentProviderName = PREFIX + dataSourceName.replace(BindDataSourceBuilder.SUFFIX, "") + SUFFIX;

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

		AnnotationProcessorUtilis.infoOnGeneratedClasses(BindContentProvider.class, packageName, contentProviderName);
		classBuilder = TypeSpec.classBuilder(contentProviderName).addModifiers(Modifier.PUBLIC).superclass(ContentProvider.class);

		classBuilder.addJavadoc("<p>This is the content provider generated for {@link $L}</p>\n\n", dataSourceName);

		classBuilder.addJavadoc("<h2>Content provider authority:</h2>\n");
		classBuilder.addJavadoc("<pre>$L</pre>\n\n", schema.contentProvider.authority);

		generateOnCreate(dataSourceNameClazz);
		generateOnShutdown(dataSourceNameClazz);

		// define static fields
		classBuilder.addField(FieldSpec.builder(String.class, "URI", Modifier.STATIC, Modifier.PUBLIC, Modifier.FINAL).initializer("$S", schema.contentProviderUri())
				.addJavadoc("<p>content provider's URI.</p>\n<pre>$L</pre>\n", schema.contentProviderUri()).build());

		// instance
		classBuilder.addField(FieldSpec.builder(className(dataSourceNameClazz), "dataSource", Modifier.PRIVATE, Modifier.STATIC).addJavadoc("<p>datasource singleton</p>\n").build());
		classBuilder.addField(FieldSpec.builder(String.class, "AUTHORITY", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL).addJavadoc("<p>Content provider authority</p>\n")
				.initializer("$S", schema.contentProvider.authority).build());
		classBuilder.addField(FieldSpec.builder(UriMatcher.class, "sURIMatcher", Modifier.PRIVATE, Modifier.STATIC, Modifier.FINAL).addJavadoc("<p>URI matcher</p>\n")
				.initializer("new $T($T.NO_MATCH)", UriMatcher.class, UriMatcher.class).build());

		Builder staticBuilder = CodeBlock.builder();
		Converter<String, String> daoConstantConverter = CaseFormat.UPPER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE);

		List<FieldSpec> listFieldUri = new ArrayList<>();
		List<FieldSpec> listFieldString = new ArrayList<>();
		List<FieldSpec> listFieldIndex = new ArrayList<>();
		List<FieldSpec> listFieldAlias = new ArrayList<>();

		for (SQLiteDaoDefinition daoDefinition : schema.getCollection()) {
			String pathConstantName = "PATH_" + daoConstantConverter.convert(daoDefinition.getEntitySimplyClassName());

			if (!daoDefinition.contentProviderEnabled)
				continue;

			// define content provider paths
			for (SQLiteModelMethod daoMethod : daoDefinition.getCollection()) {
				if (!daoMethod.contentProviderEntryPathEnabled)
					continue;

				ContentEntry entry = uriSet.get(daoMethod.contentProviderEntryPathTemplate);
				if (entry == null) {
					entry = new ContentEntry(daoMethod.contentProviderEntryPath);
					uriSet.put(daoMethod.contentProviderEntryPathTemplate, entry);

					entry.path = daoMethod.contentProviderEntryPath;
					entry.uriTemplate = daoMethod.contentProviderEntryPathTemplate;

					// we finish later
					entry.pathCostant = pathConstantName;
					entry.pathIndex = pathConstantName;
				}

				switch (daoMethod.jql.operationType) {
				case INSERT:
					AssertKripton.fail(entry.insert != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.insert = daoMethod;
					break;
				case UPDATE:
					AssertKripton.fail(entry.update != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.update = daoMethod;
					break;
				case SELECT:
					AssertKripton.fail(entry.select != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.select = daoMethod;
					break;
				case DELETE:
					AssertKripton.fail(entry.delete != null, String.format("In DAO '%s', there are more than one %s statement associated to content provider path '%s'",
							daoDefinition.getName().toString(), daoMethod.jql.operationType, entry.path));
					entry.delete = daoMethod;
					break;

				}
			}
		}

		// sort uri set by
		List<Pair<String, ContentEntry>> listUriSet = new ArrayList<>();
		Pair<String, ContentEntry> item;
		for (Entry<String, ContentEntry> entry : uriSet.entrySet()) {
			item = new Pair<String, ContentEntry>(entry.getKey(), entry.getValue());
			listUriSet.add(item);
		}

		Comparator<Pair<String, ContentEntry>> c = new Comparator<Pair<String, ContentEntry>>() {

			@Override
			public int compare(Pair<String, ContentEntry> lhs, Pair<String, ContentEntry> rhs) {
				return lhs.value0.compareTo(rhs.value0);
			}

		};
		Collections.sort(listUriSet, c);

		Set<String> alreadyUsedName = new HashSet<String>();
		Converter<String, String> format = CaseFormat.LOWER_CAMEL.converterTo(CaseFormat.UPPER_UNDERSCORE);

		int i = 1;
		for (Pair<String, ContentEntry> entry : listUriSet) {
			// define ordered part of attributes (after sort)
			entry.value1.pathCostant += "_" + i;
			entry.value1.pathIndex += "_" + i + "_INDEX";
			entry.value1.pathValue = i;

			// build class attributes
			listFieldString.add(FieldSpec.builder(String.class, entry.value1.pathCostant, Modifier.STATIC, Modifier.FINAL).initializer(CodeBlock.of("$S", entry.value1.uriTemplate)).build());
			listFieldIndex.add(FieldSpec.builder(Integer.TYPE, entry.value1.pathIndex, Modifier.STATIC, Modifier.FINAL).initializer(CodeBlock.of("$L", entry.value1.pathValue)).build());

			listFieldUri.add(FieldSpec.builder(Uri.class, "URI_" + entry.value1.pathCostant, Modifier.STATIC, Modifier.FINAL, Modifier.PRIVATE).addJavadoc("<p>Uri</p>\n")
					.addJavadoc("<pre>$L/$L</pre>\n", schema.contentProviderUri().replace("*", "[*]"), entry.value1.uriTemplate.replace("*", "[*]"))
					.initializer(CodeBlock.of("Uri.parse(URI+\"/$L\")", entry.value1.uriTemplate)).build());

			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.delete);
			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.insert);
			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.select);
			generateURIForMethod(schema, listFieldAlias, alreadyUsedName, format, entry, entry.value1.update);

			staticBuilder.addStatement("sURIMatcher.addURI(AUTHORITY, $L, $L)", entry.value1.pathCostant, entry.value1.pathIndex);

			i++;
		}

		for (FieldSpec f : listFieldUri) {
			classBuilder.addField(f);
		}

		for (FieldSpec f : listFieldString) {
			classBuilder.addField(f);
		}

		for (FieldSpec f : listFieldIndex) {
			classBuilder.addField(f);
		}

		for (FieldSpec f : listFieldAlias) {
			classBuilder.addField(f);
		}

		classBuilder.addStaticBlock(staticBuilder.build());

		generateQuery(schema);

		generateInsert(schema);

		generateUpdate(schema);

		generateDelete(schema);

		generateGetType(schema);

		classBuilder.addJavadoc("\n\n");
		JavadocUtility.generateJavadocGeneratedBy(classBuilder);

		TypeSpec typeSpec = classBuilder.build();
		JavaWriterHelper.writeJava2File(filer, packageName, typeSpec);
	}
193993
def build(self, builder):
        """"""
        params = dict(OID=self.oid)
        if self.user_type:
            params.update(dict(UserType=self.user_type.value))
        builder.start(self.__class__.__name__, params)
        # build the children
        for child in ('login_name', 'display_name', 'full_name', 'first_name', 'last_name',
                      'organisation'):
            if getattr(self, child) is not None:
                getattr(self, child).build(builder)
        for address in self.addresses:
            address.build(builder)
        for email in self.emails:
            email.build(builder)
        for phone in self.phones:
            phone.build(builder)
        for location in self.locations:
            location.build(builder)
        builder.end(self.__class__.__name__)
363166
def build(self, builder):
        """"""
        params = dict(OID=self.oid,
                      Name=self.name)
        if self.location_type:
            params.update(dict(LocationType=self.location_type.value))
        # mixins
        self.mixin()
        self.mixin_params(params)
        builder.start("Location", params)
        for mdv in self.metadata_versions:
            mdv.build(builder)
        builder.end("Location")
1031021
function buildBuilder(mqttClient, opts) {
   var connection;

   connection = tls.connect(opts);

   function handleTLSerrors(err) {
      mqttClient.emit('error', err);
      connection.end();
   }

   connection.on('secureConnect', function() {
      if (!connection.authorized) {
         connection.emit('error', new Error('TLS not authorized'));
      } else {
         connection.removeListener('error', handleTLSerrors);
      }
   });

   connection.on('error', handleTLSerrors);
   return connection;
}
922564
def _setup_adapter(self, namespace, route_prefix):
        
        self.serializer = JSONAPI(
            self.sqla.Model, prefix='{}://{}{}'.format(
                self.app.config['PREFERRED_URL_SCHEME'],
                self.app.config['SERVER_NAME'], route_prefix))
        for view in views:
            method, endpoint = view
            pattern = route_prefix + endpoint.value
            name = '{}_{}_{}'.format(namespace, method.name, endpoint.name)
            view = self._generate_view(method, endpoint)
            self.app.add_url_rule(pattern + '/',
                                  name + '_slashed',
                                  view,
                                  methods=[method.name],
                                  strict_slashes=False)
            self.app.add_url_rule(pattern, name, view, methods=[method.name])
816053
static function build($request_name, $params, $helper = NULL) {
    return self::processSchema(self::getRequestSchema($request_name), $params, $helper);
  }
626305
private void defineJavadocHeaderForContentOperation(MethodSpec.Builder builder, String value) {
		builder.addJavadoc("\n<h2>Supported $L operations</h2>\n", value);
		builder.addJavadoc("<table>\n");
		builder.addJavadoc("<tr><th>URI</th><th>DAO.METHOD</th></tr>\n");

		classBuilder.addJavadoc("<h2>Supported $L operations</h2>\n", value);
		classBuilder.addJavadoc("<table>\n");
		classBuilder.addJavadoc("<tr><th>URI</th><th>DAO.METHOD</th></tr>\n");

	}
561669
private void buildConstructor( TypeSpec.Builder typeBuilder ) {
        MethodSpec.Builder constructorBuilder = MethodSpec.constructorBuilder().addModifiers( Modifier.PUBLIC );

        if ( !beanInfo.getParameterizedTypes().isEmpty() ) {
            Class mapperClass;
            String mapperNameFormat;
            if ( isSerializer() ) {
                mapperClass = Serializer.class;
                mapperNameFormat = TYPE_PARAMETER_SERIALIZER_FIELD_NAME;
            } else {
                mapperClass = Deserializer.class;
                mapperNameFormat = TYPE_PARAMETER_DESERIALIZER_FIELD_NAME;
            }

            for ( int i = 0; i < beanInfo.getParameterizedTypes().size(); i++ ) {
                JClassType argType = beanInfo.getParameterizedTypes().get( i );
                String mapperName = String.format( mapperNameFormat, i );
                TypeName mapperType = parameterizedName( mapperClass, argType );

                FieldSpec field = FieldSpec.builder( mapperType, mapperName, Modifier.PRIVATE, Modifier.FINAL ).build();
                typeBuilder.addField( field );

                ParameterSpec parameter = ParameterSpec.builder( mapperType, mapperName ).build();
                constructorBuilder.addParameter( parameter );
                constructorBuilder.addStatement( "this.$N = $N", field, parameter );
            }
        }

        typeBuilder.addMethod( constructorBuilder.build() );
    }