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


Java Accessors类代码示例

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


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

示例1: shouldReturnThis0

import lombok.experimental.Accessors; //导入依赖的package包/类
public static boolean shouldReturnThis0(AnnotationValues<Accessors> accessors, AST<?, ?, ?> ast) {
	boolean chainForced = accessors.isExplicit("chain");
	boolean fluentForced = accessors.isExplicit("fluent");
	Accessors instance = accessors.getInstance();
	
	boolean chain = instance.chain();
	boolean fluent = instance.fluent();
	
	if (chainForced) return chain;
	
	if (!chainForced) {
		Boolean chainConfig = ast.readConfiguration(ConfigurationKeys.ACCESSORS_CHAIN);
		if (chainConfig != null) return chainConfig;
	}
	
	if (!fluentForced) {
		Boolean fluentConfig = ast.readConfiguration(ConfigurationKeys.ACCESSORS_FLUENT);
		if (fluentConfig != null) fluent = fluentConfig;
	}
	
	return chain || fluent;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:23,代码来源:HandlerUtil.java

示例2: toAccessorName

import lombok.experimental.Accessors; //导入依赖的package包/类
private static String toAccessorName(AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean,
		String booleanPrefix, String normalPrefix, boolean adhereToFluent) {
	
	if (fieldName.length() == 0) return null;
	
	Accessors ac = accessors.getInstance();
	fieldName = removePrefix(fieldName, ac.prefix());
	if (fieldName == null) return null;
	
	String fName = fieldName.toString();
	if (adhereToFluent && ac.fluent()) return fName;
	
	if (isBoolean && fName.startsWith("is") && fieldName.length() > 2 && !Character.isLowerCase(fieldName.charAt(2))) {
		// The field is for example named 'isRunning'.
		return booleanPrefix + fName.substring(2);
	}
	
	return buildName(isBoolean ? booleanPrefix : normalPrefix, fName);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:20,代码来源:TransformationsUtil.java

示例3: handle

import lombok.experimental.Accessors; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Accessors> annotation, JCAnnotation ast, JavacNode annotationNode) {
	// Accessors itself is handled by HandleGetter/Setter; this is just to ensure that the annotation is removed
	// from the AST when delomboking.
	
	handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.ACCESSORS_FLAG_USAGE, "@Accessors");
	
	deleteAnnotationIfNeccessary(annotationNode, Accessors.class);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:9,代码来源:HandleAccessors.java

示例4: shouldReturnThis

import lombok.experimental.Accessors; //导入依赖的package包/类
/**
 * When generating a setter, the setter either returns void (beanspec) or Self (fluent).
 * This method scans for the {@code Accessors} annotation to figure that out.
 */
public static boolean shouldReturnThis(JavacNode field) {
	if ((((JCVariableDecl) field.get()).mods.flags & Flags.STATIC) != 0) return false;
	
	AnnotationValues<Accessors> accessors = JavacHandlerUtil.getAccessorsForField(field);
	
	return HandlerUtil.shouldReturnThis0(accessors, field.getAst());
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:12,代码来源:JavacHandlerUtil.java

示例5: toAccessorName

import lombok.experimental.Accessors; //导入依赖的package包/类
private static String toAccessorName(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean,
		String booleanPrefix, String normalPrefix, boolean adhereToFluent) {
	
	fieldName = fieldName.toString();
	if (fieldName.length() == 0) return null;
	
	if (Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.GETTER_CONSEQUENT_BOOLEAN))) isBoolean = false;
	boolean explicitPrefix = accessors != null && accessors.isExplicit("prefix");
	boolean explicitFluent = accessors != null && accessors.isExplicit("fluent");
	
	Accessors ac = (explicitPrefix || explicitFluent) ? accessors.getInstance() : null;
	
	List<String> prefix = explicitPrefix ? Arrays.asList(ac.prefix()) : ast.readConfiguration(ConfigurationKeys.ACCESSORS_PREFIX);
	boolean fluent = explicitFluent ? ac.fluent() : Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.ACCESSORS_FLUENT));
	
	fieldName = removePrefix(fieldName, prefix);
	if (fieldName == null) return null;
	
	String fName = fieldName.toString();
	if (adhereToFluent && fluent) return fName;
	
	if (isBoolean && fName.startsWith("is") && fieldName.length() > 2 && !Character.isLowerCase(fieldName.charAt(2))) {
		// The field is for example named 'isRunning'.
		return booleanPrefix + fName.substring(2);
	}
	
	return buildAccessorName(isBoolean ? booleanPrefix : normalPrefix, fName);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:29,代码来源:HandlerUtil.java

示例6: toAllAccessorNames

import lombok.experimental.Accessors; //导入依赖的package包/类
private static List<String> toAllAccessorNames(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean,
		String booleanPrefix, String normalPrefix, boolean adhereToFluent) {
	
	if (Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.GETTER_CONSEQUENT_BOOLEAN))) isBoolean = false;
	if (!isBoolean) {
		String accessorName = toAccessorName(ast, accessors, fieldName, false, booleanPrefix, normalPrefix, adhereToFluent);
		return (accessorName == null) ? Collections.<String>emptyList() : Collections.singletonList(accessorName);
	}
	
	boolean explicitPrefix = accessors != null && accessors.isExplicit("prefix");
	boolean explicitFluent = accessors != null && accessors.isExplicit("fluent");
	
	Accessors ac = (explicitPrefix || explicitFluent) ? accessors.getInstance() : null;
	
	List<String> prefix = explicitPrefix ? Arrays.asList(ac.prefix()) : ast.readConfiguration(ConfigurationKeys.ACCESSORS_PREFIX);
	boolean fluent = explicitFluent ? ac.fluent() : Boolean.TRUE.equals(ast.readConfiguration(ConfigurationKeys.ACCESSORS_FLUENT));
	
	fieldName = removePrefix(fieldName, prefix);
	if (fieldName == null) return Collections.emptyList();
	
	List<String> baseNames = toBaseNames(fieldName, isBoolean, fluent);
	
	Set<String> names = new HashSet<String>();
	for (String baseName : baseNames) {
		if (adhereToFluent && fluent) {
			names.add(baseName);
		} else {
			names.add(buildAccessorName(normalPrefix, baseName));
			if (!normalPrefix.equals(booleanPrefix)) names.add(buildAccessorName(booleanPrefix, baseName));
		}
	}
	
	return new ArrayList<String>(names);
	
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:36,代码来源:HandlerUtil.java

示例7: build

import lombok.experimental.Accessors; //导入依赖的package包/类
@NotNull
public static AccessorsInfo build(@NotNull PsiField psiField) {
  final PsiAnnotation accessorsFieldAnnotation = PsiAnnotationSearchUtil.findAnnotation(psiField, Accessors.class);
  final PsiClass containingClass = psiField.getContainingClass();
  if (null != accessorsFieldAnnotation) {
    return buildFromAnnotation(accessorsFieldAnnotation, containingClass);
  } else {
    return build(containingClass);
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:11,代码来源:AccessorsInfo.java

示例8: shouldReturnThis

import lombok.experimental.Accessors; //导入依赖的package包/类
/**
 * When generating a setter, the setter either returns void (beanspec) or Self (fluent).
 * This method scans for the {@code Accessors} annotation to figure that out.
 */
public static boolean shouldReturnThis(EclipseNode field) {
	if ((((FieldDeclaration) field.get()).modifiers & ClassFileConstants.AccStatic) != 0) return false;
	AnnotationValues<Accessors> accessors = EclipseHandlerUtil.getAccessorsForField(field);
	boolean forced = (accessors.getActualExpression("chain") != null);
	Accessors instance = accessors.getInstance();
	return instance.chain() || (instance.fluent() && !forced);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:12,代码来源:EclipseHandlerUtil.java

示例9: shouldReturnThis

import lombok.experimental.Accessors; //导入依赖的package包/类
/**
 * When generating a setter, the setter either returns void (beanspec) or Self (fluent).
 * This method scans for the {@code Accessors} annotation to figure that out.
 */
public static boolean shouldReturnThis(JavacNode field) {
	if ((((JCVariableDecl) field.get()).mods.flags & Flags.STATIC) != 0) return false;
	
	AnnotationValues<Accessors> accessors = JavacHandlerUtil.getAccessorsForField(field);
	
	boolean forced = (accessors.getActualExpression("chain") != null);
	Accessors instance = accessors.getInstance();
	return instance.chain() || (instance.fluent() && !forced);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:14,代码来源:JavacHandlerUtil.java

示例10: toAllAccessorNames

import lombok.experimental.Accessors; //导入依赖的package包/类
private static List<String> toAllAccessorNames(AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean,
		String booleanPrefix, String normalPrefix, boolean adhereToFluent) {
	
	if (!isBoolean) {
		String accessorName = toAccessorName(accessors, fieldName, false, booleanPrefix, normalPrefix, adhereToFluent);
		return (accessorName == null) ? Collections.<String>emptyList() : Collections.singletonList(accessorName);
	}
	
	Accessors acc = accessors.getInstance();
	fieldName = removePrefix(fieldName, acc.prefix());
	if (fieldName == null) return Collections.emptyList();
	
	List<String> baseNames = toBaseNames(fieldName, isBoolean, acc.fluent());
	
	Set<String> names = new HashSet<String>();
	for (String baseName : baseNames) {
		if (adhereToFluent && acc.fluent()) {
			names.add(baseName);
		} else {
			names.add(buildName(normalPrefix, baseName));
			if (!normalPrefix.equals(booleanPrefix)) names.add(buildName(booleanPrefix, baseName));
		}
	}
	
	return new ArrayList<String>(names);
	
}
 
开发者ID:redundent,项目名称:lombok,代码行数:28,代码来源:TransformationsUtil.java

示例11: handle

import lombok.experimental.Accessors; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Accessors> annotation, Annotation ast, EclipseNode annotationNode) {
	// Accessors itself is handled by HandleGetter/Setter; this is just to ensure that usages are flagged if requested.
	
	handleExperimentalFlagUsage(annotationNode, ConfigurationKeys.ACCESSORS_FLAG_USAGE, "@Accessors");
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:6,代码来源:HandleAccessors.java

示例12: shouldReturnThis

import lombok.experimental.Accessors; //导入依赖的package包/类
/**
 * When generating a setter, the setter either returns void (beanspec) or Self (fluent).
 * This method scans for the {@code Accessors} annotation and associated config properties to figure that out.
 */
public static boolean shouldReturnThis(EclipseNode field) {
	if ((((FieldDeclaration) field.get()).modifiers & ClassFileConstants.AccStatic) != 0) return false;
	AnnotationValues<Accessors> accessors = EclipseHandlerUtil.getAccessorsForField(field);
	return shouldReturnThis0(accessors, field.getAst());
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:10,代码来源:EclipseHandlerUtil.java

示例13: handle

import lombok.experimental.Accessors; //导入依赖的package包/类
@Override public void handle(AnnotationValues<Accessors> annotation, JCAnnotation ast, JavacNode annotationNode) {
	// Accessors itself is handled by HandleGetter/Setter; this is just to ensure that the annotation is removed
	// from the AST when delomboking.
	deleteAnnotationIfNeccessary(annotationNode, Accessors.class);
}
 
开发者ID:redundent,项目名称:lombok,代码行数:6,代码来源:HandleAccessors.java

示例14: toGetterName

import lombok.experimental.Accessors; //导入依赖的package包/类
/**
 * Generates a getter name from a given field name.
 * 
 * Strategy:
 * <ul>
 * <li>Reduce the field's name to its base name by stripping off any prefix (from {@code Accessors}). If the field name does not fit
 * the prefix list, this method immediately returns {@code null}.</li>
 * <li>If {@code Accessors} has {@code fluent=true}, then return the basename.</li>
 * <li>Pick a prefix. 'get' normally, but 'is' if {@code isBoolean} is true.</li>
 * <li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character. If so, return the field name verbatim.</li> 
 * <li>Check if the first character of the field is lowercase. If so, check if the second character
 * exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.</li>
 * <li>Return the prefix plus the possibly title/uppercased first character, and the rest of the field name.</li>
 * </ul>
 * 
 * @param accessors Accessors configuration.
 * @param fieldName the name of the field.
 * @param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}.
 * @return The getter name for this field, or {@code null} if this field does not fit expected patterns and therefore cannot be turned into a getter name.
 */
public static String toGetterName(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean) {
	return toAccessorName(ast, accessors, fieldName, isBoolean, "is", "get", true);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:24,代码来源:HandlerUtil.java

示例15: toSetterName

import lombok.experimental.Accessors; //导入依赖的package包/类
/**
 * Generates a setter name from a given field name.
 * 
 * Strategy:
 * <ul>
 * <li>Reduce the field's name to its base name by stripping off any prefix (from {@code Accessors}). If the field name does not fit
 * the prefix list, this method immediately returns {@code null}.</li>
 * <li>If {@code Accessors} has {@code fluent=true}, then return the basename.</li>
 * <li>Only if {@code isBoolean} is true: Check if the field starts with {@code is} followed by a non-lowercase character.
 * If so, replace {@code is} with {@code set} and return that.</li> 
 * <li>Check if the first character of the field is lowercase. If so, check if the second character
 * exists and is title or upper case. If so, uppercase the first character. If not, titlecase the first character.</li>
 * <li>Return {@code "set"} plus the possibly title/uppercased first character, and the rest of the field name.</li>
 * </ul>
 * 
 * @param accessors Accessors configuration.
 * @param fieldName the name of the field.
 * @param isBoolean if the field is of type 'boolean'. For fields of type {@code java.lang.Boolean}, you should provide {@code false}.
 * @return The setter name for this field, or {@code null} if this field does not fit expected patterns and therefore cannot be turned into a getter name.
 */
public static String toSetterName(AST<?, ?, ?> ast, AnnotationValues<Accessors> accessors, CharSequence fieldName, boolean isBoolean) {
	return toAccessorName(ast, accessors, fieldName, isBoolean, "set", "set", true);
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:24,代码来源:HandlerUtil.java


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