public abstract class

DoublePropertyAnnotation

extends DataPropertyAnnotation

 java.lang.Object

androidx.appsearch.compiler.annotationwrapper.DataPropertyAnnotation

↳androidx.appsearch.compiler.annotationwrapper.DoublePropertyAnnotation

Gradle dependencies

compile group: 'androidx.appsearch', name: 'appsearch-compiler', version: '1.1.0-alpha05'

  • groupId: androidx.appsearch
  • artifactId: appsearch-compiler
  • version: 1.1.0-alpha05

Artifact androidx.appsearch:appsearch-compiler:1.1.0-alpha05 it located at Google repository (https://maven.google.com/)

Overview

An instance of the @Document.DoubleProperty annotation.

Summary

Fields
public static final ClassNameCLASS_NAME

public static final ClassNameCONFIG_CLASS

Constructors
publicDoublePropertyAnnotation()

Methods
public abstract DataPropertyAnnotation.KindgetDataPropertyKind()

The DataPropertyAnnotation.Kind of DataPropertyAnnotation.

public javax.lang.model.type.TypeMirrorgetUnderlyingTypeWithinGenericDoc(IntrospectionHelper helper)

from DataPropertyAnnotationgetClassName, getConfigClassName, getGenericDocArrayGetterName, getGenericDocGetterName, getGenericDocSetterName, getName, getPropertyKind, isRequired, tryParse
from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Fields

public static final ClassName CLASS_NAME

public static final ClassName CONFIG_CLASS

Constructors

public DoublePropertyAnnotation()

Methods

public abstract DataPropertyAnnotation.Kind getDataPropertyKind()

The DataPropertyAnnotation.Kind of DataPropertyAnnotation.

public javax.lang.model.type.TypeMirror getUnderlyingTypeWithinGenericDoc(IntrospectionHelper helper)

Source

/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.appsearch.compiler.annotationwrapper;

import static androidx.appsearch.compiler.IntrospectionHelper.APPSEARCH_SCHEMA_CLASS;
import static androidx.appsearch.compiler.IntrospectionHelper.DOCUMENT_ANNOTATION_CLASS;

import androidx.annotation.NonNull;
import androidx.appsearch.compiler.IntrospectionHelper;

import com.google.auto.value.AutoValue;
import com.squareup.javapoet.ClassName;

import java.util.Map;

import javax.lang.model.type.TypeMirror;

/**
 * An instance of the {@code @Document.DoubleProperty} annotation.
 */
@AutoValue
public abstract class DoublePropertyAnnotation extends DataPropertyAnnotation {
    public static final ClassName CLASS_NAME =
            DOCUMENT_ANNOTATION_CLASS.nestedClass("DoubleProperty");

    public static final ClassName CONFIG_CLASS =
            APPSEARCH_SCHEMA_CLASS.nestedClass("DoublePropertyConfig");

    public DoublePropertyAnnotation() {
        super(
                CLASS_NAME,
                CONFIG_CLASS,
                /* genericDocGetterName= */"getPropertyDouble",
                /* genericDocArrayGetterName= */"getPropertyDoubleArray",
                /* genericDocSetterName= */"setPropertyDouble");
    }

    /**
     * @param defaultName The name to use for the annotated property in case the annotation
     *                    params do not mention an explicit name.
     */
    @NonNull
    static DoublePropertyAnnotation parse(
            @NonNull Map<String, Object> annotationParams, @NonNull String defaultName) {
        String name = (String) annotationParams.get("name");
        return new AutoValue_DoublePropertyAnnotation(
                name.isEmpty() ? defaultName : name, (boolean) annotationParams.get("required"));
    }

    @NonNull
    @Override
    public final Kind getDataPropertyKind() {
        return Kind.DOUBLE_PROPERTY;
    }

    @NonNull
    @Override
    public TypeMirror getUnderlyingTypeWithinGenericDoc(@NonNull IntrospectionHelper helper) {
        return helper.mDoublePrimitiveType;
    }
}