확인 사용자 정의 필드 (속성)를 열거이 가능 자바 그래서이 :EMF 이클립스 :
import org.eclipse.emf.common.util.Enumerator;
public enum MyEnum implements Enumerator {
LITERAL1(0, "Name", "Literal", "custom1", "custom2", "custom3"),
LITERAL2(0, "Name", "Literal", "custom1", "custom2", "custom3"),
LITERAL3(0, "Name", "Literal", "custom1", "custom2", "custom3"),
LITERAL4(0, "Name", "Literal", "custom1", "custom2", "custom3");
public static final int LITERAL1_VALUE = 0;
public static final int LITERAL2_VALUE = 1;
public static final int LITERAL3_VALUE = 2;
public static final int LITERAL4_VALUE = 3;
private static final MyEnum[] VALUES_ARRAY =
new MyEnum[] {
LITERAL1,
LITERAL2,
LITERAL3,
LITERAL4,
};
public static final List<MyEnum> VALUES =
Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY));
private final int value;
private final String name;
private final String literal;
private final String custom1;
private final String custom2;
private final String custom3;
private MyEnum(int value, String name, String literal,
String custom1, String custom2, String custom3) {
this.value = value;
this.name = name;
this.literal = literal;
this.custom1 = custom1;
this.custom2 = custom2;
this.custom3 = custom3;
}
/*Getters for all of them*/
이 확장 열거라고하는 것이다. 나는 그것이 작동한다는 것을 안다 - 나는 그것을 많이 시험해 보았다. 열거 형에서해야 할 일이 무엇인지 토론 할 수 있다는 것을 알고 있습니다. 정의 된 상수를 여전히 가지고 있기 때문에 그렇다고 생각합니다. 그러나 더 많은 정보가 포함되어 있습니다 (일정한 상수 임). (또한 :이 하나, Custom fields on java enum not getting serialized, 그리고 그들은 또한 열거 형에 사용자 지정 속성을 생성하는 방법에 내 생각을 따르는 것) 보았다.
이제 이클립스 EMF 모델에서 어떻게 생성할까요? .ecore 모델 편집기의 열거 형에 추가 속성을 추가 할 위치를 모르겠습니다 ... 추가 속성을 모든 사용자 지정 속성의 키가 들어있는 ExtendedMetaData에 주석으로 추가하려고했습니다. 그러나 파일을 변경하지 않는 .genmodel 파일을 생성 할 때 (내가 SVN에서 이전에 체크인 한 버전과 비교해 보았 기 때문에 SVN에서 아무것도 변경되지 않는다고 알려줍니다.) 물론 생성 된 모델 코드에는 변화가 없습니다.
누구나? 생성 된 모델 코드를 손으로 변경할 수는 있지만 모델에 뭔가 바꿀 수있는 경우 편집 내용을 잃어 버릴 수 있습니다. 분명히 원하는 것은 아닙니다.
감사합니다.
업데이트
:MyEnum (EEnum)
LITERAL1 (EEnum Literal)
ExtendedMetaData (EAnnotation)
custom1 -> custom1
custom2 -> custom2
custom3 -> custom3
LITERAL2 (EEnum Literal)
ExtendedMetaData (EAnnotation)
custom1 -> custom1
custom2 -> custom2
custom3 -> custom3
LITERAL3 (EEnum Literal)
ExtendedMetaData (EAnnotation)
custom1 -> custom1
custom2 -> custom2
custom3 -> custom3
LITERAL4 (EEnum Literal)
ExtendedMetaData (EAnnotation)
custom1 -> custom1
custom2 -> custom2
custom3 -> custom3
이 게시물은 도움이 될 수도 있습니다 http://stackoverflow.com/questions/12177465/enum-data-type-in-emf. – lmove