Generates a schema from the given class with the declared fields (inclusive) based from the given Map. The value
of a the Map's entry will be the name used for the field (which enables aliasing).
434362
public static <T> RuntimeSchema<T> createFrom(Class<T> typeClass,
            Map<String, String> declaredFields, IdStrategy strategy)
    {
        if (typeClass.isInterface()
                || Modifier.isAbstract(typeClass.getModifiers()))
        {
            throw new RuntimeException(
                    "The root object can neither be an abstract "
                            + "class nor interface: \"" + typeClass.getName());
        }

        final ArrayList<Field<T>> fields = new ArrayList<Field<T>>(
                declaredFields.size());
        int i = 0;
        for (Map.Entry<String, String> entry : declaredFields.entrySet())
        {
            final java.lang.reflect.Field f;
            try
            {
                f = typeClass.getDeclaredField(entry.getKey());
            }
            catch (Exception e)
            {
                throw new IllegalArgumentException("Exception on field: "
                        + entry.getKey(), e);
            }

            final int mod = f.getModifiers();
            if (!Modifier.isStatic(mod) && !Modifier.isTransient(mod) && f.getAnnotation(Exclude.class) == null)
            {
                final Field<T> field = RuntimeFieldFactory.getFieldFactory(
                        f.getType(), strategy).create(++i, entry.getValue(), f,
                        strategy);
                fields.add(field);
            }
        }
        return new RuntimeSchema<T>(typeClass, fields, RuntimeEnv.newInstantiator(typeClass));
    }
791108
private FieldSpec generateRxMappingMethod(ObjectMappableAnnotatedClass clazz) {

    String objectVarName = "item";
    String cursorVarName = "cursor";

    TypeName elementType = ClassName.get(clazz.getElement().asType());

    // new Func1<Cursor, ListsItem>()

    CodeBlock.Builder initBlockBuilder = CodeBlock.builder()
        .add("new $L<$L, $L>() {\n", Func1.class.getSimpleName(), Cursor.class.getSimpleName(),
            elementType)
        .indent()
        .add("@Override public $L call($L cursor) {\n", elementType, Cursor.class.getSimpleName())
        .indent();

    // assign the columns indexes
    generateColumnIndexCode(initBlockBuilder, clazz.getColumnAnnotatedElements(), cursorVarName);

    // Instantiate element
    initBlockBuilder.addStatement("$T $L = new $T()", elementType, objectVarName, elementType);

    // read cursor into element variable
    for (ColumnAnnotateable e : clazz.getColumnAnnotatedElements()) {
      String indexVaName = e.getColumnName() + "Index";
      initBlockBuilder.beginControlFlow("if ($L >= 0)", indexVaName);
      e.generateAssignStatement(initBlockBuilder, objectVarName, cursorVarName, indexVaName);
      initBlockBuilder.endControlFlow();
    }

    initBlockBuilder.addStatement("return $L", objectVarName)
        .unindent()
        .add("}\n") // end call () method
        .unindent()
        .add("}") // end anonymous class
        .build();

    ParameterizedTypeName fieldType =
        ParameterizedTypeName.get(ClassName.get(Func1.class), ClassName.get(Cursor.class),
            elementType);

    return FieldSpec.builder(fieldType, "MAPPER", Modifier.PUBLIC, Modifier.STATIC, Modifier.FINAL)
        .initializer(initBlockBuilder.build())
        .build();
  }
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();
  }
586969
def create(cls, values, **context):
        
        schema = cls.schema()
        model = cls

        # check for creating inherited classes from a sub class
        polymorphic_columns = schema.columns(flags=orb.Column.Flags.Polymorphic)
        if polymorphic_columns:
            polymorphic_column = polymorphic_columns.values()[0]
            schema_name = values.get(polymorphic_column.name(), schema.name())
            if schema_name and schema_name != schema.name():
                schema = orb.system.schema(schema_name)
                if not schema:
                    raise orb.errors.ModelNotFound(schema=schema_name)
                else:
                    model = schema.model()

        column_values = {}
        collector_values = {}

        for key, value in values.items():
            obj = schema.collector(key) or schema.column(key)
            if isinstance(obj, orb.Collector):
                collector_values[key] = value
            else:
                column_values[key] = value

        # create the new record with column values (values stored on this record)
        record = model(context=orb.Context(**context))
        record.update(column_values)
        record.save()

        # save any collector values after the model is generated (values stored on other records)
        record.update(collector_values)

        return record
907022
function Schema(options, descriptors) {

    if (!descriptors) {
        descriptors = options;
        options = null;
    }

    function opt(name, type) {
        var value = options[name];
        if (value !== undefined) {
            if (typeof value === type) return value;
            else throw new TypeError(current + 'options : ' + name + ': "' +
                value + '" is not of type [' + type + ']');
        }
        else return false;
    }

    var current = 'Schema: arguments: ',
        defaults = { required: false };

    if (hasValue(options)) {
        if (type(options) === 'object') {
            defaults.required = opt('required', 'boolean');
            if (opt('validator', 'function')) defaults.validator = options.validator;
        }
        else throw new TypeError(current + 'options: must be of type [object]');
    }

    current += 'descriptors: ';
    if (typeof descriptors !== 'object')
        throw new TypeError(current + 'must be of type [object]');
    if (!Array.isArray(descriptors)) {
        descriptors = this.toDescriptors(descriptors, defaults);
    }
    if (options && options.extends instanceof Schema) {
        descriptors = this.extendDescriptors(descriptors, options.extends.descriptors);
    }
    if (!descriptors.length)
        throw new TypeError(current + 'contains no values');
    else if (!(descriptors[0] instanceof Descriptor)) {
        throw new TypeError(current + 'must be instances of Descriptor class');
    }
    var instance = this;
    this.descriptors = descriptors;

}
211244
public static Schema decorateRecordSchema(Schema inputSchema, @Nonnull List<Field> fieldList) {
    Preconditions.checkState(inputSchema.getType().equals(Type.RECORD));
    List<Field> outputFields = deepCopySchemaFields(inputSchema);
    List<Field> newOutputFields = Stream.concat(outputFields.stream(), fieldList.stream()).collect(Collectors.toList());

    Schema outputSchema = Schema.createRecord(inputSchema.getName(), inputSchema.getDoc(),
            inputSchema.getNamespace(), inputSchema.isError());
    outputSchema.setFields(newOutputFields);
    copyProperties(inputSchema, outputSchema);
    return outputSchema;
  }
880458
public Schema mapper(String field, Mapper mapper) {
        if (mappers == null) {
            mappers = new LinkedHashMap<>();
        }
        mappers.put(field, mapper);
        return this;
    }
475552
private static Object generateValue(Field field) {
    Class<?> rawType = field.getType();

    //TODO Objects other than Lists might need parametrized types.
    if (List.class.isAssignableFrom(rawType)) {
      ParameterizedType genericType = (ParameterizedType) field.getGenericType();
      return createListObject(genericType);
    }

    return generateValue(rawType);
  }
870672
public ClassTemplateSpec generate(DataSchema schema, DataSchemaLocation location)
  {
    pushCurrentLocation(location);
    final ClassTemplateSpec result = generate(schema);
    popCurrentLocation();
    return result;
  }
346380
private static void defineField(Map<String, FieldType> container, String name, FieldType type, String alias)
   {
      container.put(name, type);
      if (alias != null)
      {
         ALIASES.put(type, alias);
      }
   }
723559
function (field) {
            var schemaDefinition = this.schema[field];
            if (!schemaDefinition) {
                throw "Couldn't find '" + field + "' in schema";
            }
            var collection = this.get(field);
            if (!collection) {
                var context = this.getContextForChild(schemaDefinition.type);
                if (context) {
                    collection = context.createCollection(schemaDefinition.type, null);
                    collection.$parent = this;
                    this.set(field, collection);
                } else {
                    throw "Couldn't determine context for " + field;
                }
            }
            return collection;


        }
1272354
def get_declared_fields(mcs, klass, cls_fields, inherited_fields, dict_cls):
        
        opts = klass.opts
        converter = opts.model_converter(schema_cls=klass)
        base_fields = _BaseModelSerializerMetaclass.get_declared_fields(
            klass, cls_fields, inherited_fields, dict_cls)
        declared_fields = mcs.get_fields(converter, opts, base_fields, dict_cls)
        if declared_fields is not None:  # prevents sphinx from blowing up
            declared_fields.update(base_fields)
        return declared_fields
994617
private Map<String, Class<?>> createPropertyMap(Class<?> clz) throws Exception
   {
      Map<String, Class<?>> result = new HashMap<>();

      for (Method m : clz.getMethods())
      {
         if (m.getName().startsWith("set"))
         {
            if (m.getReturnType().equals(Void.TYPE) &&
                m.getParameterCount() == 1 &&
                isSupported(m.getParameterTypes()[0]))
               result.put(m.getName().substring(3), m.getParameterTypes()[0]);
         }
      }
      
      return result;
   }
207977
def alias(cls, typemap, base, *names):
        
        cls.parameter_alias[base] = (typemap, base)
        for i in names:
            cls.parameter_alias[i] = (typemap, base)
242144
function _buildMap(schema, options) {
    options = options || {};
    return function(data) {
        return _map(data, schema, options);
    };
}
1331413
public Schema createSchema(SAXSource source, PropertyMap properties) throws IOException, SAXException, IncorrectSchemaException {
    SchemaPatternBuilder spb = new SchemaPatternBuilder();
    SAXResolver resolver = ResolverFactory.createResolver(properties);
    ErrorHandler eh = properties.get(ValidateProperty.ERROR_HANDLER);
    DatatypeLibraryFactory dlf = properties.get(RngProperty.DATATYPE_LIBRARY_FACTORY);
    if (dlf == null) {
      //Create a new Data Type Library Loader
      dlf = new DatatypeLibraryLoader();
    }
    try {
      Pattern start = SchemaBuilderImpl.parse(createParseable(source, resolver, eh, properties), eh, dlf, spb,
          properties.contains(WrapProperty.ATTRIBUTE_OWNER));
      //Wrap the pattern
      return wrapPattern2(start, spb, properties);
    }
    catch (IllegalSchemaException e) {
      throw new IncorrectSchemaException();
    }
  }
427061
private static void walkFields(final Class<?> cls, final Map<String, Field> fieldMap) {
		if (cls.equals(Object.class)) {
			return;
		}
		Class<?> superClass = cls.getSuperclass();
		walkFields(superClass, fieldMap);
		Arrays.stream(cls.getDeclaredFields())
				.filter(f -> !Modifier.isStatic(f.getModifiers()))
				.forEach(f -> fieldMap.put(f.getName(), f));
	}