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

com.develhack.lombok.javac.handlers.assertion.NonnullHandler Maven / Gradle / Ivy

Go to download

The library enhancing Java classes at compilation by annotations that contained in the Develhack Core Library.

The newest version!
package com.develhack.lombok.javac.handlers.assertion;

import lombok.javac.JavacAnnotationHandler;

import org.mangosdk.spi.ProviderFor;

import com.develhack.annotation.assertion.Nonnull;
import com.develhack.annotation.assertion.Nullable;
import com.sun.tools.javac.tree.JCTree.JCVariableDecl;

@ProviderFor(JavacAnnotationHandler.class)
public class NonnullHandler extends AbstractAssertionHandler {

	public NonnullHandler() {
		super(Nonnull.class);
	}

	@Override
	protected String getCheckMethodName() {
		return "checkNonnull";
	}

	@Override
	protected boolean checkVariableType(JCVariableDecl variable) {

		if (!checkReferenceType(variable)) return false;

		if(findAnnotation(Nullable.class, variable.mods.annotations) != null) {
			sourceNode.addWarning("conflicted with the @Nonnull.");
			return false;
		}

		return true;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy