Skip to content

Commit

Permalink
Add default support
Browse files Browse the repository at this point in the history
  • Loading branch information
dmssargent committed Jul 23, 2024
1 parent 48f58a4 commit 944f3fd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ private Expression buildMethod(boolean isEnumField) {
);

return Expressions.of(methodDeclaration, StringExpression.SPACE, methodBody);
} else if ((isAbstract() && !isEnumField) || (getParentClazz().isInterface() && !isStatic())) {
} else if ((isAbstract() && !isEnumField) || (isAbstract() && getParentClazz().isInterface() && !isStatic())) {
return methodDeclaration.asStatement();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ public static MethodDeclarationExpression from(JarMethod method, boolean isEnumF
signature.add(StringExpression.ABSTRACT);
}

if (!method.isAbstract() && method.getParentClazz().isInterface()) {
signature.add(StringExpression.DEFAULT);
}

// Convert method type parameters
signature.add(JarType.convertTypeParametersToExpression(method.typeParameters(), method.getParentClazz()));
// Convert method return type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public final class StringExpression extends Expression implements FormattedExpre
public static final Expression FINAL = new StringExpression(Constants.FINAL);
public static final Expression STATIC = new StringExpression(Constants.STATIC);
public static final Expression ABSTRACT = new StringExpression(Constants.ABSTRACT);
public static final Expression DEFAULT = new StringExpression(Constants.DEFAULT);
public static final Expression VOLATILE = new StringExpression(Constants.VOLATILE);
public static final Expression TRANSIENT = new StringExpression(Constants.TRANSIENT);
public static final Expression PACKAGE = new StringExpression(Constants.PACKAGE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public class Constants {
public static final String FINAL = "final";
public static final String STATIC = "static";
public static final String ABSTRACT = "abstract";
public static final String DEFAULT = "default";
public static final String TRANSIENT = "transient";
public static final String VOLATILE = "volatile";
public static final String PACKAGE = "package";
Expand Down

0 comments on commit 944f3fd

Please sign in to comment.