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

com.atlassian.clover.context.PropertyMethodRegexpContext Maven / Gradle / Ivy

Go to download

Clover is an award winning code coverage and testing tool for Java and Groovy. It integrates easily with Maven, Ant, Grails, Eclipse and IntelliJ IDEA as well as with continuous integration servers such as Bamboo, Jenkins or Hudson. Note: before Clover 4.0 this artifact was named com.cenqua.clover:clover.

The newest version!
package com.atlassian.clover.context;

import com.atlassian.clover.api.registry.MethodInfo;
import com.atlassian.clover.api.registry.ParameterInfo;
import com.atlassian.clover.instr.java.FileStructureInfo;

import java.util.regex.Pattern;

/**
 * A regular expression based context searching for getXyz(), setXyz(), isXyz() methods.
 */
public class PropertyMethodRegexpContext extends MethodRegexpContext {
    public PropertyMethodRegexpContext(int index, String name) {
        super(index, name, Pattern.compile("(.* )?public .*(get|set|is)[A-Z0-9].*"), 1, Integer.MAX_VALUE, Integer.MAX_VALUE, Integer.MAX_VALUE);
    }

    @Override
    public boolean matches(FileStructureInfo.MethodMarker methodMarker) {
        if (!super.matches(methodMarker)) {
            return false;
        }
        final MethodInfo info = methodMarker.getMethod();
        final String name = info.getSignature().getName();
        final ParameterInfo[] params = info.getSignature().getParameters();
        if (name.startsWith("get") || name.startsWith("is")) {
            return !info.getSignature().hasParams();
        }
        return params != null && params.length == 1;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy