Removed uneeded generic
This commit is contained in:
parent
71e1972aba
commit
880e3157a3
|
@ -138,7 +138,7 @@ public class TypeImpl implements Type {
|
||||||
return (Class<?>) t;
|
return (Class<?>) t;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "unchecked" })
|
||||||
public static Type getInstance(Class<? extends Element> clz) {
|
public static Type getInstance(Class<? extends Element> clz) {
|
||||||
Type typeDefinition = null;
|
Type typeDefinition = null;
|
||||||
try {
|
try {
|
||||||
|
@ -150,7 +150,7 @@ public class TypeImpl implements Type {
|
||||||
.getRelationTypeDefinitionInstance((Class<? extends RelationElement<?, ?>>) clz);
|
.getRelationTypeDefinitionInstance((Class<? extends RelationElement<?, ?>>) clz);
|
||||||
return typeDefinition;
|
return typeDefinition;
|
||||||
} else if (PropertyElement.class.isAssignableFrom(clz)) {
|
} else if (PropertyElement.class.isAssignableFrom(clz)) {
|
||||||
typeDefinition = new PropertyTypeImpl(clz);
|
typeDefinition = new PropertyTypeImpl((Class<? extends PropertyElement>) clz);
|
||||||
return typeDefinition;
|
return typeDefinition;
|
||||||
} else if (Type.class.isAssignableFrom(clz)) {
|
} else if (Type.class.isAssignableFrom(clz)) {
|
||||||
typeDefinition = new TypeImpl(clz);
|
typeDefinition = new TypeImpl(clz);
|
||||||
|
|
|
@ -19,8 +19,8 @@ import org.gcube.informationsystem.types.reference.properties.PropertyType;
|
||||||
* @author Luca Frosini (ISTI - CNR)
|
* @author Luca Frosini (ISTI - CNR)
|
||||||
*/
|
*/
|
||||||
@JsonTypeName(value = PropertyType.NAME)
|
@JsonTypeName(value = PropertyType.NAME)
|
||||||
public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
|
public final class PropertyTypeImpl extends TypeImpl
|
||||||
implements PropertyType<P> {
|
implements PropertyType {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generated Serial Version UID
|
* Generated Serial Version UID
|
||||||
|
@ -43,7 +43,7 @@ public final class PropertyTypeImpl<P extends PropertyElement> extends TypeImpl
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
|
||||||
public PropertyTypeImpl(Class<P> clz) {
|
public PropertyTypeImpl(Class<? extends PropertyElement> clz) {
|
||||||
super(clz);
|
super(clz);
|
||||||
this.extendedTypes = retrieveSuperClasses(clz, PropertyElement.class,
|
this.extendedTypes = retrieveSuperClasses(clz, PropertyElement.class,
|
||||||
clz == PropertyElement.class ? null : PropertyElement.NAME);
|
clz == PropertyElement.class ? null : PropertyElement.NAME);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.gcube.informationsystem.utils.Version;
|
||||||
@TypeMetadata(name = PropertyType.NAME, description = "This type provides information for any PropertyType", version = Version.MINIMAL_VERSION_STRING)
|
@TypeMetadata(name = PropertyType.NAME, description = "This type provides information for any PropertyType", version = Version.MINIMAL_VERSION_STRING)
|
||||||
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
|
||||||
@Final
|
@Final
|
||||||
public interface PropertyType<P extends PropertyElement> extends PropertyElement, Type {
|
public interface PropertyType extends PropertyElement, Type {
|
||||||
|
|
||||||
public static final String NAME = "PropertyType"; // PropertyType.class.getSimpleName();
|
public static final String NAME = "PropertyType"; // PropertyType.class.getSimpleName();
|
||||||
|
|
||||||
|
|
|
@ -79,48 +79,39 @@ public class SerializationTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testPropertyTypeDefinition() throws Exception{
|
public void testPropertyTypeDefinition() throws Exception{
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType propertyElement = (PropertyType) TypeMapper.createTypeDefinition(PropertyElement.class);
|
||||||
PropertyType<PropertyElement> propertyElement = (PropertyType<PropertyElement>) TypeMapper.createTypeDefinition(PropertyElement.class);
|
|
||||||
Assert.assertTrue(propertyElement.getAccessType()==AccessType.PROPERTY_ELEMENT);
|
Assert.assertTrue(propertyElement.getAccessType()==AccessType.PROPERTY_ELEMENT);
|
||||||
logger.info(ElementMapper.marshal(propertyElement));
|
logger.info(ElementMapper.marshal(propertyElement));
|
||||||
|
|
||||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
PropertyType propertyType = (PropertyType) TypeMapper.createTypeDefinition(PropertyType.class);
|
||||||
PropertyType<PropertyType> propertyType = (PropertyType<PropertyType>) TypeMapper.createTypeDefinition(PropertyType.class);
|
|
||||||
Assert.assertTrue(propertyType.getAccessType()==AccessType.PROPERTY_TYPE);
|
Assert.assertTrue(propertyType.getAccessType()==AccessType.PROPERTY_TYPE);
|
||||||
logger.info(ElementMapper.marshal(propertyType));
|
logger.info(ElementMapper.marshal(propertyType));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType propertyDefinition = (PropertyType) TypeMapper.createTypeDefinition(PropertyDefinition.class);
|
||||||
PropertyType<PropertyDefinition> propertyDefinition = (PropertyType<PropertyDefinition>) TypeMapper.createTypeDefinition(PropertyDefinition.class);
|
|
||||||
Assert.assertTrue(propertyDefinition.getAccessType()==AccessType.PROPERTY_DEFINITION);
|
Assert.assertTrue(propertyDefinition.getAccessType()==AccessType.PROPERTY_DEFINITION);
|
||||||
logger.info(ElementMapper.marshal(propertyDefinition));
|
logger.info(ElementMapper.marshal(propertyDefinition));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType linkedEntity = (PropertyType) TypeMapper.createTypeDefinition(LinkedEntity.class);
|
||||||
PropertyType<LinkedEntity> linkedEntity = (PropertyType<LinkedEntity>) TypeMapper.createTypeDefinition(LinkedEntity.class);
|
|
||||||
Assert.assertTrue(linkedEntity.getAccessType()==AccessType.PROPERTY_ELEMENT);
|
Assert.assertTrue(linkedEntity.getAccessType()==AccessType.PROPERTY_ELEMENT);
|
||||||
logger.info(ElementMapper.marshal(linkedEntity));
|
logger.info(ElementMapper.marshal(linkedEntity));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType property = (PropertyType) TypeMapper.createTypeDefinition(Property.class);
|
||||||
PropertyType<Property> property = (PropertyType<Property>) TypeMapper.createTypeDefinition(Property.class);
|
|
||||||
Assert.assertTrue(property.getAccessType()==AccessType.PROPERTY);
|
Assert.assertTrue(property.getAccessType()==AccessType.PROPERTY);
|
||||||
logger.info(ElementMapper.marshal(property));
|
logger.info(ElementMapper.marshal(property));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType metadataType = (PropertyType) TypeMapper.createTypeDefinition(Metadata.class);
|
||||||
PropertyType<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.createTypeDefinition(Metadata.class);
|
|
||||||
Assert.assertTrue(metadataType.getAccessType()==AccessType.PROPERTY);
|
Assert.assertTrue(metadataType.getAccessType()==AccessType.PROPERTY);
|
||||||
logger.info(ElementMapper.marshal(metadataType));
|
logger.info(ElementMapper.marshal(metadataType));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType propagationConstraint = (PropertyType) TypeMapper.createTypeDefinition(PropagationConstraint.class);
|
||||||
PropertyType<PropagationConstraint> propagationConstraint = (PropertyType<PropagationConstraint>) TypeMapper.createTypeDefinition(PropagationConstraint.class);
|
|
||||||
Assert.assertTrue(propagationConstraint.getAccessType()==AccessType.PROPERTY);
|
Assert.assertTrue(propagationConstraint.getAccessType()==AccessType.PROPERTY);
|
||||||
logger.info(ElementMapper.marshal(propagationConstraint));
|
logger.info(ElementMapper.marshal(propagationConstraint));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType encrypted = (PropertyType) TypeMapper.createTypeDefinition(Encrypted.class);
|
||||||
PropertyType<Encrypted> encrypted = (PropertyType<Encrypted>) TypeMapper.createTypeDefinition(Encrypted.class);
|
|
||||||
Assert.assertTrue(encrypted.getAccessType()==AccessType.PROPERTY);
|
Assert.assertTrue(encrypted.getAccessType()==AccessType.PROPERTY);
|
||||||
logger.info(ElementMapper.marshal(encrypted));
|
logger.info(ElementMapper.marshal(encrypted));
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
PropertyType templateVariable = (PropertyType) TypeMapper.createTypeDefinition(TemplateVariable.class);
|
||||||
PropertyType<TemplateVariable> templateVariable = (PropertyType<TemplateVariable>) TypeMapper.createTypeDefinition(TemplateVariable.class);
|
|
||||||
Assert.assertTrue(templateVariable.getAccessType()==AccessType.PROPERTY_ELEMENT);
|
Assert.assertTrue(templateVariable.getAccessType()==AccessType.PROPERTY_ELEMENT);
|
||||||
logger.info(ElementMapper.marshal(templateVariable));
|
logger.info(ElementMapper.marshal(templateVariable));
|
||||||
}
|
}
|
||||||
|
@ -216,16 +207,16 @@ public class SerializationTest {
|
||||||
public void testTypeSerialization() throws Exception {
|
public void testTypeSerialization() throws Exception {
|
||||||
String serialized = TypeMapper.serializeType(Metadata.class);
|
String serialized = TypeMapper.serializeType(Metadata.class);
|
||||||
logger.info(serialized);
|
logger.info(serialized);
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
PropertyType<Metadata> propertyType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(serialized);
|
PropertyType propertyType = (PropertyType) TypeMapper.deserializeTypeDefinition(serialized);
|
||||||
Version typeVersion = propertyType.getVersion();
|
Version typeVersion = propertyType.getVersion();
|
||||||
logger.debug("Version {}", typeVersion.toString());
|
logger.debug("Version {}", typeVersion.toString());
|
||||||
logger.info(ElementMapper.marshal(propertyType));
|
logger.info(ElementMapper.marshal(propertyType));
|
||||||
|
|
||||||
String json = "{\"" + Element.TYPE_PROPERTY + "\":\"PropertyType\",\"metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"typeSuperTypes\":[\"Property\"],\"properties\":[{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"" + IdentifiableElement.ID_PROPERTY + "\",\"description\":\"This ID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"propertyType\":\"String\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
|
String json = "{\"" + Element.TYPE_PROPERTY + "\":\"PropertyType\",\"metadata\":null,\"name\":\"Metadata\",\"description\":\"This class provides metadata per every IdentifiableElement\",\"typeSuperTypes\":[\"Property\"],\"properties\":[{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"creationTime\",\"description\":\"Creation time. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateTime\",\"description\":\"Last Update time. At creation time it assumes the same value of creationTime. It represents the difference, measured in milliseconds, between the creation time and midnight, January 1, 1970, UTC.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"Date\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"createdBy\",\"description\":\"The user that created the Entity or the Relation. It is initialized at creation time. \",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"" + IdentifiableElement.ID_PROPERTY + "\",\"description\":\"This ID is be used to identify the Entity or the Relation univocally.\",\"mandatory\":true,\"readonly\":true,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":\"^([a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}){1}$\",\"propertyType\":\"String\"},{\"" + Element.TYPE_PROPERTY + "\":\"PropertyDefinition\",\"name\":\"lastUpdateBy\",\"description\":\"The user that made the last update to the Entity or the Relation. At creation time, it assumes the same value of creator.\",\"mandatory\":true,\"readonly\":false,\"notnull\":true,\"max\":null,\"min\":null,\"regexp\":null,\"propertyType\":\"String\"}],\"accessType\":\"PROPERTY\",\"abstract\":false,\"version\":\"1.0.0\",\"changelog\":{\"1.0.0\":\"First Version\"}}";
|
||||||
logger.info(json);
|
logger.info(json);
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
PropertyType<Metadata> metadataType = (PropertyType<Metadata>) TypeMapper.deserializeTypeDefinition(json);
|
PropertyType metadataType = (PropertyType) TypeMapper.deserializeTypeDefinition(json);
|
||||||
logger.info(ElementMapper.marshal(metadataType));
|
logger.info(ElementMapper.marshal(metadataType));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue