Generates the text representation of this import statement as it would appear in source code. For example: "import java.util.List", "import static java.util.Collections. ", etc. @return the text representation of this import
()
| 109 | * @return the text representation of this import |
| 110 | */ |
| 111 | @Override |
| 112 | public String getText() { |
| 113 | String simpleName = getAlias(); |
| 114 | String memberName = getFieldName(); |
| 115 | |
| 116 | if (!isStatic()) { |
| 117 | if (isStar()) { |
| 118 | return "import " + getPackageName() + "*"; |
| 119 | } else if (simpleName == null || simpleName.isEmpty() |
| 120 | || simpleName.equals(getType().getNameWithoutPackage())) { |
| 121 | return "import " + getClassName(); |
| 122 | } else { |
| 123 | return "import " + getClassName() + " as " + simpleName; |
| 124 | } |
| 125 | } else { |
| 126 | if (isStar()) { |
| 127 | return "import static " + getClassName() + ".*"; |
| 128 | } else if (simpleName == null || simpleName.isEmpty() || simpleName.equals(memberName)) { |
| 129 | return "import static " + getClassName() + "." + memberName; |
| 130 | } else { |
| 131 | return "import static " + getClassName() + "." + memberName + " as " + simpleName; |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | public boolean isStar() { |
| 137 | return isStar; |
nothing calls this directly
no test coverage detected