All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.develhack.lombok.eclipse.handlers.assertion.AbstractNumericalAssertionHandler Maven / Gradle / Ivy

package com.develhack.lombok.eclipse.handlers.assertion;

import static lombok.eclipse.Eclipse.toQualifiedName;

import java.lang.annotation.Annotation;

import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;

import com.develhack.lombok.NameResolver;

abstract class AbstractNumericalAssertionHandler extends AbstractAssertionHandler {

	public AbstractNumericalAssertionHandler(Class annotationType) {
		super(annotationType);
	}

	@Override
	protected boolean checkVariableType(AbstractVariableDeclaration variable) {

		if (isPrimitiveNumber(variable) || isBoxedNumber(variable)) return true;

		String argumentTypeName = toQualifiedName(variable.type.getTypeName());

		if (NameResolver.resolveFQN(sourceNode, argumentTypeName, NameResolver.BIG_INTEGER, NameResolver.BIG_DECIMAL) != null) {
			return true;
		}

		sourceNode.addWarning(String.format("@%s is only applicable to the numerical type.", getAnnotationName()));
		return false;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy