Skip to content

Commit

Permalink
Lazy initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
garcia-jj committed Dec 30, 2013
1 parent 968e659 commit 11fccca
Showing 1 changed file with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,16 @@ public ControllerMethod getControllerMethod() {
}

public void setControllerMethod(ControllerMethod controllerMethod) {
createValuedParameter(controllerMethod);
this.controllerMethod = controllerMethod;
}

public ValuedParameter[] getValuedParameters() {
if (valuedParameters == null) {
valuedParameters = new ValuedParameter[controllerMethod.getArity()];
}
createValuedParameter(controllerMethod);
return valuedParameters;
}

public void setParameter(int index, Object value) {
valuedParameters[index].setValue(value);
getValuedParameters()[index].setValue(value);
}

public Object[] getParametersValues() {
Expand All @@ -90,11 +87,13 @@ public void setResult(Object result) {
}

private void createValuedParameter(ControllerMethod controllerMethod) {
if (controllerMethod != null && controllerMethod.getMethod() != null) {
Parameter[] parameters = parameterNameProvider.parametersFor(controllerMethod.getMethod());
valuedParameters = new ValuedParameter[parameters.length];
for (int i = 0; i < valuedParameters.length; i++) {
valuedParameters[i] = new ValuedParameter(parameters[i], null);
if (valuedParameters == null) {
valuedParameters = new ValuedParameter[controllerMethod.getArity()];
if (controllerMethod != null && controllerMethod.getMethod() != null) {
Parameter[] parameters = parameterNameProvider.parametersFor(controllerMethod.getMethod());
for (int i = 0; i < valuedParameters.length; i++) {
valuedParameters[i] = new ValuedParameter(parameters[i], null);
}
}
}
}
Expand Down

1 comment on commit 11fccca

@Turini
Copy link
Member

@Turini Turini commented on 11fccca Dec 31, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Please sign in to comment.