本文整理汇总了Java中com.google.auto.common.MoreElements.getLocalAndInheritedMethods方法的典型用法代码示例。如果您正苦于以下问题:Java MoreElements.getLocalAndInheritedMethods方法的具体用法?Java MoreElements.getLocalAndInheritedMethods怎么用?Java MoreElements.getLocalAndInheritedMethods使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.auto.common.MoreElements
的用法示例。
在下文中一共展示了MoreElements.getLocalAndInheritedMethods方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findWriteToParcel
import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
@Nullable private ExecutableElement findWriteToParcel(TypeElement subject) {
TypeMirror parcel = elements.getTypeElement("android.os.Parcel").asType();
@SuppressWarnings("deprecation") // Support for kapt2
ImmutableSet<ExecutableElement> methods =
MoreElements.getLocalAndInheritedMethods(subject, elements);
for (ExecutableElement element : methods) {
if (element.getSimpleName().contentEquals("writeToParcel")
&& MoreTypes.isTypeOf(void.class, element.getReturnType())
&& !element.getModifiers().contains(Modifier.ABSTRACT)) {
List<? extends VariableElement> parameters = element.getParameters();
if (parameters.size() == 2
&& types.isSameType(parcel, parameters.get(0).asType())
&& MoreTypes.isTypeOf(int.class, parameters.get(1).asType())) {
return element;
}
}
}
return null;
}
示例2: needsContentDescriptor
import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
private static boolean needsContentDescriptor(Context context) {
ProcessingEnvironment env = context.processingEnvironment();
TypeElement autoValueTypeElement = context.autoValueClass();
Elements elements = env.getElementUtils();
@SuppressWarnings("deprecation") // Support for kapt2
ImmutableSet<ExecutableElement> methods =
MoreElements.getLocalAndInheritedMethods(autoValueTypeElement, elements);
for (ExecutableElement element : methods) {
if (element.getSimpleName().contentEquals("describeContents")
&& MoreTypes.isTypeOf(int.class, element.getReturnType())
&& element.getParameters().isEmpty()
&& !element.getModifiers().contains(ABSTRACT)) {
return false;
}
}
return true;
}
示例3: findWriteToParcel
import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
private static ExecutableElement findWriteToParcel(Context context) {
ProcessingEnvironment env = context.processingEnvironment();
TypeMirror parcel = env.getElementUtils().getTypeElement("android.os.Parcel").asType();
for (ExecutableElement element : MoreElements.getLocalAndInheritedMethods(
context.autoValueClass(), env.getElementUtils())) {
if (element.getSimpleName().contentEquals("writeToParcel")
&& MoreTypes.isTypeOf(void.class, element.getReturnType())
&& !element.getModifiers().contains(ABSTRACT)) {
List<? extends VariableElement> parameters = element.getParameters();
if (parameters.size() == 2
&& env.getTypeUtils().isSameType(parcel, parameters.get(0).asType())
&& MoreTypes.isTypeOf(int.class, parameters.get(1).asType())) {
return element;
}
}
}
return null;
}
示例4: needsContentDescriptor
import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
private static boolean needsContentDescriptor(Context context) {
ProcessingEnvironment env = context.processingEnvironment();
for (ExecutableElement element : MoreElements.getLocalAndInheritedMethods(
context.autoValueClass(), env.getElementUtils())) {
if (element.getSimpleName().contentEquals("describeContents")
&& MoreTypes.isTypeOf(int.class, element.getReturnType())
&& element.getParameters().isEmpty()
&& !element.getModifiers().contains(ABSTRACT)) {
return false;
}
}
return true;
}
示例5: createContext
import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
private AutoValueExtension.Context createContext(TypeElement type) {
String packageName = MoreElements.getPackage(type).getQualifiedName().toString();
Set<ExecutableElement> allMethods = MoreElements.getLocalAndInheritedMethods(type, elements);
Set<ExecutableElement> methods = methodsToImplement(type, allMethods);
Map<String, ExecutableElement> properties = new LinkedHashMap<String, ExecutableElement>();
for (ExecutableElement e : methods) {
properties.put(e.getSimpleName().toString(), e);
}
return new TestContext(processingEnvironment, packageName, type, properties);
}
示例6: create
import com.google.auto.common.MoreElements; //导入方法依赖的package包/类
PaperParcelDescriptor create(TypeElement element, OptionsDescriptor options)
throws NonWritableFieldsException, NonReadableFieldsException {
ImmutableList<VariableElement> fields = Utils.getFieldsToParcel(element, options);
//noinspection deprecation: Support for kapt2
ImmutableSet<ExecutableElement> methods =
MoreElements.getLocalAndInheritedMethods(element, elements);
ImmutableList<ExecutableElement> constructors =
Utils.orderedConstructorsIn(element, options.reflectAnnotations());
ImmutableList<FieldDescriptor> constructorFields;
boolean isConstructorVisible;
ImmutableList<FieldDescriptor> writableFields;
ImmutableMap<FieldDescriptor, ExecutableElement> setterMethodMap;
ImmutableList<FieldDescriptor> readableFields;
ImmutableMap<FieldDescriptor, ExecutableElement> getterMethodMap;
ImmutableMap<FieldDescriptor, AdapterDescriptor> adapters;
boolean singleton = Utils.isSingleton(types, element);
if (!singleton) {
WriteInfo writeInfo = WriteInfo.create(element, types, fieldDescriptorFactory, fields,
methods, constructors, options.reflectAnnotations());
constructorFields = writeInfo.constructorFields();
isConstructorVisible = writeInfo.isConstructorVisible();
writableFields = writeInfo.writableFields();
setterMethodMap = writeInfo.setterMethodMap();
ReadInfo readInfo = ReadInfo.create(element, types, fieldDescriptorFactory, fields,
methods, options.reflectAnnotations());
readableFields = readInfo.readableFields();
getterMethodMap = readInfo.getterMethodMap();
adapters = getAdapterMap(readInfo, options.allowSerializable());
} else {
constructorFields = ImmutableList.of();
isConstructorVisible = false;
writableFields = ImmutableList.of();
setterMethodMap = ImmutableMap.of();
readableFields = ImmutableList.of();
getterMethodMap = ImmutableMap.of();
adapters = ImmutableMap.of();
}
return new AutoValue_PaperParcelDescriptor(
element,
constructorFields,
isConstructorVisible,
writableFields,
setterMethodMap,
readableFields,
getterMethodMap,
adapters,
singleton);
}