Class FunctionalEntityStream

  • All Implemented Interfaces:
    java.lang.AutoCloseable, java.lang.Iterable<BulkUpdateEntity>, BulkUpdatable

    public class FunctionalEntityStream
    extends java.lang.Object
    implements BulkUpdatable
    ラムダ式を利用してBulkUpdatableを構築するためのクラス。 以下のような使い方。
     EntityManager em = ...
     
     List oids = new ArrayList<>();
     long[] counter = {0};
     em.bulkUpdate(BulkUpdatable.as("TargetEntity").onNext(() -> {
         //onNextで次の1件のBulkUpdateEntityを返却するように実装
         if (counter[0] >= 100) {
           //処理対象が終了した場合は、nullを返却
           return null;
         }
         GenericEntity ret = new GenericEntity("TargetEntity");
         ret.setName("hoge");
         counter[0]++;
         return new BulkUpdateEntity(UpdateMethod.INSERT, ret);
       }).onUpdated(bue -> {
         //onUpdatedは、更新処理後のコールバック処理を記述可能(オプション)
         oids.add(bue.getEntity().getOid());
       }).onClose(() -> {
         //onCloseは、BulkUpdatableのクローズ処理を記述可能(オプション)
         doSomething...
       }));
     
     
    • Method Summary

      Modifier and Type Method Description
      void close()
      BulkUpdatableのクローズ処理を記述。
      FunctionalEntityStream definitionName​(java.lang.String definitionName)
      Entityの定義名を指定
      java.lang.String getDefinitionName()
      バルク更新対象のEntity定義名を返却するように実装。
      java.util.List<java.lang.String> getUpdateProperties()
      バルク更新(UPDATEおよびMERGEで更新と判断された場合)の際の更新対象のプロパティを指定する。 未指定(null)の場合は全項目を更新対象と判断。
      java.util.Iterator<BulkUpdateEntity> iterator()  
      FunctionalEntityStream onClose​(java.lang.Runnable onClose)
      BulkUpdatableのクローズ処理を記述。
      FunctionalEntityStream onNext​(java.util.function.Supplier<BulkUpdateEntity> onNext)
      BulkUpdateEntityを取得するロジックを記述。 処理対象のBulkUpdateEntityが既にない場合はnullを返却するように実装。
      FunctionalEntityStream onUpdated​(java.util.function.Consumer<BulkUpdateEntity> onUpdated)
      更新処理成功後のコールバック処理を記述可能。
      void updated​(BulkUpdateEntity updatedEntity)
      バルク更新対象のEntityの更新処理が成功した場合呼び出されるコールバック。
      FunctionalEntityStream updateProperties​(java.lang.String... propName)
      更新時の更新対象プロパティを指定
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • FunctionalEntityStream

        public FunctionalEntityStream()
    • Method Detail

      • onNext

        public FunctionalEntityStream onNext​(java.util.function.Supplier<BulkUpdateEntity> onNext)
        BulkUpdateEntityを取得するロジックを記述。 処理対象のBulkUpdateEntityが既にない場合はnullを返却するように実装。
        Parameters:
        onNext -
        Returns:
      • definitionName

        public FunctionalEntityStream definitionName​(java.lang.String definitionName)
        Entityの定義名を指定
        Parameters:
        definitionName -
        Returns:
      • updateProperties

        public FunctionalEntityStream updateProperties​(java.lang.String... propName)
        更新時の更新対象プロパティを指定
        Parameters:
        propName -
        Returns:
      • onClose

        public FunctionalEntityStream onClose​(java.lang.Runnable onClose)
        BulkUpdatableのクローズ処理を記述。
        Parameters:
        onClose -
        Returns:
      • onUpdated

        public FunctionalEntityStream onUpdated​(java.util.function.Consumer<BulkUpdateEntity> onUpdated)
        更新処理成功後のコールバック処理を記述可能。
        Parameters:
        onUpdated -
        Returns:
      • getDefinitionName

        public java.lang.String getDefinitionName()
        Description copied from interface: BulkUpdatable
        バルク更新対象のEntity定義名を返却するように実装。
        Specified by:
        getDefinitionName in interface BulkUpdatable
        Returns:
      • updated

        public void updated​(BulkUpdateEntity updatedEntity)
        Description copied from interface: BulkUpdatable
        バルク更新対象のEntityの更新処理が成功した場合呼び出されるコールバック。
        Specified by:
        updated in interface BulkUpdatable
      • close

        public void close()
        Description copied from interface: BulkUpdatable
        BulkUpdatableのクローズ処理を記述。
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface BulkUpdatable
      • getUpdateProperties

        public java.util.List<java.lang.String> getUpdateProperties()
        Description copied from interface: BulkUpdatable
        バルク更新(UPDATEおよびMERGEで更新と判断された場合)の際の更新対象のプロパティを指定する。 未指定(null)の場合は全項目を更新対象と判断。
        Specified by:
        getUpdateProperties in interface BulkUpdatable
        Returns: