Package com.sap.cds

Class ResultBuilder

java.lang.Object
com.sap.cds.ResultBuilder

public abstract class ResultBuilder extends Object
Builder class to programmatically create a Result to represent the result of queries, insert, update and delete operations.
  • Constructor Details

    • ResultBuilder

      public ResultBuilder()
  • Method Details

    • selectedRows

      public static ResultBuilder selectedRows(List<? extends Map<String,?>> rows)
      Creates a ResultBuilder to represent a query result.
      Parameters:
      rows - the result rows
      Returns:
      the result builder
    • insertedRows

      public static ResultBuilder insertedRows(List<? extends Map<String,?>> rows)
      Creates a ResultBuilder for an INSERT or UPSERT result.
      Parameters:
      rows - the rows in- or upserted
      Returns:
      the result builder
    • updatedRows

      public static ResultBuilder updatedRows(long updateCount, Map<String,?> updateData)
      Creates a ResultBuilder for a searched UPDATE, updating multiple rows with the same data.
      Parameters:
      updateCount - the number of rows that were updated
      updateData - the update data
      Returns:
      the result builder
    • batchUpdate

      public static ResultBuilder batchUpdate()
      Creates a ResultBuilder for a batch UPDATE result. The results of the individual UPDATE statements have to be added using addUpdatedRows(long, Map).
      Returns:
      the result builder
    • deletedRows

      public static ResultBuilder deletedRows(long deleteCount)
      Creates a ResultBuilder for a DELETE result.
      Parameters:
      deleteCount - the number of rows that were deleted
      Returns:
      the result builder
    • deletedRows

      public static ResultBuilder deletedRows(int[] deleteCounts)
      Creates a ResultBuilder for a batch DELETE result.
      Parameters:
      deleteCounts - the number of rows deleted by the individual DELETE operations of the batch
      Returns:
      the result builder
    • deletedRows

      public static ResultBuilder deletedRows(long[] deleteCounts)
      Creates a ResultBuilder for a batch DELETE result.
      Parameters:
      deleteCounts - the number of rows deleted by the individual DELETE operations of the batch
      Returns:
      the result builder
    • entity

      public abstract ResultBuilder entity(CdsEntity entity)
      Specifies the source CdsEntity of this result.
      Parameters:
      entity - the source entity
      Returns:
      this ResultBuilder
    • rowType

      public abstract ResultBuilder rowType(CdsStructuredType rowType)
      Specifies the CdsStructuredType that represents the row type of this result.
      Parameters:
      rowType - the row type
      Returns:
      this ResultBuilder
    • inlineCount

      public abstract ResultBuilder inlineCount(long inlineCount)
      Specifies the inline count of a query result.
      Parameters:
      inlineCount - the inline count
      Returns:
      this ResultBuilder
    • addUpdatedRows

      public abstract ResultBuilder addUpdatedRows(long updateCount, Map<String,?> updateData)
      Adds an update result to this result builder that represents the result of a single UPDATE operation of a batch.
      Parameters:
      updateCount - the number of rows that were updated
      updateData - the update data
      Returns:
      this ResultBuilder
    • addUpdatedRows

      public abstract ResultBuilder addUpdatedRows(long[] updateCounts, List<? extends Map<String,?>> updateData)
      Adds multiple update results to this result builder that represent the result of the UPDATE operations of a batch.
      Parameters:
      updateCounts - the number of rows that were updated per line of the batch
      updateData - the update data
      Returns:
      this ResultBuilder
    • result

      public abstract Result result()
      Create a Result from this ResultBuilder
      Returns:
      the result
    • rows

      protected abstract ResultBuilder rows(Stream<? extends Map<String,?>> rows)
    • rows

      protected ResultBuilder rows(List<? extends Map<String,?>> rows)
    • rowCount

      protected abstract ResultBuilder rowCount(long[] rowCounts)