Default Methods is one of the source-code metrics Understand computes across 17+ languages — browse them in the GUI, export and track them, or script them with the Python API.
Default Methods
API ID: CountDeclMethodDefaultLanguages: Java
Targets: Architectures, Classes, Files, Project
Number of local default methods.
A default method (also called package-private) has no explicit public, private, or protected modifier in Java, making it accessible only from other classes in the same package.
For example:
public class sample {
public void publicMethod() {
}
void defaultMethod() {
}
private void privateMethod() {
}
}
defaultMethod() has no access modifier, giving CountDeclMethodDefault = 1. publicMethod() and privateMethod() have explicit modifiers, so neither counts here.
See Public Methods, Protected Methods, and Private Methods for the access levels shared with C++, C#, and Java, and Internal Methods/Protected Internal Methods for C#'s additional access levels.
Targets By Language:- Java: Project, File, Class, Interface
- For projects and architectures, this metric must also be enabled from "Project Configuration/Metrics/Projects and Architectures" with the "Show aggregated class metrics" option. Enabling this option can be time consuming.
- This metric can be disabled from "Project Configuration/Metrics/Object Orientated" with the "Show method and variable count metrics" option.