org.apache.avro

## Class Resolver

- java.lang.Object
- - org.apache.avro.Resolver

-     public class Resolver
      extends Object

  Encapsulate schema-resolution logic in an easy-to-consume representation. See `resolve(org.apache.avro.Schema, org.apache.avro.Schema, org.apache.avro.generic.GenericData)` and also the separate document entitled `refactoring-resolution` for more information. It might also be helpful to study `ResolvingGrammarGenerator` as an example of how to use this class.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `Resolver.Action` An abstract class for an action to be taken to resolve a writer's schema (found in public instance variable `writer`) against a reader's schema (in `reader`).
    `static class` | `Resolver.Container` Used for array and map schemas: the public instance variable `elementAction` contains the resolving action needed for the element type of an array or value top of a map.
    `static class` | `Resolver.DoNothing` In this case, there's nothing to be done for resolution: the two schemas are effectively the same.
    `static class` | `Resolver.EnumAdjust` Contains information needed to resolve enumerations.
    `static class` | `Resolver.ErrorAction` In this case there is an error.
    `static class` | `Resolver.Promote` In this case, the writer's type needs to be promoted to the reader's.
    `static class` | `Resolver.ReaderUnion` In this case, the reader is a union and the writer is not.
    `static class` | `Resolver.RecordAdjust` Instructions for resolving two record schemas.
    `static class` | `Resolver.Skip` This only appears inside `Resolver.RecordAdjust.fieldActions`, i.e., the actions for adjusting the fields of a record.
    `static class` | `Resolver.WriterUnion` In this case, the writer was a union.

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Resolver()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Resolver.Action` | `resolve(Schema writer, Schema reader)` Uses `GenericData.get()` for the `data` param.
    `static Resolver.Action` | `resolve(Schema writer, Schema reader, GenericData data)` Returns a `Resolver.Action` tree for resolving the writer schema `writer` and the reader schema `reader`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### Resolver

          public Resolver()

  - ### Method Detail

    - #### resolve

          public static Resolver.Action resolve(Schema writer,
                                                Schema reader,
                                                GenericData data)

      Returns a `Resolver.Action` tree for resolving the writer schema `writer` and the reader schema `reader`. This method walks the reader's and writer's schemas together, generating an appropriate subclass of `Resolver.Action` to encapsulate the information needed to resolve the corresponding parts of each schema tree. For convenience, every `Resolver.Action` object has a pointer to the corresponding parts of the reader's and writer's trees being resolved by the action. Each subclass of `Resolver.Action` has additional information needed for different types of schema, e.g., the `Resolver.EnumAdjust` subclass has information about re-ordering and deletion of enumeration symbols, while `Resolver.RecordAdjust` has information about re-ordering and deletion of record fields. Note that aliases are applied to the writer's schema before resolution actually takes place. This means that the `writer` field of the resulting `Resolver.Action` objects will not be the same schema as provided to this method. However, the `reader` field will be.
      Parameters:
        `writer` - The schema used by the writer
        `reader` - The schema used by the reader
        `data` - Used for `getDefaultValue` and getting conversions
      Returns:
        Nested actions for resolving the two

    - #### resolve

          public static Resolver.Action resolve(Schema writer,
                                                Schema reader)

      Uses `GenericData.get()` for the `data` param.

Copyright © 2009–2024 The Apache Software Foundation. All rights reserved.