当前位置: 首页>>代码示例>>Java>>正文


Java Wither类代码示例

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


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

示例1: handle

import lombok.experimental.Wither; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Wither> annotation, Annotation ast, EclipseNode annotationNode) {
	handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither");
	
	EclipseNode node = annotationNode.up();
	AccessLevel level = annotation.getInstance().value();
	if (level == AccessLevel.NONE || node == null) return;
	
	List<Annotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod=", annotationNode);
	List<Annotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam=", annotationNode);
	
	switch (node.getKind()) {
	case FIELD:
		createWitherForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, true, onMethod, onParam);
		break;
	case TYPE:
		if (!onMethod.isEmpty()) {
			annotationNode.addError("'onMethod' is not supported for @Wither on a type.");
		}
		if (!onParam.isEmpty()) {
			annotationNode.addError("'onParam' is not supported for @Wither on a type.");
		}
		generateWitherForType(node, annotationNode, level, false);
		break;
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:HandleWither.java

示例2: handle

import lombok.experimental.Wither; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Wither> annotation, JCAnnotation ast, JavacNode annotationNode) {
	handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.WITHER_FLAG_USAGE, "@Wither");
	
	Collection<JavacNode> fields = annotationNode.upFromAnnotationToFields();
	deleteAnnotationIfNeccessary(annotationNode, Wither.class);
	deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
	JavacNode node = annotationNode.up();
	AccessLevel level = annotation.getInstance().value();
	
	if (level == AccessLevel.NONE || node == null) return;
	
	List<JCAnnotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Wither(onMethod=", annotationNode);
	List<JCAnnotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Wither(onParam=", annotationNode);
	
	switch (node.getKind()) {
	case FIELD:
		createWitherForFields(level, fields, annotationNode, true, onMethod, onParam);
		break;
	case TYPE:
		if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Wither on a type.");
		if (!onParam.isEmpty()) annotationNode.addError("'onParam' is not supported for @Wither on a type.");
		generateWitherForType(node, annotationNode, level, false);
		break;
	}
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:HandleWither.java

示例3: getWitherFields

import lombok.experimental.Wither; //导入依赖的package包/类
@NotNull
private Collection<PsiField> getWitherFields(@NotNull PsiClass psiClass) {
  Collection<PsiField> witherFields = new ArrayList<PsiField>();
  for (PsiField psiField : psiClass.getFields()) {
    boolean createWither = true;
    PsiModifierList modifierList = psiField.getModifierList();
    if (null != modifierList) {
      // Skip static fields.
      createWither = !modifierList.hasModifierProperty(PsiModifier.STATIC);
      // Skip final fields
      createWither &= !(modifierList.hasModifierProperty(PsiModifier.FINAL) && psiField.hasInitializer());
      // Skip fields that start with $
      createWither &= !psiField.getName().startsWith(LombokUtils.LOMBOK_INTERN_FIELD_MARKER);
      // Skip fields having Wither annotation already
      createWither &= !PsiAnnotationSearchUtil.isAnnotatedWith(psiField, Wither.class);
    }
    if (createWither) {
      witherFields.add(psiField);
    }
  }
  return witherFields;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:23,代码来源:WitherProcessor.java

示例4: handle

import lombok.experimental.Wither; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Wither> annotation, Annotation ast, EclipseNode annotationNode) {
	EclipseNode node = annotationNode.up();
	AccessLevel level = annotation.getInstance().value();
	if (level == AccessLevel.NONE || node == null) return;
	
	List<Annotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Setter(onMethod=", annotationNode);
	List<Annotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Setter(onParam=", annotationNode);
	
	switch (node.getKind()) {
	case FIELD:
		createWitherForFields(level, annotationNode.upFromAnnotationToFields(), annotationNode, annotationNode.get(), true, onMethod, onParam);
		break;
	case TYPE:
		if (!onMethod.isEmpty()) {
			annotationNode.addError("'onMethod' is not supported for @Wither on a type.");
		}
		if (!onParam.isEmpty()) {
			annotationNode.addError("'onParam' is not supported for @Wither on a type.");
		}
		generateWitherForType(node, annotationNode, level, false);
		break;
	}
}
 
开发者ID:redundent,项目名称:lombok,代码行数:24,代码来源:HandleWither.java

示例5: handle

import lombok.experimental.Wither; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Wither> annotation, JCAnnotation ast, JavacNode annotationNode) {
	Collection<JavacNode> fields = annotationNode.upFromAnnotationToFields();
	deleteAnnotationIfNeccessary(annotationNode, Wither.class);
	deleteImportFromCompilationUnit(annotationNode, "lombok.AccessLevel");
	JavacNode node = annotationNode.up();
	AccessLevel level = annotation.getInstance().value();
	
	if (level == AccessLevel.NONE || node == null) return;
	
	List<JCAnnotation> onMethod = unboxAndRemoveAnnotationParameter(ast, "onMethod", "@Setter(onMethod=", annotationNode);
	List<JCAnnotation> onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@Setter(onParam=", annotationNode);
	
	switch (node.getKind()) {
	case FIELD:
		createWitherForFields(level, fields, annotationNode, true, onMethod, onParam);
		break;
	case TYPE:
		if (!onMethod.isEmpty()) annotationNode.addError("'onMethod' is not supported for @Wither on a type.");
		if (!onParam.isEmpty()) annotationNode.addError("'onParam' is not supported for @Wither on a type.");
		generateWitherForType(node, annotationNode, level, false);
		break;
	}
}
 
开发者ID:redundent,项目名称:lombok,代码行数:24,代码来源:HandleWither.java

示例6: generateWitherForField

import lombok.experimental.Wither; //导入依赖的package包/类
/**
 * Generates a wither on the stated field.
 * 
 * Used by {@link HandleValue}.
 * 
 * The difference between this call and the handle method is as follows:
 * 
 * If there is a {@code lombok.experimental.Wither} annotation on the field, it is used and the
 * same rules apply (e.g. warning if the method already exists, stated access level applies).
 * If not, the wither is still generated if it isn't already there, though there will not
 * be a warning if its already there. The default access level is used.
 */
public void generateWitherForField(EclipseNode fieldNode, EclipseNode sourceNode, AccessLevel level) {
	for (EclipseNode child : fieldNode.down()) {
		if (child.getKind() == Kind.ANNOTATION) {
			if (annotationTypeMatches(Wither.class, child)) {
				//The annotation will make it happen, so we can skip it.
				return;
			}
		}
	}
	
	List<Annotation> empty = Collections.emptyList();
	createWitherForField(level, fieldNode, sourceNode, false, empty, empty);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:26,代码来源:HandleWither.java

示例7: createWitherMethod

import lombok.experimental.Wither; //导入依赖的package包/类
@Nullable
public PsiMethod createWitherMethod(@NotNull PsiField psiField, @NotNull String methodModifier, @NotNull AccessorsInfo accessorsInfo) {
  LombokLightMethodBuilder result = null;
  final PsiClass psiFieldContainingClass = psiField.getContainingClass();
  if (psiFieldContainingClass != null) {
    final PsiType returnType = PsiClassUtil.getTypeWithGenerics(psiFieldContainingClass);
    final String psiFieldName = psiField.getName();
    final PsiType psiFieldType = psiField.getType();

    result = new LombokLightMethodBuilder(psiField.getManager(), getWitherName(accessorsInfo, psiFieldName, psiFieldType))
      .withMethodReturnType(returnType)
      .withContainingClass(psiFieldContainingClass)
      .withNavigationElement(psiField)
      .withModifier(methodModifier);

    PsiAnnotation witherAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, Wither.class);
    addOnXAnnotations(witherAnnotation, result.getModifierList(), "onMethod");

    final LombokLightParameter methodParameter = new LombokLightParameter(psiFieldName, psiFieldType, result, JavaLanguage.INSTANCE);
    PsiModifierList methodParameterModifierList = methodParameter.getModifierList();
    copyAnnotations(psiField, methodParameterModifierList,
      LombokUtils.NON_NULL_PATTERN, LombokUtils.NULLABLE_PATTERN, LombokUtils.DEPRECATED_PATTERN);
    addOnXAnnotations(witherAnnotation, methodParameterModifierList, "onParam");
    result.withParameter(methodParameter);

    if (psiFieldContainingClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
      result.withModifier(PsiModifier.ABSTRACT);
    } else {
      result.withBody(createCodeBlock(psiField, psiFieldContainingClass, returnType, psiFieldName));
    }
  }
  return result;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:34,代码来源:WitherFieldProcessor.java

示例8: generateWitherForType

import lombok.experimental.Wither; //导入依赖的package包/类
public boolean generateWitherForType(EclipseNode typeNode, EclipseNode pos, AccessLevel level, boolean checkForTypeLevelWither) {
	if (checkForTypeLevelWither) {
		if (hasAnnotation(Wither.class, typeNode)) {
			//The annotation will make it happen, so we can skip it.
			return true;
		}
	}
	
	TypeDeclaration typeDecl = null;
	if (typeNode.get() instanceof TypeDeclaration) typeDecl = (TypeDeclaration) typeNode.get();
	int modifiers = typeDecl == null ? 0 : typeDecl.modifiers;
	boolean notAClass = (modifiers &
			(ClassFileConstants.AccInterface | ClassFileConstants.AccAnnotation | ClassFileConstants.AccEnum)) != 0;
	
	if (typeDecl == null || notAClass) {
		pos.addError("@Wither is only supported on a class or a field.");
		return false;
	}
	
	for (EclipseNode field : typeNode.down()) {
		if (field.getKind() != Kind.FIELD) continue;
		FieldDeclaration fieldDecl = (FieldDeclaration) field.get();
		if (!filterField(fieldDecl)) continue;
		
		//Skip final fields.
		if ((fieldDecl.modifiers & ClassFileConstants.AccFinal) != 0 && fieldDecl.initialization != null) continue;
		
		generateWitherForField(field, pos.get(), level);
	}
	return true;
}
 
开发者ID:redundent,项目名称:lombok,代码行数:32,代码来源:HandleWither.java

示例9: generateWitherForField

import lombok.experimental.Wither; //导入依赖的package包/类
/**
 * Generates a wither on the stated field.
 * 
 * Used by {@link HandleValue}.
 * 
 * The difference between this call and the handle method is as follows:
 * 
 * If there is a {@code lombok.experimental.Wither} annotation on the field, it is used and the
 * same rules apply (e.g. warning if the method already exists, stated access level applies).
 * If not, the wither is still generated if it isn't already there, though there will not
 * be a warning if its already there. The default access level is used.
 */
public void generateWitherForField(EclipseNode fieldNode, ASTNode pos, AccessLevel level) {
	for (EclipseNode child : fieldNode.down()) {
		if (child.getKind() == Kind.ANNOTATION) {
			if (annotationTypeMatches(Wither.class, child)) {
				//The annotation will make it happen, so we can skip it.
				return;
			}
		}
	}
	
	List<Annotation> empty = Collections.emptyList();
	createWitherForField(level, fieldNode, fieldNode, pos, false, empty, empty);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:26,代码来源:HandleWither.java

示例10: WitherProcessor

import lombok.experimental.Wither; //导入依赖的package包/类
public WitherProcessor(WitherFieldProcessor fieldProcessor) {
  super(PsiMethod.class, Wither.class);
  this.fieldProcessor = fieldProcessor;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:5,代码来源:WitherProcessor.java

示例11: WitherFieldProcessor

import lombok.experimental.Wither; //导入依赖的package包/类
public WitherFieldProcessor(RequiredArgsConstructorProcessor requiredArgsConstructorProcessor) {
  super(PsiMethod.class, Wither.class);
  this.requiredArgsConstructorProcessor = requiredArgsConstructorProcessor;
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:5,代码来源:WitherFieldProcessor.java

示例12: generateWitherForField

import lombok.experimental.Wither; //导入依赖的package包/类
/**
 * Generates a wither on the stated field.
 * 
 * Used by {@link HandleValue}.
 * 
 * The difference between this call and the handle method is as follows:
 * 
 * If there is a {@code lombok.experimental.Wither} annotation on the field, it is used and the
 * same rules apply (e.g. warning if the method already exists, stated access level applies).
 * If not, the wither is still generated if it isn't already there, though there will not
 * be a warning if its already there. The default access level is used.
 * 
 * @param fieldNode The node representing the field you want a wither for.
 * @param pos The node responsible for generating the wither (the {@code @Value} or {@code @Wither} annotation).
 */
public void generateWitherForField(JavacNode fieldNode, DiagnosticPosition pos, AccessLevel level) {
	if (hasAnnotation(Wither.class, fieldNode)) {
		//The annotation will make it happen, so we can skip it.
		return;
	}
	
	createWitherForField(level, fieldNode, fieldNode, false, List.<JCAnnotation>nil(), List.<JCAnnotation>nil());
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:24,代码来源:HandleWither.java


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