dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #41987
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21446: Minor, use AnnotationUtils.findAnnotation() instead of Method.getAnnotation() as its supports met...
------------------------------------------------------------
revno: 21446
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-12-14 17:55:51 +0100
message:
Minor, use AnnotationUtils.findAnnotation() instead of Method.getAnnotation() as its supports method overrides
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaUtils.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaUtils.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaUtils.java 2015-05-06 13:36:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/schema/SchemaUtils.java 2015-12-14 16:55:51 +0000
@@ -30,9 +30,9 @@
import com.google.common.collect.Sets;
import com.google.common.primitives.Primitives;
-
import org.hisp.dhis.common.IdentifiableObject;
import org.hisp.dhis.schema.annotation.PropertyRange;
+import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.Assert;
import java.util.Collection;
@@ -47,7 +47,7 @@
public final class SchemaUtils
{
private static final Set<PropertyType> PROPS_IGNORE_MINMAX = Sets.newHashSet( REFERENCE, BOOLEAN, DATE, CONSTANT );
-
+
public static void updatePropertyTypes( Property property )
{
Assert.notNull( property );
@@ -62,14 +62,14 @@
if ( property.isWritable() )
{
- if ( property.getGetterMethod().isAnnotationPresent( org.hisp.dhis.schema.annotation.Property.class ) )
+ if ( AnnotationUtils.findAnnotation( property.getGetterMethod(), org.hisp.dhis.schema.annotation.Property.class ) != null )
{
- property.setPropertyType( property.getGetterMethod().getAnnotation( org.hisp.dhis.schema.annotation.Property.class ).value() );
+ property.setPropertyType( AnnotationUtils.findAnnotation( property.getGetterMethod(), org.hisp.dhis.schema.annotation.Property.class ).value() );
}
- if ( property.getGetterMethod().isAnnotationPresent( PropertyRange.class ) )
+ if ( AnnotationUtils.findAnnotation( property.getGetterMethod(), PropertyRange.class ) != null )
{
- PropertyRange propertyRange = property.getGetterMethod().getAnnotation( PropertyRange.class );
+ PropertyRange propertyRange = AnnotationUtils.findAnnotation( property.getGetterMethod(), PropertyRange.class );
if ( property.getMax() == null || propertyRange.max() <= property.getMax() )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java 2015-09-21 04:59:10 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/DefaultSchemaService.java 2015-12-14 16:55:51 +0000
@@ -37,6 +37,7 @@
import org.hisp.dhis.translation.TranslationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.OrderComparator;
+import org.springframework.core.annotation.AnnotationUtils;
import org.springframework.util.StringUtils;
import javax.annotation.PostConstruct;
@@ -152,9 +153,9 @@
private String getName( Class<?> klass )
{
- if ( klass.isAnnotationPresent( JacksonXmlRootElement.class ) )
+ if ( AnnotationUtils.findAnnotation( klass, JacksonXmlRootElement.class ) != null )
{
- JacksonXmlRootElement rootElement = klass.getAnnotation( JacksonXmlRootElement.class );
+ JacksonXmlRootElement rootElement = AnnotationUtils.findAnnotation( klass, JacksonXmlRootElement.class );
if ( !StringUtils.isEmpty( rootElement.localName() ) )
{
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java 2015-12-14 16:37:59 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/schema/Jackson2PropertyIntrospectorService.java 2015-12-14 16:55:51 +0000
@@ -78,7 +78,7 @@
List<String> classFieldNames = ReflectionUtils.getAllFieldNames( clazz );
// TODO this is quite nasty, should find a better way of exposing properties at class-level
- if ( clazz.isAnnotationPresent( JacksonXmlRootElement.class ) )
+ if ( AnnotationUtils.findAnnotation( clazz, JacksonXmlRootElement.class ) != null )
{
Property property = new Property();