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

com.ingenico.connect.gateway.sdk.java.AbstractParamRequest Maven / Gradle / Ivy

Go to download

SDK to communicate with the Ingenico ePayments platform using the Ingenico Connect Server API

There is a newer version: 6.47.0
Show newest version
package com.ingenico.connect.gateway.sdk.java;

import java.util.Collection;
import java.util.List;

/**
 * Base class for a {@link ParamRequest}s.
 */
public abstract class AbstractParamRequest implements ParamRequest {

	/**
	 * Adds a request parameter with the given name and value to the given list, unless if the value is {@code null}.
	 * 

* The following types are supported: *

    *
  • {@link String} *
  • {@link Integer} *
  • {@link Long} *
  • {@link Boolean} *
  • {@link Collection}s of the above *
*/ protected void addParameter(List requestParameters, String name, Object value) { addParameter(requestParameters, name, value, true); } private void addParameter(List requestParameters, String name, Object value, boolean allowCollection) { if (value instanceof String) { requestParameters.add(new RequestParam(name, (String) value)); } else if (value instanceof Integer || value instanceof Long || value instanceof Boolean) { requestParameters.add(new RequestParam(name, value.toString())); } else if (allowCollection && value instanceof Collection) { Collection values = (Collection) value; for (Object element : values) { addParameter(requestParameters, name, element, false); } } else if (value != null) { throw new IllegalArgumentException("Unsupported request parameter type"); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy