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

com.malinskiy.sheldon.codegen.validator.DeleteValidator Maven / Gradle / Ivy

There is a newer version: 1.0.1
Show newest version
package com.malinskiy.sheldon.codegen.validator;

import com.google.auto.common.MoreTypes;

import com.malinskiy.sheldon.codegen.ProcessingException;

import javax.annotation.Nonnull;
import javax.lang.model.element.ExecutableElement;
import javax.lang.model.type.TypeKind;

public class DeleteValidator {
    public static void checkValidDelete(@Nonnull ExecutableElement method) throws ProcessingException {
        if (!method.getReturnType().getKind().equals(TypeKind.VOID)) {
            throw new ProcessingException(
                    method,
                    "Should return void"
            );
        }

        if (method.getParameters().size() != 1 ||
            !MoreTypes.isTypeOf(String.class, method.getParameters().get(0).asType())) {
            throw new ProcessingException(
                    method,
                    "Should have only one String parameter"
            );
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy