Interface DtoInfoResolver


  • public interface DtoInfoResolver
    Interface for classes implementing the ability to instantiate corresponding aggregates and identifiers from a DTO. DTO resolvers are used by FluentAssembler to create domain aggregates and/or identifiers from DTO instances.

    There can be several DtoInfoResolvers in the system: the first one returning true from the supports(Object) for a particular DTO will be used. Implementations can be annotated with javax.annotation.Priority to define an absolute order amongst them.

    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <D,​A extends AggregateRoot<?>>
      A
      resolveAggregate​(D dto, Class<A> aggregateRootClass)
      Returns the aggregate instance derived from the DTO instance passed as first argument.
      <D,​A extends AggregateRoot<?>>
      A
      resolveAggregate​(D dto, Class<A> aggregateRootClass, int position)
      Similar to resolveAggregate(Object, Class) but used in the case where a Tuple of multiple aggregates corresponds to a single DTO.
      <D,​I>
      I
      resolveId​(D dto, Class<I> aggregateIdClass)
      Returns the identifier instance derived from the DTO instance passed as first argument.
      <D,​I>
      I
      resolveId​(D dto, Class<I> aggregateIdClass, int position)
      Similar to resolveId(Object, Class) but used in the case where a Tuple of multiple aggregates corresponds to a single DTO.
      <D> boolean supports​(D dto)
      Returns whether the resolver supports the DTO instance passed as argument.
    • Method Detail

      • supports

        <D> boolean supports​(D dto)
        Returns whether the resolver supports the DTO instance passed as argument. The first resolver to support a particular DTO is used.
        Type Parameters:
        D - the type of the DTO.
        Parameters:
        dto - the DTO to check for.
        Returns:
        true if the resolver supports this particular DTO, false otherwise.
      • resolveId

        <D,​I> I resolveId​(D dto,
                                Class<I> aggregateIdClass)
        Returns the identifier instance derived from the DTO instance passed as first argument.
        Type Parameters:
        D - the type of the DTO.
        I - the type of the identifier.
        Parameters:
        dto - the DTO used to resolve the identifier.
        aggregateIdClass - the identifier class.
        Returns:
        the newly created identifier derived from the DTO.
      • resolveId

        <D,​I> I resolveId​(D dto,
                                Class<I> aggregateIdClass,
                                int position)
        Similar to resolveId(Object, Class) but used in the case where a Tuple of multiple aggregates corresponds to a single DTO. The position argument specifies the index of the identifier in the tuple.
        Type Parameters:
        D - the type of the DTO.
        I - the type of the identifier.
        Parameters:
        dto - the DTO used to resolve the identifier.
        aggregateIdClass - the identifier class.
        position - the position in the tuple of the aggregate this identifier relates to.
        Returns:
        the newly created identifier derived from the DTO.
      • resolveAggregate

        <D,​A extends AggregateRoot<?>> A resolveAggregate​(D dto,
                                                                Class<A> aggregateRootClass)
        Returns the aggregate instance derived from the DTO instance passed as first argument.
        Type Parameters:
        D - the type of the DTO.
        A - the type of the aggregate root.
        Parameters:
        dto - the DTO sued to resolve the aggregate.
        aggregateRootClass - the aggregate root class.
        Returns:
        the newly created aggregate derived from the DTO.
      • resolveAggregate

        <D,​A extends AggregateRoot<?>> A resolveAggregate​(D dto,
                                                                Class<A> aggregateRootClass,
                                                                int position)
        Similar to resolveAggregate(Object, Class) but used in the case where a Tuple of multiple aggregates corresponds to a single DTO. The position argument specifies the index of the aggregate in the tuple.
        Type Parameters:
        D - the type of the DTO.
        A - the type of the aggregate root.
        Parameters:
        dto - the DTO sued to resolve the aggregate.
        aggregateRootClass - the aggregate root class.
        position - the position in the tuple of the aggregate to create.
        Returns:
        the newly created aggregate derived from the DTO.