All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.backendless.transaction.OpResultIdGenerator Maven / Gradle / Ivy

There is a newer version: 7.0-alpha
Show newest version
package com.backendless.transaction;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

class OpResultIdGenerator
{
  private List opResultIdStrings;
  private final Map opResultIdMaps = new HashMap<>();

  OpResultIdGenerator( List opResultIdStrings )
  {
    this.opResultIdStrings = opResultIdStrings;
  }

  String generateOpResultId( OperationType operationType, String tableName )
  {
    String opResultIdGenerated;
    final String key = operationType.getOperationName() + tableName;
    if( opResultIdMaps.containsKey( key ) )
    {
      int count = opResultIdMaps.get( key );
      opResultIdMaps.put( key, ++count );
      opResultIdGenerated = key + count;
    }
    else
    {
      opResultIdMaps.put( key, 1 );
      opResultIdGenerated = key + 1;
    }
    opResultIdStrings.add( opResultIdGenerated );
    return opResultIdGenerated;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy