public abstract class

SetterOrField

extends java.lang.Object

 java.lang.Object

↳androidx.appsearch.compiler.SetterOrField

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

A setter/field.

Summary

Constructors
publicSetterOrField()

Methods
public abstract javax.lang.model.element.ElementgetElement()

The setter/field element.

public java.lang.StringgetJvmName()

The setter/field element's name.

public booleanisSetter()

Whether it is a setter.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public SetterOrField()

Methods

public abstract javax.lang.model.element.Element getElement()

The setter/field element.

public java.lang.String getJvmName()

The setter/field element's name.

public boolean isSetter()

Whether it is a setter.

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;

import androidx.annotation.NonNull;

import com.google.auto.value.AutoValue;

import javax.lang.model.element.Element;
import javax.lang.model.element.ElementKind;

/**
 * A setter/field.
 */
@AutoValue
public abstract class SetterOrField {
    /**
     * The setter/field element.
     */
    @NonNull
    public abstract Element getElement();

    /**
     * The setter/field element's name.
     */
    @NonNull
    public String getJvmName() {
        return getElement().getSimpleName().toString();
    }

    /**
     * Whether it is a setter.
     */
    public boolean isSetter() {
        return getElement().getKind() == ElementKind.METHOD;
    }

    @NonNull
    static SetterOrField create(@NonNull Element element) {
        return new AutoValue_SetterOrField(element);
    }
}