• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ExtensionMethod类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中lombok.experimental.ExtensionMethod的典型用法代码示例。如果您正苦于以下问题:Java ExtensionMethod类的具体用法?Java ExtensionMethod怎么用?Java ExtensionMethod使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ExtensionMethod类属于lombok.experimental包,在下文中一共展示了ExtensionMethod类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getApplicableExtensionMethods

import lombok.experimental.ExtensionMethod; //导入依赖的package包/类
static List<Extension> getApplicableExtensionMethods(EclipseNode typeNode, Annotation ann, TypeBinding receiverType) {
	List<Extension> extensions = new ArrayList<Extension>();
	if ((typeNode != null) && (ann != null) && (receiverType != null)) {
		BlockScope blockScope = ((TypeDeclaration) typeNode.get()).initializerScope;
		EclipseNode annotationNode = typeNode.getNodeFor(ann);
		AnnotationValues<ExtensionMethod> annotation = createAnnotation(ExtensionMethod.class, annotationNode);
		boolean suppressBaseMethods = false;
		try {
			suppressBaseMethods = annotation.getInstance().suppressBaseMethods();
		} catch (AnnotationValueDecodeFail fail) {
			fail.owner.setError(fail.getMessage(), fail.idx);
		}
		for (Object extensionMethodProvider : annotation.getActualExpressions("value")) {
			if (extensionMethodProvider instanceof ClassLiteralAccess) {
				TypeBinding binding = ((ClassLiteralAccess) extensionMethodProvider).type.resolveType(blockScope);
				if (binding == null) continue;
				if (!binding.isClass() && !binding.isEnum()) continue;
				Extension e = new Extension();
				e.extensionMethods = getApplicableExtensionMethodsDefinedInProvider(typeNode, (ReferenceBinding) binding, receiverType);
				e.suppressBaseMethods = suppressBaseMethods;
				extensions.add(e);
			}
		}
	}
	return extensions;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:27,代码来源:PatchExtensionMethod.java


示例2: handle

import lombok.experimental.ExtensionMethod; //导入依赖的package包/类
@Override public void handle(AnnotationValues<ExtensionMethod> annotation, Annotation ast, EclipseNode annotationNode) {
	TypeDeclaration typeDecl = null;
	EclipseNode owner = annotationNode.up();
	if (owner.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) owner.get();
	int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
	
	boolean notAClass = (modifiers &
			(ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation)) != 0;
	
	if (typeDecl == null || notAClass) {
		annotationNode.addError("@ExtensionMethod is legal only on classes and enums.");
		return;
	}
	
	List<Object> listenerInterfaces = annotation.getActualExpressions("value");
	if (listenerInterfaces.isEmpty()) {
		annotationNode.addWarning(String.format("@ExtensionMethod has no effect since no extension types were specified."));
		return;
	}
}
 
开发者ID:redundent,项目名称:lombok,代码行数:21,代码来源:HandleExtensionMethod.java


示例3: getExtensionMethods

import lombok.experimental.ExtensionMethod; //导入依赖的package包/类
private static List<Extension> getExtensionMethods(CompletionProposalCollector completionProposalCollector) {
	List<Extension> extensions = new ArrayList<Extension>();
	ClassScope classScope = getClassScope(completionProposalCollector);
	if (classScope != null) {
		TypeDeclaration decl = classScope.referenceContext;
		TypeBinding firstParameterType = getFirstParameterType(decl, completionProposalCollector);
		for (EclipseNode typeNode = getTypeNode(decl); typeNode != null; typeNode = upToType(typeNode)) {
			Annotation ann = getAnnotation(ExtensionMethod.class, typeNode);
			extensions.addAll(0, getApplicableExtensionMethods(typeNode, ann, firstParameterType));
		}
	}
	return extensions;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:14,代码来源:PatchExtensionMethodCompletionProposal.java


示例4: handle

import lombok.experimental.ExtensionMethod; //导入依赖的package包/类
@Override
public void handle(final AnnotationValues<ExtensionMethod> annotation, final JCAnnotation source, final JavacNode annotationNode) {
	handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.EXTENSION_METHOD_FLAG_USAGE, "@ExtensionMethod");
	
	deleteAnnotationIfNeccessary(annotationNode, ExtensionMethod.class);
	JavacNode typeNode = annotationNode.up();
	boolean isClassOrEnum = isClassOrEnum(typeNode);
	
	if (!isClassOrEnum) {
		annotationNode.addError("@ExtensionMethod can only be used on a class or an enum");
		return;
	}
	
	boolean suppressBaseMethods = annotation.getInstance().suppressBaseMethods();
	
	List<Object> extensionProviders = annotation.getActualExpressions("value");
	if (extensionProviders.isEmpty()) {
		annotationNode.addError(String.format("@%s has no effect since no extension types were specified.", ExtensionMethod.class.getName()));
		return;
	}
	final List<Extension> extensions = getExtensions(annotationNode, extensionProviders);
	if (extensions.isEmpty()) return;
	
	new ExtensionMethodReplaceVisitor(annotationNode, extensions, suppressBaseMethods).replace();
	
	annotationNode.rebuild();
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:28,代码来源:HandleExtensionMethod.java



注:本文中的lombok.experimental.ExtensionMethod类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java MetaSaveResponseProto类代码示例发布时间:2022-05-22
下一篇:
Java CSSStyleSheet类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap