W
Wojtek
Given the following:
---------------------------------
public class Foo
{
private static final int DEFAULT_LENGTH = 30;
private Type ivType;
private int ivLength;
public enum Type
{
OTHER,
FIXED,
VARIABLE;
}
public Foo(Type type)
{
this(type,DEFAULT_LENGTH);
}
public Foo(Type.VARIABLE varType, int length)
{
this(varType,length);
}
private Foo(Type type, int length)
{
super();
ivType = type;
ivLength = length;
}
}
---------------------------------
The compiler complains that Type.VARIABLE cannot be used. Obviously
what I want is that if the Type is VARIABLE, then I want the length in
the constructor, otherwise I will use the default length.
And yes I know I can have a constructor that only takes (int length)
and then assume that the Type is VARIABLE. That is not the point here.
---------------------------------
public class Foo
{
private static final int DEFAULT_LENGTH = 30;
private Type ivType;
private int ivLength;
public enum Type
{
OTHER,
FIXED,
VARIABLE;
}
public Foo(Type type)
{
this(type,DEFAULT_LENGTH);
}
public Foo(Type.VARIABLE varType, int length)
{
this(varType,length);
}
private Foo(Type type, int length)
{
super();
ivType = type;
ivLength = length;
}
}
---------------------------------
The compiler complains that Type.VARIABLE cannot be used. Obviously
what I want is that if the Type is VARIABLE, then I want the length in
the constructor, otherwise I will use the default length.
And yes I know I can have a constructor that only takes (int length)
and then assume that the Type is VARIABLE. That is not the point here.