You can introduce parameter object:
class ParameterObject {
public final SomeClass!(TemplateParam) foo;
public final string[][string] someAA;
public final uint[] dataToProcess;
public final SomeEnumType flag;
private ParameterObject(
SomeClass!(TemplateParam) foo,
string[][string] someAA,
uint[] dataToProcess,
SomeEnumType flag) {
this.foo = foo;
this.someAA = someAA;
this.dataToProcess = dataToProcess;
this.flag = flag;
}
private static class Builder {
public SomeClass!(TemplateParam) foo;
public string[][string] someAA;
public uint[] dataToProcess;
public SomeEnumType flag;
public Builder foo(SomeClass!(TemplateParam) foo) {
this.foo = foo;
return this;
}
public Builder someAA(string[][string] someAA) {
this.someAA = someAA;
return this;
}
public Builder dataToProcess(uint[] dataToProcess) {
this.dataToProcess = dataToProcess;
return this;
}
public Builder flag(SomeEnumType flag) {
this.flag = flag;
return this;
}
public ParameterObject build() {
if (null == foo) throw Exception("init foo!");
if (null == someAA) throw Exception("init someAA!");
if (null == dataToProcess) throw Exception("init dataToProcess!");
if (null == flag) throw Exception("init flag!");
return new ParameterObject(foo, someAA, dataToProcess, flag);
}
}
}
Now, your call would look for example:
SomeClass[string] myValue =
someFunction(
new ParameterObject.Build().
foo(myFoo).
someAA(myAA).
dataToProcess(myData).
flag(false).
build()
);
It's much easier to deal with similar cases in languages which allow creation of inline maps:
someFunction(
Map.new(
foo => myFoo,
someAA => myAA,
dataToProcess => myData,
flag => false
)
Qualifier final
means that a field can be set only from class's constructor. Qualifier static
in front of a class means that the class is not tied to it's outer class, i.e. can't access/mutate its fields.