First of all I would like to share that I've started working with java and object oriented programming very recently so forgive me if this is a stupid question but I cannot find a clear answer elsewhere.
I'm working on a template for a Comsol model and would like to abbreviate a part of the code to make it more readable. Although the following piece of code runs with the Comsol compiler:
Model model = ModelUtil.create("Model"); // Returns a model
model.geom().create("geom1"); // add a component
model.geom("geom1").create("circle") // add a shape
//I would like to rewrite the following block of code:
model.geom("geom1").shape("circle").name("c1", "Circle");
model.geom("geom1").shape("circle").feature("c1").label("OuterDiameter");
model.geom("geom1").shape("circle").feature("c1").set("type", "curve");
model.geom("geom1").shape("circle").feature("c1").set("r", "0.5");
I would like to do abbreviate model.geom("geom1").shape("circle")
into something like MGS
.
I need such a command a significant amount of times since I would also like to use it for abbreviating model.material("mat1").propertyGroup("def")
and model.sol("sol1").feature("s1").feature("fc1")
and model.result("pg2").feature("iso1")
and presummably more in the future.
I am more familiar with Python which would allow me to do something very simple like:
MGS = model.geom("geom1").shape("circle")
MGS.name("c1", "Circle")
MGSF = MGS.feature("c1")
MGSF.label("OuterDiameter")
MGSF.set("type", "curve")
I can't find any similar expression in java.
Thanks