Added @Final annotation to interfaces and final modifier to classes

This commit is contained in:
Luca Frosini 2023-01-24 19:52:18 +01:00
parent 39df1b24cd
commit ce0ddaedd6
19 changed files with 65 additions and 7 deletions

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.model.reference.properties.Encrypted;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonTypeName(value = Encrypted.NAME)
public class EncryptedImpl extends PropertyImpl implements Encrypted {
public final class EncryptedImpl extends PropertyImpl implements Encrypted {
/**
* Generated Serial Version UID

View File

@ -12,7 +12,7 @@ import org.gcube.informationsystem.model.reference.properties.PropagationConstra
* @author Luca Frosini (ISTI - CNR)
*/
@JsonTypeName(value=PropagationConstraint.NAME)
public class PropagationConstraintImpl extends PropertyImpl implements PropagationConstraint {
public final class PropagationConstraintImpl extends PropertyImpl implements PropagationConstraint {
/**
* Generated Serial Version UID

View File

@ -4,6 +4,7 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonGetter;
import org.gcube.com.fasterxml.jackson.annotation.JsonSetter;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.model.impl.properties.EncryptedImpl;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -15,6 +16,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as=EncryptedImpl.class)
@TypeMetadata(name = Encrypted.NAME, description = "This type is used to properly manage encrypted values across contexts.", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface Encrypted extends Property {
public static final String NAME = "Encrypted"; // Encrypted.class.getSimpleName();

View File

@ -10,6 +10,7 @@ import org.gcube.com.fasterxml.jackson.annotation.JsonFormat;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.Element;
import org.gcube.informationsystem.model.impl.properties.HeaderImpl;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -23,6 +24,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as=HeaderImpl.class)
@TypeMetadata(name = Header.NAME, description = "This type provides metadata per every IdentifiableElement", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface Header extends Property {
public static final String NAME = "Header"; // Header.class.getSimpleName();

View File

@ -5,6 +5,7 @@ package org.gcube.informationsystem.model.reference.properties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.model.impl.properties.PropagationConstraintImpl;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -28,6 +29,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as=PropagationConstraintImpl.class)
@TypeMetadata(name = PropagationConstraint.NAME, description = "This type provides propagation constraint for Relation", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface PropagationConstraint extends Property {
public static final String NAME = "PropagationConstraint"; // PropagationConstraint.class.getSimpleName();

View File

@ -0,0 +1,19 @@
package org.gcube.informationsystem.types.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.gcube.informationsystem.base.reference.Element;
/**
* It indicates that the {@link Element} is final and cannot be extended/derived.
* This is needed because the type definition is made with interface.
* @author Luca Frosini (ISTI - CNR)
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface Final {
}

View File

@ -23,6 +23,7 @@ import org.gcube.informationsystem.base.reference.relations.RelationElement;
import org.gcube.informationsystem.model.reference.properties.Header;
import org.gcube.informationsystem.types.TypeMapper;
import org.gcube.informationsystem.types.annotations.Abstract;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.entities.EntityTypeImpl;
import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl;
@ -72,8 +73,12 @@ public class TypeImpl implements Type {
@JsonInclude(Include.NON_NULL)
protected Map<Version, String> changelog;
@JsonProperty(value = "abstract")
@JsonProperty(value = ABSTRACT_PROPERTY)
protected boolean abstractType;
@JsonProperty(value = FINAL_PROPERTY)
protected boolean finalClass;
protected Set<String> superClasses;
protected Set<PropertyDefinition> properties;
@ -182,6 +187,10 @@ public class TypeImpl implements Type {
this.abstractType = true;
}
if(clz.isAnnotationPresent(Final.class)) {
this.finalClass = true;
}
}
@Override
@ -253,6 +262,11 @@ public class TypeImpl implements Type {
public boolean isAbstract() {
return abstractType;
}
@Override
public boolean isFinal() {
return finalClass;
}
@Override
public Set<String> getSuperClasses() {

View File

@ -14,7 +14,7 @@ import org.gcube.informationsystem.types.reference.properties.PropertyDefinition
* @author Luca Frosini (ISTI - CNR)
*/
@JsonTypeName(value=FacetType.NAME)
public class FacetTypeImpl extends EntityTypeImpl implements FacetType {
public final class FacetTypeImpl extends EntityTypeImpl implements FacetType {
/**
* Generated Serial Version UID

View File

@ -20,7 +20,7 @@ import org.gcube.informationsystem.types.reference.properties.LinkedEntity;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonTypeName(value=ResourceType.NAME)
public class ResourceTypeImpl extends EntityTypeImpl implements ResourceType {
public final class ResourceTypeImpl extends EntityTypeImpl implements ResourceType {
/**
* Generated Serial Version UID

View File

@ -19,7 +19,7 @@ import org.gcube.informationsystem.types.reference.relations.ConsistsOfType;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonTypeName(value=ConsistsOfType.NAME)
public class ConsistsOfTypeImpl extends RelationTypeImpl<ResourceType, FacetType> implements ConsistsOfType {
public final class ConsistsOfTypeImpl extends RelationTypeImpl<ResourceType, FacetType> implements ConsistsOfType {
/**
* Generated Serial Version UID

View File

@ -16,7 +16,7 @@ import org.gcube.informationsystem.types.reference.relations.IsRelatedToType;
* @author Luca Frosini (ISTI - CNR)
*/
@JsonTypeName(value=IsRelatedToType.NAME)
public class IsRelatedToTypeImpl extends RelationTypeImpl<ResourceType, ResourceType> implements IsRelatedToType {
public final class IsRelatedToTypeImpl extends RelationTypeImpl<ResourceType, ResourceType> implements IsRelatedToType {
/**
* Generated Serial Version UID

View File

@ -29,6 +29,7 @@ public interface Type extends IdentifiableElement {
public static final String VERSION_PROPERTY = "version";
public static final String CHANGELOG_PROPERTY = "changelog";
public static final String ABSTRACT_PROPERTY = "abstract";
public static final String FINAL_PROPERTY = "final";
public static final String TYPE_SUPERCLASSES_PROPERTY = "superClasses";
public static final String PROPERTIES_PROPERTY = "properties";
@ -48,8 +49,12 @@ public interface Type extends IdentifiableElement {
@JsonGetter(value = CHANGELOG_PROPERTY)
public Map<String, String> getChangelogWithVersionAsString();
@JsonGetter(value = ABSTRACT_PROPERTY)
public boolean isAbstract();
@JsonGetter(value = FINAL_PROPERTY)
public boolean isFinal();
public Set<String> getSuperClasses();
public Set<PropertyDefinition> getProperties();

View File

@ -4,6 +4,7 @@ import java.util.Set;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.entities.FacetTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
@ -19,6 +20,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as = FacetTypeImpl.class)
@TypeMetadata(name = FacetType.NAME, description = "This class provides information for the definition of any FacetType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface FacetType extends EntityType {
public static final String NAME = "FacetType"; //FacetType.class.getSimpleName();

View File

@ -3,6 +3,7 @@ package org.gcube.informationsystem.types.reference.entities;
import java.util.List;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.entities.ResourceTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
@ -16,6 +17,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as=ResourceTypeImpl.class)
@TypeMetadata(name = ResourceType.NAME, description = "This class provides information for the definition of any ResourceType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface ResourceType extends EntityType {
public static final String NAME = "ResourceType"; //ResourceType.class.getSimpleName();

View File

@ -2,6 +2,7 @@ package org.gcube.informationsystem.types.reference.properties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.properties.LinkedEntityImpl;
import org.gcube.informationsystem.types.reference.Change;
@ -18,6 +19,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as=LinkedEntityImpl.class)
@TypeMetadata(name = LinkedEntity.NAME, description = " A convenient type to define a Resource in terms of: mandatory/recommended ConsistsOf->Facets; suggested IsRelatedTo->Resource.", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface LinkedEntity extends PropertyElement, Comparable<LinkedEntity> {
public static final String NAME = "LinkedEntity"; // LinkedEntity.class.getSimpleName();

View File

@ -3,6 +3,7 @@ package org.gcube.informationsystem.types.reference.properties;
import org.gcube.com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.properties.PropertyDefinitionImpl;
import org.gcube.informationsystem.types.reference.Change;
@ -16,6 +17,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as = PropertyDefinitionImpl.class)
@TypeMetadata(name = PropertyDefinition.NAME, description = "This class provides information for the definition of any properties", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface PropertyDefinition extends PropertyElement, Comparable<PropertyDefinition> {
public static final String NAME = "PropertyDefinition"; // PropertyDefinition.class.getSimpleName();

View File

@ -7,6 +7,7 @@ import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.base.reference.IdentifiableElement;
import org.gcube.informationsystem.base.reference.properties.PropertyElement;
import org.gcube.informationsystem.model.reference.properties.Header;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.annotations.ISProperty;
import org.gcube.informationsystem.types.impl.properties.PropertyTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
@ -21,6 +22,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as = PropertyTypeImpl.class)
@TypeMetadata(name = PropertyType.NAME, description = "This class provides information for any PropertyType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface PropertyType<P extends PropertyElement> extends PropertyElement, Type {
public static final String NAME = "PropertyType"; // PropertyTypeDefinition.class.getSimpleName();

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.types.reference.relations;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.impl.relations.ConsistsOfTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -14,6 +15,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as = ConsistsOfTypeImpl.class)
@TypeMetadata(name = ConsistsOfType.NAME, description = "This class provides information for any ConsistsOfType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface ConsistsOfType extends RelationType<ResourceType, FacetType> {
public static final String NAME = "ConsistsOfType"; // ConsistsOfType.class.getSimpleName();

View File

@ -1,6 +1,7 @@
package org.gcube.informationsystem.types.reference.relations;
import org.gcube.com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import org.gcube.informationsystem.types.annotations.Final;
import org.gcube.informationsystem.types.impl.relations.IsRelatedToTypeImpl;
import org.gcube.informationsystem.types.reference.Change;
import org.gcube.informationsystem.types.reference.TypeMetadata;
@ -13,6 +14,7 @@ import org.gcube.informationsystem.utils.Version;
@JsonDeserialize(as = IsRelatedToTypeImpl.class)
@TypeMetadata(name = IsRelatedToType.NAME, description = "This class provides information for any IsRelatedToType", version = Version.MINIMAL_VERSION_STRING)
@Change(version = Version.MINIMAL_VERSION_STRING, description = Version.MINIMAL_VERSION_DESCRIPTION)
@Final
public interface IsRelatedToType extends RelationType<ResourceType, ResourceType> {
public static final String NAME = "IsRelatedToType"; // IsRelatedToType.class.getSimpleName();