I was under the belief that whenever you create an instance of a static nested class it should be something like:
Outerclass.StaticNestedClass myObject = new Outerclass.StaticNestedClass();
This code below (I omitted some of the code which I don't think was relevant here) doesn't use the enclosing class name. GeneratedData is a static nested class of class ObjectBuilder. Why don't I see:
ObjectBuilder.GeneratedData = ObjectBuilder.createMallet()
Instead there is:
GeneratedData generatedData = ObjectBuilder.createMallet();
here are the java files...
public class Mallet {
public Mallet(float radius, float height, int numPointsAroundMallet) {
GeneratedData generatedData = ObjectBuilder.createMallet(new Point(0f,
0f, 0f), radius, height, numPointsAroundMallet);
// lots of code omitted
}
}
and here is the class where the static nested class is defined. As you can see, the method createMallet() creates an object of type GeneratedData, and the Mallet class above used that method instead of the constructor.
class ObjectBuilder {
static interface DrawCommand {
void draw();
}
static class GeneratedData {
final float[] vertexData;
final List<DrawCommand> drawList;
GeneratedData(float[] vertexData, List<DrawCommand> drawList) {
this.vertexData = vertexData;
this.drawList = drawList;
}
}
static GeneratedData createMallet(
// lots of code omitted
return builder.build();
}
private final float[] vertexData;
private ObjectBuilder(int sizeInVertices) {
vertexData = new float[sizeInVertices * FLOATS_PER_VERTEX];
}
private GeneratedData build() {
return new GeneratedData(vertexData, drawList);
}
}