Migrating from Delphi to Java - enum types and set types
Hi!
I'm trying to use some Java types with similar behaviour with Delphi types.
One is enum type, that is used to choice one option from some available options. Here is an example in Delphi:
type Alignment = (LEFT, RIGHT);
var a: Alignment;
a := LEFT;
I'm trying to simulate the same behaviour with the following Java code:
<code>
public final class Alignment {
public static final Alignment LEFT = new Alignment('L');
public static final Alignment RIGHT = new Alignment('R');
private final char alignmentType;
private Alignment(char alignmentType) {
this.alignmentType = alignmentType;
}
}
</code>
Now i can use
Alignment a = Alignment.RIGHT;
Is it correct? Is there some easyest way?
Another Delphi type that i need to use in Java is set of types. These types are used you you need to select zero, one or many options from a set of options. Here is an example in Delphi:
<code>
type StringOptions = set of (tsfUpperCase, tsfNoAccent, tsfOnlyDigit);
var so: StringOptions;
so := [tsfUpperCase, tsfOnlyDigit];
</code>
I didn't found a way to represent this in Java. Is there a way to achieve this?
Thanks.

