io.micronaut.core.annotation.Introspected Java Examples

The following examples show how to use io.micronaut.core.annotation.Introspected. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AbstractPatternBasedMethod.java    From micronaut-data with Apache License 2.0 6 votes vote down vote up
private boolean resolveDtoIfNecessary(
        @NonNull MethodMatchContext matchContext,
        @NonNull ClassElement queryResultType,
        @Nullable QueryModel query,
        @NonNull ClassElement returnType) {
    if (!TypeUtils.areTypesCompatible(returnType, queryResultType)) {
        if (query != null && returnType.hasStereotype(Introspected.class) && queryResultType.hasStereotype(MappedEntity.class)) {
            if (attemptProjection(matchContext, queryResultType, query, returnType)) {
                return true;
            }
        } else {
            matchContext.fail("Query results in a type [" + queryResultType.getName() + "] whilst method returns an incompatible type: " + returnType.getName());
        }
    }
    return false;
}
 
Example #2
Source File: MappedEntityMapper.java    From micronaut-data with Apache License 2.0 6 votes vote down vote up
/**
 * The bean introspection configuration for a mapped entity.
 *
 * @return The entity
 */
public static AnnotationValue<Introspected> buildIntrospectionConfiguration() {
    final AnnotationValueBuilder<Introspected> builder = AnnotationValue.builder(Introspected.class)
            // don't bother with transients properties
            .member("excludedAnnotations", Transient.class)
            // following are indexed for fast lookups
            .member("indexed",
                    AnnotationValue.builder(Introspected.IndexedAnnotation.class)
                            .member("annotation", Id.class).build(),
                    AnnotationValue.builder(Introspected.IndexedAnnotation.class)
                            .member("annotation", Version.class).build(),
                    AnnotationValue.builder(Introspected.IndexedAnnotation.class)
                            .member("annotation", DateCreated.class).build(),
                    AnnotationValue.builder(Introspected.IndexedAnnotation.class)
                            .member("annotation", DateUpdated.class).build(),
                    AnnotationValue.builder(Introspected.IndexedAnnotation.class)
                            .member("annotation", MappedProperty.class)
                            .member("member", "value").build()
            );
    return builder.build();
}
 
Example #3
Source File: FindByFinder.java    From micronaut-data with Apache License 2.0 5 votes vote down vote up
/**
 * Is the return type compatible.
 * @param methodElement The method element
 * @param matchContext The match context
 * @return The return type
 */
protected boolean isCompatibleReturnType(@NonNull MethodElement methodElement, @NonNull MatchContext matchContext) {
    ClassElement returnType = methodElement.getGenericReturnType();
    if (!returnType.getName().equals("void")) {
        return returnType.hasStereotype(Introspected.class) ||
                returnType.isPrimitive() ||
                ClassUtils.isJavaBasicType(returnType.getName()) ||
                TypeUtils.isContainerType(returnType);
    }
    return false;
}
 
Example #4
Source File: FindOneMethod.java    From micronaut-data with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isMethodMatch(@NonNull MethodElement methodElement, @NonNull MatchContext matchContext) {
    return super.isMethodMatch(methodElement, matchContext) &&
                    matchContext.getReturnType().hasStereotype(Introspected.class);
}
 
Example #5
Source File: AbstractPatternBasedMethod.java    From micronaut-data with Apache License 2.0 4 votes vote down vote up
private boolean isValidResultType(ClassElement returnType) {
    return returnType.hasStereotype(Introspected.class) || ClassUtils.isJavaBasicType(returnType.getName()) || returnType.isPrimitive();
}
 
Example #6
Source File: MappedEntityMapper.java    From micronaut-data with Apache License 2.0 4 votes vote down vote up
@Override
public List<AnnotationValue<?>> map(AnnotationValue<MappedEntity> annotation, VisitorContext visitorContext) {
    AnnotationValue<Introspected> introspectionConfig = buildIntrospectionConfiguration();
    return Collections.singletonList(introspectionConfig);
}