Added @Inherited to ResourceDef annotation (#2340)
This change avoids duplication of ResourceDef on custom resources, where there is no changes on resource name or profile.
This commit is contained in:
parent
589d323175
commit
0d00954852
|
@ -21,6 +21,7 @@ package ca.uhn.fhir.model.api.annotation;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Inherited;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
@ -28,6 +29,7 @@ import java.lang.annotation.Target;
|
||||||
/**
|
/**
|
||||||
* Class annotation which indicates a resource definition class
|
* Class annotation which indicates a resource definition class
|
||||||
*/
|
*/
|
||||||
|
@Inherited
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Target(value= {ElementType.TYPE})
|
@Target(value= {ElementType.TYPE})
|
||||||
public @interface ResourceDef {
|
public @interface ResourceDef {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import ca.uhn.fhir.util.TestUtil;
|
||||||
import org.hl7.fhir.dstu3.model.Binary;
|
import org.hl7.fhir.dstu3.model.Binary;
|
||||||
import org.hl7.fhir.dstu3.model.CarePlan;
|
import org.hl7.fhir.dstu3.model.CarePlan;
|
||||||
import org.hl7.fhir.dstu3.model.CodeType;
|
import org.hl7.fhir.dstu3.model.CodeType;
|
||||||
|
import org.hl7.fhir.dstu3.model.DomainResource;
|
||||||
import org.hl7.fhir.dstu3.model.IdType;
|
import org.hl7.fhir.dstu3.model.IdType;
|
||||||
import org.hl7.fhir.dstu3.model.Meta;
|
import org.hl7.fhir.dstu3.model.Meta;
|
||||||
import org.hl7.fhir.dstu3.model.Patient;
|
import org.hl7.fhir.dstu3.model.Patient;
|
||||||
|
@ -89,6 +90,15 @@ public class ModelScannerDstu3Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testResourceWithInheritedDef() {
|
||||||
|
try {
|
||||||
|
FhirContext.forDstu3().getResourceDefinition(InheritedResourceDef.class);
|
||||||
|
} catch (ConfigurationException e) {
|
||||||
|
fail("The InheritedResourceDef class should contain a valid HAPI-FHIR annotation inherited from superclass");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testScanExtensionTypes() throws DataFormatException {
|
public void testScanExtensionTypes() throws DataFormatException {
|
||||||
|
|
||||||
|
@ -238,11 +248,25 @@ public class ModelScannerDstu3Test {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class NoResourceDef extends Patient {
|
class NoResourceDef extends DomainResource {
|
||||||
@SearchParamDefinition(name = "foo", path = "Patient.telecom", type = "bar")
|
@SearchParamDefinition(name = "foo", path = "Patient.telecom", type = "bar")
|
||||||
public static final String SP_TELECOM = "foo";
|
public static final String SP_TELECOM = "foo";
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public DomainResource copy() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ResourceType getResourceType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static class InheritedResourceDef extends Patient {
|
||||||
|
public InheritedResourceDef() {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ResourceDef(name = "Patient")
|
@ResourceDef(name = "Patient")
|
||||||
|
|
Loading…
Reference in New Issue