Skip to content

Commit

Permalink
Get rid of Vector in FBProcedureCall
Browse files Browse the repository at this point in the history
  • Loading branch information
mrotteveel committed Oct 31, 2023
1 parent 8873d05 commit 7e6ca18
Showing 1 changed file with 15 additions and 20 deletions.
35 changes: 15 additions & 20 deletions src/main/org/firebirdsql/jdbc/FBProcedureCall.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@
*/
package org.firebirdsql.jdbc;

import org.firebirdsql.jaybird.util.CollectionUtils;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
import java.util.Vector;

import static org.firebirdsql.jdbc.SQLStateConstants.*;

Expand All @@ -46,18 +48,17 @@ public Object clone() {
}
}

private static Vector<FBProcedureParam> cloneParameters(final Vector<FBProcedureParam> parameters) {
final Vector<FBProcedureParam> clonedParameters = new Vector<>(parameters.size());
private static List<FBProcedureParam> cloneParameters(final List<FBProcedureParam> parameters) {
final List<FBProcedureParam> clonedParameters = new ArrayList<>(parameters.size());
for (FBProcedureParam param : parameters) {
clonedParameters.add(param != null ? (FBProcedureParam) param.clone() : null);
}
return clonedParameters;
}

private String name;
// TODO Replace Vector with a List
private Vector<FBProcedureParam> inputParams = new Vector<>();
private Vector<FBProcedureParam> outputParams = new Vector<>();
private List<FBProcedureParam> inputParams = new ArrayList<>();
private List<FBProcedureParam> outputParams = new ArrayList<>();

/**
* Get the name of the procedure to be called.
Expand Down Expand Up @@ -92,10 +93,7 @@ public FBProcedureParam getInputParam(int index) {

// ensure that vector has right size
// note, index starts with 1
if (inputParams.size() < index) {
inputParams.setSize(index);
}

CollectionUtils.growToSize(inputParams, index);
inputParams.set(index - 1, result);
}

Expand All @@ -120,7 +118,7 @@ public FBProcedureParam getOutputParam(int index) {
*
* @return instance of {@link FBProcedureParam}.
*/
private FBProcedureParam getParam(Collection<FBProcedureParam> params, int index) {
private static FBProcedureParam getParam(Collection<FBProcedureParam> params, int index) {
for (FBProcedureParam param : params) {
if (param != null && param.getIndex() == index) {
return param;
Expand Down Expand Up @@ -180,11 +178,7 @@ public List<FBProcedureParam> getOutputParams() {
* @param param The parameter to be added
*/
public void addInputParam(FBProcedureParam param) {
if (inputParams.size() < param.getPosition() + 1) {
inputParams.setSize(param.getPosition() + 1);
}

inputParams.set(param.getPosition(), param);
addParam(inputParams, param);
}

/**
Expand All @@ -194,11 +188,12 @@ public void addInputParam(FBProcedureParam param) {
* The parameter to be added
*/
public void addOutputParam(FBProcedureParam param) {
if (outputParams.size() < param.getPosition() + 1) {
outputParams.setSize(param.getPosition() + 1);
}
addParam(outputParams, param);
}

outputParams.set(param.getPosition(), param);
private static void addParam(List<FBProcedureParam> params, FBProcedureParam param) {
CollectionUtils.growToSize(params, param.getPosition() + 1);
params.set(param.getPosition(), param);
}

/**
Expand Down

0 comments on commit 7e6ca18

Please sign in to comment.