blob: 083fc01b1ac226f0bab57b8f6b813ab5c9ca2fce (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
package com.github.javaparser.ast.nodeTypes;
import java.util.List;
import com.github.javaparser.ast.Node;
import com.github.javaparser.ast.type.ClassOrInterfaceType;
public interface NodeWithExtends<T> {
public List<ClassOrInterfaceType> getExtends();
public T setExtends(final List<ClassOrInterfaceType> extendsList);
/**
* Add an extends to this and automatically add the import
*
* @param clazz the class to extand from
* @return this
*/
public default T addExtends(Class<?> clazz) {
((Node) this).tryAddImportToParentCompilationUnit(clazz);
return addExtends(clazz.getSimpleName());
}
/**
* Add an extends to this
*
* @param name the name of the type to extends from
* @return this
*/
@SuppressWarnings("unchecked")
public default T addExtends(String name) {
ClassOrInterfaceType classOrInterfaceType = new ClassOrInterfaceType(name);
getExtends().add(classOrInterfaceType);
classOrInterfaceType.setParentNode((Node) this);
return (T) this;
}
}
|