Class LegacyClassScanner

java.lang.Object
com.sap.cloud.sdk.datamodel.odata.utility.LegacyClassScanner

@Beta public class LegacyClassScanner extends Object
Helper class that enables finding the correct order of parameters for get-by-key and function/actions. Used only INTERNALLY by the SDK and IS NOT intended for public usage.
  • Field Details

    • DISABLED

      public static final LegacyClassScanner DISABLED
      Enables a LegacyClassScanner where parameter reordering is skipped
  • Constructor Details

    • LegacyClassScanner

      public LegacyClassScanner(@Nullable File outputDir)
  • Method Details

    • determineArgumentsForMethod

      @Nonnull public <ParameterT> List<List<ParameterT>> determineArgumentsForMethod(@Nonnull String className, @Nonnull String methodName, @Nonnull Iterable<ParameterT> currentArguments, @Nonnull Function<ParameterT,String> argumentNameLookup)
      Determine a list of argument-sets for a named method. It reads the existing argument sets for this method from the class file present in the output directory and combines the new, incoming argument set.

      Example:
      Let's assume legacy method "foo" exists in the old class. It is defined twice with arguments "a" and "a,b,c" respectively. Now the generator reads a service specification where a method "foo" is referenced with arguments "a,x,c,b". The result of this method will be: "a", "a,b,c", "a,b,c,x".

      Type Parameters:
      ParameterT - Currently either EntityPropertyModel or FunctionImportParameterModel or UnboundOperationParameterModel
      Parameters:
      className - The fully qualified class name (including package), used to parse the legacy class file from output directory.
      methodName - The method name to determine multiple argument-sets for.
      currentArguments - A single set of arguments coming from generator input.
      argumentNameLookup - A function to get the parameter name.
      Returns:
      The ordered combination of argument-sets for a specific method.
    • determineArgumentsForConstructor

      @Nonnull public <ParameterT> List<List<ParameterT>> determineArgumentsForConstructor(@Nonnull String className, @Nonnull Iterable<ParameterT> currentArguments, @Nonnull Function<ParameterT,String> argumentNameLookup, int numSkipArguments)
      Determine a list of argument-sets for a constructor. It reads the existing argument sets for constructors of the class present in the output directory and combines the new, incoming argument set.

      Example:
      Let's assume there's a legacy class "Bar". It has two constructors with arguments "a" and "a,b,c" respectively. Now the generator reads a service specification where a resulting class "Bar" is required with constructor arguments "a,x,c,b". The result of this method will be: "a", "a,b,c", "a,b,c,x".

      Type Parameters:
      ParameterT - Currently EntityPropertyModel
      Parameters:
      className - The fully qualified class name (including package), used to parse the legacy class file from output directory.
      currentArguments - A single set of arguments coming from generator input.
      argumentNameLookup - A function to get the parameter name.
      numSkipArguments - The number of arguments to skip in the parameters passed
      Returns:
      The ordered combination of argument-sets for a specific constructor.