Add dynamic field_factories

 ==== Parameters

 field_factories<Array>:: Array of dynamic field objects
324904
def add_dynamic_field_factory(name, type, options = {}, &block)
      stored, more_like_this = options[:stored], options[:more_like_this]
      field_factory = FieldFactory::Dynamic.new(name, type, options, &block)
      @dynamic_field_factories[field_factory.signature] = field_factory
      @dynamic_field_factories_cache[field_factory.name] = field_factory
      if stored
        @stored_field_factories_cache[field_factory.name] << field_factory
      end
      if more_like_this
        @more_like_this_field_factories_cache[field_factory.name] << field_factory
      end
    end
1332413
def add_class2fields(self, html_class, fields=[], exclude=[], include_all_if_empty=True):
        
        self.add_attr2fields('class', html_class, fields, exclude)
539078
def define_dynamic_queries(roles)
      dynamic_module = Module.new do
        roles.each do |role|
          ["#{role}?".to_sym, "is_#{role}?".to_sym].each do |method|
            define_method(method) { is? role }
          end
        end
      end
      include dynamic_module
    end
773300
def add_to_fields(self):
        ''''''
        meta = self.model._meta
        meta.scalarfields.append(self)
        if self.index:
            meta.indices.append(self)
826468
public T newInstance(Map<String, Object> fields)
	{
		try
		{
			FactoryDefinition<T> bestDef = factories[0];
			int bestScore = bestDef.getScore(fields);

			for(int i=1, n=factories.length; i<n; i++)
			{
				int score = factories[i].getScore(fields);
				if(score > bestScore)
				{
					bestDef = factories[i];
					bestScore = score;
				}
			}

			return bestDef.create(fields);
		}
		catch(RuntimeException e)
		{
			throw new RuntimeException("Could not create " + type + "; " + e.getMessage(), e);
		}
	}
905051
@Reference(cardinality=ReferenceCardinality.MULTIPLE, policy=ReferencePolicy.DYNAMIC)
	public void addFactory(TaskSystemFactory factory) {
		logger.finer("Adding factory: " + factory);
		filters.add(factory);
	}
1327006
private function initFromArray(array $fieldArray = [])
    {
        foreach ($fieldArray as $fieldName => $fieldParams) {
            $this->addField($fieldName, Factory::get($fieldParams));
        }
    }
427882
def add_field_like(self, name, like_array):
        
        new_shape = list(like_array.shape)
        new_shape[0] = len(self)
        new_data = ma.empty(new_shape, like_array.dtype)
        new_data.mask = True
        self.add_field(name, new_data)
401753
protected void buildConstructorWithFields(ClassVisitor cw,
                                              ClassDefinition classDef,
                                              Collection<FieldDefinition> fieldDefs) {


        Type[] params = new Type[fieldDefs.size()];
        int index = 0;
        for ( FieldDefinition field : fieldDefs ) {
            params[index++] = Type.getType( BuildUtils.getTypeDescriptor( field.getTypeName() ) );
        }

        MethodVisitor mv = cw.visitMethod( Opcodes.ACC_PUBLIC,
                "<init>",
                Type.getMethodDescriptor( Type.VOID_TYPE,
                        params ),
                null,
                null );
        mv.visitCode();
        Label l0 = null;
        if ( this.debug ) {
            l0 = new Label();
            mv.visitLabel( l0 );
        }

        fieldConstructorStart( mv, classDef, fieldDefs );

        mv.visitInsn( Opcodes.RETURN );
        Label l1 = null;
        if ( this.debug ) {
            l1 = new Label();
            mv.visitLabel( l1 );
            mv.visitLocalVariable( "this",
                    BuildUtils.getTypeDescriptor( classDef.getClassName() ),
                    null,
                    l0,
                    l1,
                    0 );
            for ( FieldDefinition field : classDef.getFieldsDefinitions() ) {
                Label l11 = new Label();
                mv.visitLabel( l11 );
                mv.visitLocalVariable( field.getName(),
                        BuildUtils.getTypeDescriptor( field.getTypeName() ),
                        null,
                        l0,
                        l1,
                        0 );
            }
        }
        mv.visitMaxs( 0,
                0 );
        mv.visitEnd();

    }
65740
public void addDynamicMacro(String name, Factory factory) {

        if (m_factories == null) {
            m_factories = new HashMap<String, Factory>();
        }
        m_factories.put(name, factory);
    }
655203
def params_factory(schema: dict, add_message: bool) -> list:
    

    # Immediately create message as an argument
    params = []
    if add_message:
        params.append(click.Argument(["message"], required=False))

    for property, prpty_schema in schema.items():
        multiple = False
        choices = None

        if any(char in property for char in ["@"]):
            continue
        if prpty_schema.get("type") in COMPLEX_TYPES:
            continue
        if prpty_schema.get("duplicate"):
            continue
        if property == "message":
            continue

        elif not prpty_schema.get("oneOf"):
            click_type, description, choices = json_schema_to_click_type(prpty_schema)
        else:
            click_type, multiple, description = handle_oneof(prpty_schema["oneOf"])
            # Not all oneOf schema can be handled by click
            if not click_type:
                continue

        # Convert bool values into flags
        if click_type == click.BOOL:
            param_decls = [get_flag_param_decals_from_bool(property)]
            click_type = None
        else:
            param_decls = [get_param_decals_from_name(property)]

        if description:
            description = description.capitalize()

            if multiple:
                if not description.endswith("."):
                    description += "."
                description += " Multiple usages of this option are allowed"
        # Construct the base command options
        option = partial(
            click.Option, param_decls=param_decls, help=description, multiple=multiple
        )

        if choices:
            option = option(type=choices)
        elif click_type:
            option = option(type=click_type)
        else:
            option = option()
        params.append(option)
    return params
1243711
private static void configureFields(MdcGelfMessageAssembler mdcGelfMessageAssembler, GelfLogField[] fields,
            GelfDynamicMdcLogFields[] dynamicFieldArray) {

    	if (fields == null || fields.length == 0) {
            mdcGelfMessageAssembler.addFields(LogMessageField.getDefaultMapping(Time, Severity, ThreadName, SourceClassName,
                    SourceMethodName, SourceLineNumber, SourceSimpleClassName, LoggerName, Marker));
            return;
        }

        for (GelfLogField field : fields) {

            if (Strings.isNotEmpty(field.getMdc())) {
                mdcGelfMessageAssembler.addField(new MdcMessageField(field.getName(), field.getMdc()));
            }

            if (Strings.isNotEmpty(field.getLiteral())) {
                mdcGelfMessageAssembler.addField(new StaticMessageField(field.getName(), field.getLiteral()));
            }

            if (field.getPatternLayout() != null) {
                mdcGelfMessageAssembler.addField(new PatternLogMessageField(field.getName(), null, field.getPatternLayout()));
            }
        }

        if (dynamicFieldArray != null) {
            for (GelfDynamicMdcLogFields gelfDynamicMdcLogFields : dynamicFieldArray) {
                mdcGelfMessageAssembler.addField(new DynamicMdcMessageField(gelfDynamicMdcLogFields.getRegex()));
            }
        }
    }
570248
def add_fields(store_name, field_names):
    
    def decorate(cls):
        def _add(index, name):
            def _set_dir(self, value): getattr(self, store_name)[index] = value
            def _get_dir(self): return getattr(self, store_name)[index]
            setattr(cls, name, property(_get_dir, _set_dir))

        for index, field_name in enumerate(field_names):
            _add(index, field_name)

        return cls

    return decorate
237585
private void addPojoField(final TypeSpec.Builder classBuilder,
                              final MethodSpec.Builder constructorBuilder,
                              final String fieldName,
                              final TypeName fieldClass) {
        classBuilder.addField(fieldClass, fieldName, Modifier.PRIVATE, Modifier.FINAL);
        addGetter(classBuilder, fieldName, fieldClass);
        addConstructorParameter(constructorBuilder, fieldName, fieldClass);
    }
207908
public void addFields(List<ModelFieldBean> modelFields) {
		Assert.notNull(modelFields, "modelFields must not be null");

		for (ModelFieldBean bean : modelFields) {
			this.fields.put(bean.getName(), bean);
		}
	}
1158005
def dynamic_field_factories_hash
      @dynamic_field_factories_hash ||=
        begin
          dynamic_field_factories_hash = @types.inject({}) do |hash, type|
            Setup.for(type).dynamic_field_factories.each do |field_factory|
              (hash[field_factory.name.to_sym] ||= {})[type.name] = field_factory
            end
            hash
          end
          dynamic_field_factories_hash.each_pair do |field_name, field_configurations_hash|
            if @types.any? { |type| field_configurations_hash[type.name].nil? }
              dynamic_field_factories_hash.delete(field_name)
            else
              dynamic_field_factories_hash[field_name] = field_configurations_hash.values.first
            end
          end
        end
    end
486944
public static void setDynamicMdcFields(String spec, GelfMessageAssembler gelfMessageAssembler) {
        if (null != spec) {
            String[] fields = spec.split(MULTI_VALUE_DELIMITTER);

            for (String field : fields) {
                gelfMessageAssembler.addField(new DynamicMdcMessageField(field.trim()));
            }
        }
    }