[Jiemamy-notify:2293] commit [3330] DataTypeHolderに型パラメータを持たせるように変更。

アーカイブの一覧に戻る

svnno****@sourc***** svnno****@sourc*****
2009年 4月 21日 (火) 09:05:07 JST


Revision: 3330
          http://svn.sourceforge.jp/view?root=jiemamy&view=rev&rev=3330
Author:   daisuke_m
Date:     2009-04-21 09:05:07 +0900 (Tue, 21 Apr 2009)

Log Message:
-----------
DataTypeHolderに型パラメータを持たせるように変更。

Modified Paths:
--------------
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java
    artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java
    artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/JiemamyPropertyTest.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeHolder.java
    zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java


-------------- next part --------------
Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java	2009-04-21 00:04:17 UTC (rev 3329)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/model/datatype/DomainModelImpl.java	2009-04-21 00:05:07 UTC (rev 3330)
@@ -26,7 +26,6 @@
 import org.jiemamy.model.attribute.constraint.ColumnCheckConstraint;
 import org.jiemamy.model.attribute.constraint.NotNullConstraint;
 import org.jiemamy.model.datatype.BuiltinDataType;
-import org.jiemamy.model.datatype.DataType;
 import org.jiemamy.model.datatype.DomainModel;
 
 /**
@@ -84,7 +83,7 @@
 		return checkConstraint;
 	}
 	
-	public DataType getDataType() {
+	public BuiltinDataType getDataType() {
 		return dataType;
 	}
 	
@@ -124,11 +123,8 @@
 		checkConstraint = check;
 	}
 	
-	public void setDataType(DataType dataType) {
-		if ((dataType instanceof BuiltinDataType) == false && dataType != null) {
-			throw new IllegalArgumentException();
-		}
-		this.dataType = (BuiltinDataType) dataType;
+	public void setDataType(BuiltinDataType dataType) {
+		this.dataType = dataType;
 	}
 	
 	public void setDescription(String description) {

Modified: artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java
===================================================================
--- artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java	2009-04-21 00:04:17 UTC (rev 3329)
+++ artemis/trunk/jiemamy-core/src/main/java/org/jiemamy/internal/serializer/JiemamyDomParser.java	2009-04-21 00:05:07 UTC (rev 3330)
@@ -393,7 +393,8 @@
 			DomainModel domainModel = factory.newModel(DomainModel.class, DomUtil.getUUID(domainNode, CoreQName.ID));
 			domainModel.setName(XpathUtil.getTextContent(domainNode, EL_CORE_NAME));
 			domainModel.setLogicalName(XpathUtil.getTextContent(domainNode, EL_CORE_LOGICALNAME));
-			domainModel.setDataType(getDataType((Element) XpathUtil.getNode(domainNode, "core:dataType")));
+			domainModel.setDataType((BuiltinDataType) getDataType((Element) XpathUtil.getNode(domainNode,
+					"core:dataType")));
 			
 			Node nnNode = XpathUtil.getNode(domainNode, "core:notNull");
 			if (nnNode != null) {

Modified: artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/JiemamyPropertyTest.java
===================================================================
--- artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/JiemamyPropertyTest.java	2009-04-21 00:04:17 UTC (rev 3329)
+++ artemis/trunk/jiemamy-core/src/test/java/org/jiemamy/JiemamyPropertyTest.java	2009-04-21 00:05:07 UTC (rev 3330)
@@ -23,7 +23,6 @@
 import java.lang.reflect.Field;
 import java.lang.reflect.Method;
 import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
 import java.util.Arrays;
 
 import org.apache.commons.lang.ClassUtils;
@@ -54,8 +53,8 @@
 			
 			Class<? extends JiemamyElement> targetModelClass = getTargetModelClass(enumClass);
 			for (Field field : enumClass.getFields()) {
-				String iserName = ReflectionUtil.convertFieldToAccessorName(field, "is");
-				String getterName = ReflectionUtil.convertFieldToAccessorName(field, "get");
+				String iserName = ReflectionUtil.convertFieldToAccessorName(field, ReflectionUtil.IS);
+				String getterName = ReflectionUtil.convertFieldToAccessorName(field, ReflectionUtil.GET);
 				try {
 					targetModelClass.getMethod(getterName);
 				} catch (NoSuchMethodException e) {
@@ -149,7 +148,8 @@
 	
 	private Class<? extends JiemamyElement> getTargetModelClass(Class<?> propImplementation) {
 		ParameterizedType pType = (ParameterizedType) propImplementation.getGenericInterfaces()[0];
-		Type type = pType.getActualTypeArguments()[0];
-		return (Class<? extends JiemamyElement>) type;
+		@SuppressWarnings("unchecked")
+		Class<? extends JiemamyElement> type = (Class<? extends JiemamyElement>) pType.getActualTypeArguments()[0];
+		return type;
 	}
 }

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java	2009-04-21 00:04:17 UTC (rev 3329)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/attribute/ColumnModel.java	2009-04-21 00:05:07 UTC (rev 3330)
@@ -31,7 +31,7 @@
  * @since 0.2
  * @author daisuke
  */
-public interface ColumnModel extends AttributeModel, DataTypeHolder {
+public interface ColumnModel extends AttributeModel, DataTypeHolder<DataType> {
 	
 	/**
 	 * チェック制約を取得する。

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeHolder.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeHolder.java	2009-04-21 00:04:17 UTC (rev 3329)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DataTypeHolder.java	2009-04-21 00:05:07 UTC (rev 3330)
@@ -21,10 +21,11 @@
 /**
  * データ型({@link DataType})を保持するモデルを表すインターフェイス。
  * 
+ * @param <T> 型記述子の型
  * @since 0.2
  * @author daisuke
  */
-public interface DataTypeHolder {
+public interface DataTypeHolder<T extends DataType> {
 	
 	/**
 	 * 型記述子を取得する。
@@ -32,7 +33,7 @@
 	 * @return 型記述子. 未設定の場合は{@code null}
 	 * @since 0.2
 	 */
-	DataType getDataType();
+	T getDataType();
 	
 	/**
 	 * 型記述子を設定する。
@@ -42,6 +43,6 @@
 	 * @param dataType 型記述子
 	 * @since 0.2
 	 */
-	void setDataType(DataType dataType);
+	void setDataType(T dataType);
 	
 }

Modified: zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java
===================================================================
--- zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java	2009-04-21 00:04:17 UTC (rev 3329)
+++ zeus/trunk/jiemamy-spec-core/src/main/java/org/jiemamy/model/datatype/DomainModel.java	2009-04-21 00:05:07 UTC (rev 3330)
@@ -30,7 +30,7 @@
  * @since 0.2
  * @author daisuke
  */
-public interface DomainModel extends JiemamyElement, DataTypeMold<DomainRef>, DataTypeHolder {
+public interface DomainModel extends JiemamyElement, DataTypeMold<DomainRef>, DataTypeHolder<BuiltinDataType> {
 	
 	/**
 	 * {@inheritDoc}
@@ -53,14 +53,6 @@
 	ColumnCheckConstraint getCheckConstraint();
 	
 	/**
-	 * ドメインとして定義された型記述子を取得する。
-	 * 
-	 * @return ドメインとして定義された型記述子. 未設定の場合は{@code null}
-	 * @since 0.2
-	 */
-	DataType getDataType();
-	
-	/**
 	 * 説明文を取得する。
 	 * 
 	 * @return 説明文. 未設定の場合は{@code null}



Jiemamy-notify メーリングリストの案内
アーカイブの一覧に戻る