Method Body

When you need to extract a specific method body, use the include-java plugin.Consider the file below: /** * Top level conceptual description of a {@link CustomDomain} problem. * <p> * To avoid <b>copy & paste</b> of the content consider to re-use information. */ class HelloWorld { /** * Each year we hire students from different universities to increase * <code>diversity</code> */ private int numberOfStudents; /** * Conceptual description of a <i>Domain</i> problem. * <p> * It will work only if you put high level description here and * <b>not</b> implementation details. * * @param p1 important parameter of something * @param p2 sample <i>offset</i> according to the rules of the universe * @return name of the <b>best</b> sample */ public String sampleMethod(String p1, int p2) { validate(); process(p2); // important comment notifyAll(p1); // very important return bestSample(); } public void sampleMethod(Map<String, Integer> p1, int p2, boolean isActive) { // overloaded method } /** * @param trader trader that performs action * @param transaction transaction to perform action on */ public void importantAction(Trader trader, Transaction transaction) { // TODO important } public Data createData() { // create data } } You can specify a method name to extract its full definition, or display only its body. :include-java: HelloWorld.java {entry: "sampleMethod", bodyOnly: true} If bodyOnly is specified, signature will be omitted. validate(); process(p2); // important comment notifyAll(p1); // very important return bestSample();

Callout Comments

Similar to how you snippets/external-code-snippets#callout-comments specify comments type for a regular file, you can specify commentsType option for include-java . :include-java: HelloWorld.java {entry: "sampleMethod", bodyOnly: true, commentsType: "inline"} validate(); process(p2); // important comment notifyAll(p1); // very important return bestSample();

Signature Only

You can also specify a method name and extract only its signature. :include-java: HelloWorld.java {entry: "sampleMethod", signatureOnly: true} If signatureOnly is specified, body will be omitted. public String sampleMethod(String p1, int p2)

Overloads

Specify types inside brackets to select an overloaded versions of your methods.Types should appear as they are in the file, i.e., if you use the short version of a type, you need to use the short version inside the plugin. :include-java: HelloWorld.java {entry: "sampleMethod(Map, int, boolean)"} Note: Generic types are erased and spaces after commas are optional public void sampleMethod(Map<String, Integer> p1, int p2, boolean isActive) { // overloaded method }

Type Body

To extract class , interface or enum body use: :include-java: MyEnum.java {entry: "MyEnum"} enum MyEnum { /** * description of <b>entry one</b> */ ENTRY_ONE, /** * description of entry two * <ul> * <li>item one</li> * <li>item two</li> * </ul> */ ENTRY_TWO, /** * Don't use, instead use ENTRY_TWO */ @Deprecated ENTRY_THREE } Use bodyOnly to only display body of your type. :include-java: MyEnum.java {entry: "MyEnum", bodyOnly: true} /** * description of <b>entry one</b> */ ENTRY_ONE, /** * description of entry two * <ul> * <li>item one</li> * <li>item two</li> * </ul> */ ENTRY_TWO, /** * Don't use, instead use ENTRY_TWO */ @Deprecated ENTRY_THREE

Multiple Entries

To display multiple methods at once use entries parameter to pass a list of method names. :include-java: HelloWorld.java {entries: ["createData", "importantAction"]} This will render: public Data createData() { // create data } public void importantAction(Trader trader, Transaction transaction) { // TODO important } List important methods signatures at one place by passing signatureOnly: true . :include-java: HelloWorld.java {entries: ["createData", "importantAction"], signatureOnly: true} This will render: public Data createData() public void importantAction(Trader trader, Transaction transaction)

Multiple Overloads

To list of the overloads of a method, specify method name using the entries parameter. :include-java: HelloWorld.java {entries: "sampleMethod", signatureOnly: true} public String sampleMethod(String p1, int p2) public void sampleMethod(Map<String, Integer> p1, int p2, boolean isActive)