org.springframework.ldap.core.support

## Class AbstractContextMapper<T>

- java.lang.Object
- - org.springframework.ldap.core.support.AbstractContextMapper<T>

- All Implemented Interfaces:
    ContextMapper<T>

      public abstract class AbstractContextMapper<T>
      extends Object
      implements ContextMapper<T>

  Abstract superclass that may be used instead of implementing `ContextMapper` directly. Subclassing from this superclass, the supplied context will be automatically cast to `DirContextOperations`. Note that if you use your own `DirObjectFactory`, this implementation will fail with a `ClassCastException`.
  Author:
    Mattias Hellborg Arthursson

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `AbstractContextMapper()`

  - ### Method Summary

    All Methods Instance Methods Abstract Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected abstract T` | `doMapFromContext(DirContextOperations ctx)` Map a single `DirContextOperation` to an object.
    `T` | `mapFromContext(Object ctx)` Map a single LDAP Context to an object.

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

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

- - ### Constructor Detail

    - #### AbstractContextMapper

          public AbstractContextMapper()

  - ### Method Detail

    - #### mapFromContext

          public final T mapFromContext(Object ctx)

      Map a single LDAP Context to an object. The supplied Object `ctx` is the object from a single `SearchResult`, `Binding`, or a lookup operation.
      Specified by:
        `mapFromContext` in interface `ContextMapper<T>`
      Parameters:
        `ctx` - the context to map to an object. Typically this will be a `DirContextAdapter` instance, unless a project specific `DirObjectFactory` has been specified on the `ContextSource`.
      Returns:
        an object built from the data in the context.
      Throws:
        `ClassCastException` - if a custom `DirObjectFactory` implementation is used, causing the objects passed in be anything else than `DirContextOperations` instances.

    - #### doMapFromContext

          protected abstract T doMapFromContext(DirContextOperations ctx)

      Map a single `DirContextOperation` to an object. The supplied instance is the object supplied to `mapFromContext(Object)` cast to a `DirContextOperations`.
      Parameters:
        `ctx` - the context to map to an object.
      Returns:
        an object built from the data in the context.