Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,7 @@ private String findInCompileSourceRoots(String name) {
}

private String findInCompileSourceRoots(List<String> list, String name) {
for (Object obj : list) {
String dir = (String) obj;
for (String dir : list) {
dir = asRelativeFile(dir);
if (name.startsWith(dir)) {
return name.substring(dir.length() + 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,40 +116,6 @@ public static String wrapWords(String line, String wordSep, String lineSep, int
offset = next + 1;
}
}
/*
while (inputLineLength - offset > watermark) {
if (line.charAt(offset) == ' ') {
++offset;
} else {
int spaceToWrapAt = line.lastIndexOf(' ', watermark + offset);
int spaces = 0;
for (int i = offset; i < spaceToWrapAt; i++) {
spaces += line.charAt(i) == ' ' ? 1 : 0;
}
if (spaceToWrapAt >= offset) {
sb.append(line, offset, spaceToWrapAt);
sb.append(newLine);
offset = spaceToWrapAt + 1;
} else if (wrapLongWords) {
sb.append(line, offset, watermark + offset);
sb.append(newLine);
offset += watermark;
} else {
spaceToWrapAt = line.indexOf(' ', watermark + offset);
if (spaceToWrapAt >= 0) {
sb.append(line, offset, spaceToWrapAt);
sb.append(newLine);
offset = spaceToWrapAt + 1;
} else {
sb.append(line, offset, line.length());
offset = inputLineLength;
}
}
}
}

sb.append(line, offset, line.length());
*/
return sb.toString();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,7 @@ private static boolean doUpdateFile(Path path, byte[] newdata) throws IOExceptio
Files.delete(path);
return true;
} else {
byte[] olddata = new byte[0];
if (Files.exists(path) && Files.isReadable(path)) {
olddata = Files.readAllBytes(path);
}
final byte[] olddata = readFile(path);
if (Arrays.equals(olddata, newdata)) {
return false;
}
Expand All @@ -97,6 +94,14 @@ private static boolean doUpdateFile(Path path, byte[] newdata) throws IOExceptio
}
}

private static byte[] readFile(Path path) throws IOException {
if (Files.isReadable(path)) {
return Files.readAllBytes(path);
}

return new byte[0];
}

/**
* Read the content of the input file and update the target accordingly
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ public class DependencySet {

private Set<String> excludes = new HashSet<>();

public DependencySet() {
}

public Set<String> getIncludes() {
return includes;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@ public class ExternalBomConflictCheck {

private String version;

public ExternalBomConflictCheck() {
}

public String getGroupId() {
return groupId;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ public class ExternalBomConflictCheckSet {

private Set<ExternalBomConflictCheck> boms = new HashSet<>();

public ExternalBomConflictCheckSet() {
}

public Set<ExternalBomConflictCheck> getBoms() {
return boms;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private VelocityContext getApiMethodContext(List<ApiMethodParser.ApiMethodModel>
return context;
}

public File getApiMethodFile() throws MojoExecutionException {
public File getApiMethodFile() {
final StringBuilder fileName = new StringBuilder();
fileName.append(outPackage.replace(".", Matcher.quoteReplacement(File.separator))).append(File.separator);
fileName.append(getEnumName()).append(".java");
Expand All @@ -190,7 +190,7 @@ private VelocityContext getApiTestContext(List<ApiMethodParser.ApiMethodModel> m
return context;
}

private String getTestFilePath() throws MojoExecutionException {
private String getTestFilePath() {
final StringBuilder fileName = new StringBuilder();
fileName.append(componentPackage.replace(".", Matcher.quoteReplacement(File.separator))).append(File.separator);
fileName.append(getUnitTestName()).append(".java");
Expand Down Expand Up @@ -259,7 +259,7 @@ private VelocityContext getEndpointContext(List<ApiMethodParser.ApiMethodModel>
return context;
}

private File getConfigurationFile() throws MojoExecutionException {
private File getConfigurationFile() {
final StringBuilder fileName = new StringBuilder();
// endpoint configuration goes in component package
fileName.append(componentPackage.replace(".", Matcher.quoteReplacement(File.separator))).append(File.separator);
Expand Down Expand Up @@ -312,18 +312,28 @@ public static String getType(Class<?> clazz) {
}
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public String getAliases() {
StringBuilder sb = new StringBuilder();
sb.append("{");
if (!aliases.isEmpty()) {
StringJoiner sj = new StringJoiner(", ");
aliases.forEach(a -> sj.add("\"" + a.getMethodPattern() + "=" + a.getMethodAlias() + "\""));
sb.append(sj.toString());
sb.append(sj);
}
sb.append("}");
return sb.toString();
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getApiMethodsForParam(List<ApiMethodParser.ApiMethodModel> models, ApiMethodArg argument) {
StringBuilder sb = new StringBuilder();

Expand Down Expand Up @@ -368,6 +378,11 @@ public static String getApiMethodsForParam(List<ApiMethodParser.ApiMethodModel>
return "{" + answer + "}";
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getTestName(ApiMethodParser.ApiMethodModel model) {
final StringBuilder builder = new StringBuilder();
final String name = model.getMethod().getName();
Expand All @@ -381,15 +396,30 @@ public static String getTestName(ApiMethodParser.ApiMethodModel model) {
return builder.toString();
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static boolean isVoidType(Class<?> resultType) {
return resultType == Void.TYPE;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public String getExchangePropertyPrefix() {
// exchange property prefix
return "Camel" + componentName + ".";
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getResultDeclaration(Class<?> resultType) {
if (resultType.isPrimitive()) {
return ClassUtils.primitiveToWrapper(resultType).getSimpleName();
Expand All @@ -410,31 +440,56 @@ public static String getResultDeclaration(Class<?> resultType) {
PRIMITIVE_VALUES.put(Double.TYPE, "0.0d");
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public boolean hasDoc(ApiMethodArg argument) {
return argument.getDescription() != null && !argument.getDescription().isEmpty();
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public String getDoc(ApiMethodArg argument) {
if (argument.getDescription() == null || argument.getDescription().isEmpty()) {
return "";
}
return argument.getDescription();
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public String getApiName(String apiName) {
if (apiName == null || apiName.isEmpty()) {
return "DEFAULT";
}
return apiName;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public String getApiDescription(String apiDescription) {
if (apiDescription == null) {
return "";
}
return apiDescription;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public boolean isOptionalParameter(ApiMethodArg argument) {
String name = argument.getName();
if (nullableOptions != null) {
Expand All @@ -447,6 +502,28 @@ public boolean isOptionalParameter(ApiMethodArg argument) {
return false;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public String getCanonicalName(ApiMethodArg argument) {
// replace primitives with wrapper classes (as that makes them option and avoid boolean because false by default)
final Class<?> type = argument.getType();
if (type.isPrimitive()) {
return getCanonicalName(ClassUtils.primitiveToWrapper(type));
}
String fqn = argument.getRawTypeArgs();
// the type may use $ for classloader, so replace it back with dot
fqn = fqn.replace('$', '.');
return fqn;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public String getApiMethods(List<ApiMethodParser.ApiMethodModel> models) {
models.sort((o1, o2) -> o1.getName().compareToIgnoreCase(o2.getName()));

Expand All @@ -469,7 +546,7 @@ public String getApiMethods(List<ApiMethodParser.ApiMethodModel> models) {
sb.append(", signatures={");
StringJoiner sj = new StringJoiner(", ");
signatures.forEach(s -> sj.add("\"" + s + "\""));
sb.append(sj.toString());
sb.append(sj);
sb.append("}");
}
sb.append(")");
Expand All @@ -494,6 +571,11 @@ private List<String> getSignatures(List<ApiMethodParser.ApiMethodModel> models,
return list;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getDefaultArgValue(Class<?> aClass) {
if (aClass.isPrimitive()) {
// lookup default primitive value string
Expand All @@ -504,24 +586,16 @@ public static String getDefaultArgValue(Class<?> aClass) {
}
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getBeanPropertySuffix(String parameter) {
// capitalize first character
StringBuilder builder = new StringBuilder();
builder.append(Character.toUpperCase(parameter.charAt(0)));
builder.append(parameter, 1, parameter.length());
return builder.toString();
}

public String getCanonicalName(ApiMethodArg argument) throws MojoExecutionException {
// replace primitives with wrapper classes (as that makes them option and avoid boolean because false by default)
final Class<?> type = argument.getType();
if (type.isPrimitive()) {
return getCanonicalName(ClassUtils.primitiveToWrapper(type));
}

String fqn = argument.getRawTypeArgs();
// the type may use $ for classloader, so replace it back with dot
fqn = fqn.replace('$', '.');
return fqn;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,22 @@ private StringBuilder getFileBuilder() {
return fileName;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getApiMethod(String proxyClass, String classPrefix) {
String proxyClassWithCanonicalName = getProxyClassWithCanonicalName(proxyClass);
String prefix = classPrefix != null ? classPrefix : "";
return prefix + proxyClassWithCanonicalName.substring(proxyClassWithCanonicalName.lastIndexOf('.') + 1) + "ApiMethod";
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getEndpointConfig(String proxyClass, String classPrefix) {
String proxyClassWithCanonicalName = getProxyClassWithCanonicalName(proxyClass);
String prefix = classPrefix != null ? classPrefix : "";
Expand All @@ -336,6 +346,11 @@ private static String getProxyClassWithCanonicalName(String proxyClass) {
return proxyClass.replace("$", "");
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getEnumConstant(String enumValue) {
if (enumValue == null || enumValue.isEmpty()) {
return "DEFAULT";
Expand All @@ -347,6 +362,11 @@ public static String getEnumConstant(String enumValue) {
return value;
}

/*
* This is used when configuring the plugin instead of directly, which is why it reports as unused
* without the annotation
*/
@SuppressWarnings("unused")
public static String getNullableOptionValues(String[] nullableOptions) {
if (nullableOptions == null || nullableOptions.length == 0) {
return "";
Expand Down
Loading