lombok.experimental.Tolerate Java Examples

The following examples show how to use lombok.experimental.Tolerate. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 6 votes vote down vote up
/**
 * Checks if there is a (non-default) constructor. In case of multiple constructors (overloading), only
 * the first constructor decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned.
 * 
 * @param node Any node that represents the Type (JCClassDecl) to look in, or any child node thereof.
 */
public static MemberExistsResult constructorExists(JavacNode node) {
	node = upToTypeNode(node);
	
	if (node != null && node.get() instanceof JCClassDecl) {
		top: for (JCTree def : ((JCClassDecl)node.get()).defs) {
			if (def instanceof JCMethodDecl) {
				JCMethodDecl md = (JCMethodDecl) def;
				if (md.name.contentEquals("<init>")) {
					if ((md.mods.flags & Flags.GENERATEDCONSTR) != 0) continue;
					List<JCAnnotation> annotations = md.getModifiers().getAnnotations();
					if (annotations != null) for (JCAnnotation anno : annotations) {
						if (typeMatches(Tolerate.class, node, anno.getAnnotationType())) continue top;
					}
					return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
				}
			}
		}
	}
	
	return MemberExistsResult.NOT_EXISTS;
}
 
Example #2
Source File: EclipseHandlerUtil.java    From EasyMPermission with MIT License 6 votes vote down vote up
/**
 * Checks if there is a (non-default) constructor. In case of multiple constructors (overloading), only
 * the first constructor decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned.
 * 
 * @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.
 */
public static MemberExistsResult constructorExists(EclipseNode node) {
	while (node != null && !(node.get() instanceof TypeDeclaration)) {
		node = node.up();
	}
	
	if (node != null && node.get() instanceof TypeDeclaration) {
		TypeDeclaration typeDecl = (TypeDeclaration)node.get();
		if (typeDecl.methods != null) top: for (AbstractMethodDeclaration def : typeDecl.methods) {
			if (def instanceof ConstructorDeclaration) {
				if ((def.bits & ASTNode.IsDefaultConstructor) != 0) continue;
				
				if (def.annotations != null) for (Annotation anno : def.annotations) {
					if (typeMatches(Tolerate.class, node, anno.type)) continue top;
				}
				
				return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
			}
		}
	}
	
	return MemberExistsResult.NOT_EXISTS;
}
 
Example #3
Source File: BuilderPreDefinedInnerClassMethodProcessor.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
protected Collection<? extends PsiElement> generatePsiElements(@NotNull PsiClass psiParentClass, @Nullable PsiMethod psiParentMethod, @NotNull PsiAnnotation psiAnnotation, @NotNull PsiClass psiBuilderClass) {
  final Collection<PsiMethod> result = new ArrayList<>();

  final Collection<String> existedMethodNames = PsiClassUtil.collectClassMethodsIntern(psiBuilderClass).stream()
    .filter(psiMethod -> PsiAnnotationSearchUtil.isNotAnnotatedWith(psiMethod, Tolerate.class))
    .map(PsiMethod::getName).collect(Collectors.toSet());

  BuilderHandler builderHandler = getBuilderHandler();
  final List<BuilderInfo> builderInfos = builderHandler.createBuilderInfos(psiAnnotation, psiParentClass, psiParentMethod, psiBuilderClass);

  //create constructor
  result.addAll(builderHandler.createConstructors(psiBuilderClass, psiAnnotation));

  // create builder methods
  builderInfos.stream()
    .filter(info -> info.notAlreadyExistingMethod(existedMethodNames))
    .map(BuilderInfo::renderBuilderMethods)
    .forEach(result::addAll);

  // create 'build' method
  final String buildMethodName = builderHandler.getBuildMethodName(psiAnnotation);
  if (!existedMethodNames.contains(buildMethodName)) {
    result.add(builderHandler.createBuildMethod(psiAnnotation, psiParentClass, psiParentMethod, psiBuilderClass, buildMethodName, builderInfos));
  }

  // create 'toString' method
  if (!existedMethodNames.contains(ToStringProcessor.METHOD_NAME)) {
    result.add(builderHandler.createToStringMethod(psiAnnotation, psiBuilderClass));
  }

  return result;
}
 
Example #4
Source File: Location.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public Location() {
}
 
Example #5
Source File: MailHost.java    From gocd with Apache License 2.0 4 votes vote down vote up
@Tolerate
@Deprecated // use `isTls()` instead, left here for rails
public boolean getTls() {
    return isTls();
}
 
Example #6
Source File: MailHost.java    From gocd with Apache License 2.0 4 votes vote down vote up
@Tolerate
@Deprecated // use `getUsername()` instead
public String getUserName() {
    return getUsername();
}
 
Example #7
Source File: AbstractProcessor.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
protected void filterToleratedElements(@NotNull Collection<? extends PsiModifierListOwner> definedMethods) {
  definedMethods.removeIf(definedMethod -> PsiAnnotationSearchUtil.isAnnotatedWith(definedMethod, Tolerate.class));
}
 
Example #8
Source File: TolerateWithValue.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Tolerate
public TolerateWithValue(int age) {
  this(age, "unknown");
}
 
Example #9
Source File: TolerateWithData.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Tolerate
public TolerateWithData(int age) {
  this(age, "unknown");
}
 
Example #10
Source File: BuilderWithTolerate.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Tolerate
public BuilderWithTolerateBuilder value(String s) {
	return this.value(Integer.parseInt(s));
}
 
Example #11
Source File: BuilderWithTolerate.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Tolerate
public BuilderWithTolerateBuilder value(String s) {
	return this.value(Integer.parseInt(s));
}
 
Example #12
Source File: Office.java    From spring-data-jpa-datatables with Apache License 2.0 4 votes vote down vote up
@Tolerate
private Office() {}
 
Example #13
Source File: Employee.java    From spring-data-jpa-datatables with Apache License 2.0 4 votes vote down vote up
@Tolerate
private Employee() {}
 
Example #14
Source File: JavacHandlerUtil.java    From EasyMPermission with MIT License 4 votes vote down vote up
/**
 * Checks if there is a method with the provided name. In case of multiple methods (overloading), only
 * the first method decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned.
 * 
 * @param methodName the method name to check for.
 * @param node Any node that represents the Type (JCClassDecl) to look in, or any child node thereof.
 * @param caseSensitive If the search should be case sensitive.
 * @param params The number of parameters the method should have; varargs count as 0-*. Set to -1 to find any method with the appropriate name regardless of parameter count.
 */
public static MemberExistsResult methodExists(String methodName, JavacNode node, boolean caseSensitive, int params) {
	node = upToTypeNode(node);
	
	if (node != null && node.get() instanceof JCClassDecl) {
		top: for (JCTree def : ((JCClassDecl)node.get()).defs) {
			if (def instanceof JCMethodDecl) {
				JCMethodDecl md = (JCMethodDecl) def;
				String name = md.name.toString();
				boolean matches = caseSensitive ? name.equals(methodName) : name.equalsIgnoreCase(methodName);
				if (matches) {
					if (params > -1) {
						List<JCVariableDecl> ps = md.params;
						int minArgs = 0;
						int maxArgs = 0;
						if (ps != null && ps.length() > 0) {
							minArgs = ps.length();
							if ((ps.last().mods.flags & Flags.VARARGS) != 0) {
								maxArgs = Integer.MAX_VALUE;
								minArgs--;
							} else {
								maxArgs = minArgs;
							}
						}
						
						if (params < minArgs || params > maxArgs) continue;
					}
					
					List<JCAnnotation> annotations = md.getModifiers().getAnnotations();
					if (annotations != null) for (JCAnnotation anno : annotations) {
						if (typeMatches(Tolerate.class, node, anno.getAnnotationType())) continue top;
					}
					
					return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
				}
			}
		}
	}
	
	return MemberExistsResult.NOT_EXISTS;
}
 
Example #15
Source File: EclipseHandlerUtil.java    From EasyMPermission with MIT License 4 votes vote down vote up
/**
 * Checks if there is a method with the provided name. In case of multiple methods (overloading), only
 * the first method decides if EXISTS_BY_USER or EXISTS_BY_LOMBOK is returned.
 * 
 * @param methodName the method name to check for.
 * @param node Any node that represents the Type (TypeDeclaration) to look in, or any child node thereof.
 * @param caseSensitive If the search should be case sensitive.
 * @param params The number of parameters the method should have; varargs count as 0-*. Set to -1 to find any method with the appropriate name regardless of parameter count.
 */
public static MemberExistsResult methodExists(String methodName, EclipseNode node, boolean caseSensitive, int params) {
	while (node != null && !(node.get() instanceof TypeDeclaration)) {
		node = node.up();
	}
	
	if (node != null && node.get() instanceof TypeDeclaration) {
		TypeDeclaration typeDecl = (TypeDeclaration)node.get();
		if (typeDecl.methods != null) top: for (AbstractMethodDeclaration def : typeDecl.methods) {
			if (def instanceof MethodDeclaration) {
				char[] mName = def.selector;
				if (mName == null) continue;
				boolean nameEquals = caseSensitive ? methodName.equals(new String(mName)) : methodName.equalsIgnoreCase(new String(mName));
				if (nameEquals) {
					if (params > -1) {
						int minArgs = 0;
						int maxArgs = 0;
						if (def.arguments != null && def.arguments.length > 0) {
							minArgs = def.arguments.length;
							if ((def.arguments[def.arguments.length - 1].type.bits & ASTNode.IsVarArgs) != 0) {
								minArgs--;
								maxArgs = Integer.MAX_VALUE;
							} else {
								maxArgs = minArgs;
							}
						}
						
						if (params < minArgs || params > maxArgs) continue;
					}
					
					if (def.annotations != null) for (Annotation anno : def.annotations) {
						if (typeMatches(Tolerate.class, node, anno.type)) continue top;
					}
					
					return getGeneratedBy(def) == null ? MemberExistsResult.EXISTS_BY_USER : MemberExistsResult.EXISTS_BY_LOMBOK;
				}
			}
		}
	}
	
	return MemberExistsResult.NOT_EXISTS;
}
 
Example #16
Source File: Token.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public Token() {
}
 
Example #17
Source File: ResultData.java    From Moss with Apache License 2.0 4 votes vote down vote up
@Tolerate
public ResultData(){}
 
Example #18
Source File: User.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public User() {
}
 
Example #19
Source File: Device.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public Device() {
}
 
Example #20
Source File: OauthClientDetails.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public OauthClientDetails() {
}
 
Example #21
Source File: AccessToken.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public OAuth2Authentication authentication() {
    return SerializationUtils.deserialize(authentication);
}
 
Example #22
Source File: AccessToken.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public OAuth2AccessToken token() {
    return SerializationUtils.deserialize(token);
}
 
Example #23
Source File: AuthorizationCode.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public AuthorizationCode() {
}
 
Example #24
Source File: UserForm.java    From konker-platform with Apache License 2.0 4 votes vote down vote up
@Tolerate
public UserForm() {}
 
Example #25
Source File: BungeeChatContext.java    From BungeeChat2 with GNU General Public License v3.0 4 votes vote down vote up
@Tolerate
public void setServer(String server) {
  setServer(Optional.ofNullable(server));
}
 
Example #26
Source File: BungeeChatContext.java    From BungeeChat2 with GNU General Public License v3.0 4 votes vote down vote up
@Tolerate
public void setChannel(String channel) {
  setChannel(Optional.ofNullable(channel));
}
 
Example #27
Source File: BungeeChatContext.java    From BungeeChat2 with GNU General Public License v3.0 4 votes vote down vote up
@Tolerate
public void setMessage(String message) {
  setMessage(Optional.ofNullable(message));
}
 
Example #28
Source File: BungeeChatContext.java    From BungeeChat2 with GNU General Public License v3.0 4 votes vote down vote up
@Tolerate
public void setTarget(BungeeChatAccount target) {
  setTarget(Optional.ofNullable(target));
}
 
Example #29
Source File: BungeeChatContext.java    From BungeeChat2 with GNU General Public License v3.0 4 votes vote down vote up
@Tolerate
public void setSender(BungeeChatAccount sender) {
  setSender(Optional.ofNullable(sender));
}
 
Example #30
Source File: SubMenuVO.java    From Moss with Apache License 2.0 4 votes vote down vote up
@Tolerate
public SubMenuVO(){}