Skip to content

Commit

Permalink
Merge pull request #15 from bowbahdoe/only-use-abstract-classes
Browse files Browse the repository at this point in the history
Only ever use abstract classes
  • Loading branch information
bowbahdoe committed Jan 27, 2022
2 parents eab4912 + fc1b295 commit d0d5ece
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 21 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ Requires Java 17+.
<dependency>
<groupId>dev.mccue</groupId>
<artifactId>magic-bean</artifactId>
<version>2.0.2</version>
<version>3.0.0</version>
<scope>provided</scope>
</dependency>
```

### deps.edn
```edn
{:mvn/repos {"jitpack" {:url "https://jitpack.io"}}
:aliases {:compile {:deps {dev.mccue/magic-bean {:mvn/version "2.0.2"}}}}}
:aliases {:compile {:deps {dev.mccue/magic-bean {:mvn/version "3.0.0"}}}}}
```

## What this does
Expand Down Expand Up @@ -65,7 +65,7 @@ import dev.mccue.magicbean.MagicBean;
import java.util.List;

@MagicBean
public final class Example implements ExampleBeanOps {
public final class Example extends ExampleBeanOps {
int x;
String name;
List<String> strs;
Expand All @@ -74,48 +74,50 @@ public final class Example implements ExampleBeanOps {

#### You receive
```java
sealed interface ExampleBeanOps permits Example {
sealed abstract class ExampleBeanOps permits Example {

/**
* Get the current value for x.
*/
default int getX() {
public int getX() {
return ((Example) this).x;
}

/**
* Set the current value for x.
*/
default void setX(int x) {
public void setX(int x) {
((Example) this).x = x;
}

/**
* Get the current value for name.
*/
default java.lang.String getName() {
public java.lang.String getName() {
return ((Example) this).name;
}

/**
* Set the current value for name.
*/
default void setName(java.lang.String name) {
public void setName(java.lang.String name) {
((Example) this).name = name;
}

/**
* Get the current value for strs.
*/
default java.util.List<java.lang.String> getStrs() {
public java.util.List<java.lang.String> getStrs() {
return ((Example) this).strs;
}

/**
* Set the current value for strs.
*/
default void setStrs(java.util.List<java.lang.String> strs) {
public void setStrs(java.util.List<java.lang.String> strs) {
((Example) this).strs = strs;
}

}
```

Expand All @@ -127,8 +129,6 @@ import dev.mccue.magicbean.MagicBean;

import java.util.List;

// If you want equals/hashCode, toString, or a static factory
// then an abstract class will be generated, not an interface.
@MagicBean(
generateAllArgsStaticFactory = true,
generateEqualsAndHashCode = true,
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.mccue</groupId>
<artifactId>magic-bean</artifactId>
<version>2.0.2</version>
<version>3.0.0</version>
<packaging>jar</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,7 @@ public boolean process(
var packageDecl = packageName == null ? "" : "package " + packageName + ";\n\n";


String classDeclStart;
if (useAbstractClass) {
classDeclStart = "sealed abstract class %s permits %s {\n\n";
} else {
classDeclStart = "sealed interface %s permits %s {\n\n";
}

classDeclStart = classDeclStart.formatted(
String classDeclStart = "sealed abstract class %s permits %s {\n\n".formatted(
className + "BeanOps", className
);

Expand Down

0 comments on commit d0d5ece

Please sign in to comment.