Search in sources :

Example 1 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class PutObjectRequestGenerator method toRequiredConstructorParams.

/**
     * Gets the sorted list of required constructor params, including stream and length
     */
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));
    builder.add(new Arguments("", "stream"));
    builder.add(new Arguments("", "length"));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false)).collect(GuavaCollectors.immutableList());
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConverterUtil.getNonVoidArgsFromParamList(com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList) Helper.camelToUnderscore(com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) PythonHelper.pythonIndent(com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Example 2 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class Helper method sortConstructorArgs.

/**
     * Sorts a list of Arguments by name.  Used for sorting constructor arguments for consistency.
     * @param arguments List of Arguments
     * @return Sorted list of Arguments
     */
public static ImmutableList<Arguments> sortConstructorArgs(final ImmutableList<Arguments> arguments) {
    final List<Arguments> sortable = new ArrayList<>();
    sortable.addAll(arguments);
    Collections.sort(sortable, new CustomArgumentComparator());
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(sortable);
    return builder.build();
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)

Example 3 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class BaseRequestGenerator method toRequiredConstructorParams.

/**
     * Gets the sorted list of required constructor parameters for a Ds3Request
     */
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false)).collect(GuavaCollectors.immutableList());
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) Helper.camelToUnderscore(com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore) RequestConverterUtil(com.spectralogic.ds3autogen.utils.RequestConverterUtil) Operation(com.spectralogic.ds3autogen.api.models.enums.Operation) BaseRequest(com.spectralogic.ds3autogen.python.model.request.BaseRequest) GeneratorUtils(com.spectralogic.ds3autogen.python.utils.GeneratorUtils) BaseQueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.BaseQueryParam) ConverterUtil.isEmpty(com.spectralogic.ds3autogen.utils.ConverterUtil.isEmpty) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) PythonDocGeneratorUtil.toConstructorDocs(com.spectralogic.ds3autogen.python.utils.PythonDocGeneratorUtil.toConstructorDocs) Ds3DocSpec(com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) VoidQueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.VoidQueryParam) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Ds3Param(com.spectralogic.ds3autogen.api.models.apispec.Ds3Param) NormalizingContractNamesUtil(com.spectralogic.ds3autogen.utils.NormalizingContractNamesUtil) OperationQueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.OperationQueryParam) QueryParam(com.spectralogic.ds3autogen.python.model.request.queryparam.QueryParam) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Example 4 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class StringPayloadGenerator method toRequiredConstructorParams.

/**
     * Gets the sorted list of required constructor parameters including the request payload
     */
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));
    builder.add(new Arguments("string", PAYLOAD_NAME));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false)).collect(GuavaCollectors.immutableList());
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConverterUtil.getNonVoidArgsFromParamList(com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList) Helper.camelToUnderscore(com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Example 5 with CustomArgumentComparator

use of com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator in project ds3_autogen by SpectraLogic.

the class GetObjectRequestGenerator method toRequiredConstructorParams.

/**
     * Gets the sorted list of required constructor parameters, including the stream
     */
@Override
public ImmutableList<ConstructorParam> toRequiredConstructorParams(final Ds3Request ds3Request) {
    final ImmutableList.Builder<Arguments> builder = ImmutableList.builder();
    builder.addAll(getNonVoidArgsFromParamList(ds3Request.getRequiredQueryParams()));
    builder.addAll(getAssignmentArguments(ds3Request));
    builder.add(new Arguments("", "stream"));
    return builder.build().stream().sorted(new CustomArgumentComparator()).map(arg -> new ConstructorParam(camelToUnderscore(arg.getName()), false)).collect(GuavaCollectors.immutableList());
}
Also used : Arguments(com.spectralogic.ds3autogen.api.models.Arguments) RequestConverterUtil.getNonVoidArgsFromParamList(com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList) Helper.camelToUnderscore(com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore) Ds3Request(com.spectralogic.ds3autogen.api.models.apispec.Ds3Request) GuavaCollectors(com.spectralogic.ds3autogen.utils.collections.GuavaCollectors) ImmutableList(com.google.common.collect.ImmutableList) PythonHelper.pythonIndent(com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) ConstructorParam(com.spectralogic.ds3autogen.python.model.request.ConstructorParam) ImmutableList(com.google.common.collect.ImmutableList) CustomArgumentComparator(com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator) Arguments(com.spectralogic.ds3autogen.api.models.Arguments)

Aggregations

ImmutableList (com.google.common.collect.ImmutableList)9 CustomArgumentComparator (com.spectralogic.ds3autogen.utils.comparators.CustomArgumentComparator)9 Arguments (com.spectralogic.ds3autogen.api.models.Arguments)8 Ds3Request (com.spectralogic.ds3autogen.api.models.apispec.Ds3Request)7 ConstructorParam (com.spectralogic.ds3autogen.python.model.request.ConstructorParam)7 Helper.camelToUnderscore (com.spectralogic.ds3autogen.utils.Helper.camelToUnderscore)7 GuavaCollectors (com.spectralogic.ds3autogen.utils.collections.GuavaCollectors)7 RequestConverterUtil.getNonVoidArgsFromParamList (com.spectralogic.ds3autogen.utils.RequestConverterUtil.getNonVoidArgsFromParamList)6 PythonHelper.pythonIndent (com.spectralogic.ds3autogen.python.helpers.PythonHelper.pythonIndent)5 GeneratorUtils.hasRequiredFileObjectListPayload (com.spectralogic.ds3autogen.python.utils.GeneratorUtils.hasRequiredFileObjectListPayload)2 Ds3RequestClassificationUtil (com.spectralogic.ds3autogen.utils.Ds3RequestClassificationUtil)2 Ds3Param (com.spectralogic.ds3autogen.api.models.apispec.Ds3Param)1 Ds3DocSpec (com.spectralogic.ds3autogen.api.models.docspec.Ds3DocSpec)1 Operation (com.spectralogic.ds3autogen.api.models.enums.Operation)1 BaseRequest (com.spectralogic.ds3autogen.python.model.request.BaseRequest)1 BaseQueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.BaseQueryParam)1 OperationQueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.OperationQueryParam)1 QueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.QueryParam)1 VoidQueryParam (com.spectralogic.ds3autogen.python.model.request.queryparam.VoidQueryParam)1 GeneratorUtils (com.spectralogic.ds3autogen.python.utils.GeneratorUtils)1