Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasstamann committed Mar 15, 2024
2 parents 3cab40d + 750670b commit 7b626be
Show file tree
Hide file tree
Showing 33 changed files with 422 additions and 124 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Refactoring of an existing fluent api can therefore be a very complex thing to d

This project provides an annotation processor that generates fluent api implementations and therefore completely hiding all necessary boilerplate code.
To achieve this all that needs to be done is to define some fluent and backing bean interfaces and command classes and to configure its "plumbing" by placing a few annotations.
.


# Features
- fluent api is created by defining some interfaces and placing some annotations on them
Expand All @@ -22,7 +22,7 @@ To achieve this all that needs to be done is to define some fluent and backing b
- implementing, extending and maintaining of an immutable, fluent api becomes a no-brainer

# Restrictions
- fluent interfaces must not contain any cycles and must be strongly hierarchically
- backing bean interfaces must not contain any cycles and must be strongly hierarchical

# How does it work?

Expand All @@ -35,15 +35,15 @@ The api lib must be bound as a dependency - for example in maven:
<dependency>
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen-api</artifactId>
<version>0.8.0</version>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>

<!-- optional - add it if you want to use validators -->
<dependency>
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen-validation-api</artifactId>
<version>0.8.0</version>
<version>1.0.0</version>
<scope>compile</scope>
</dependency>

Expand All @@ -62,7 +62,7 @@ Additionally, you need to declare the annotation processor path in your compiler
<path>
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen-processor</artifactId>
<version>0.8.0</version>
<version>1.0.0</version>
</path>
</annotationProcessorPaths>

Expand Down Expand Up @@ -426,8 +426,6 @@ Validators are annotations annotated with _FluentApiValidator_ meta annotation.
Validation criteria can be added as annotation attributes. The _FluentApiValidator_ meta annotation defines the attribute to validator constructor mapping via the parameterNames attribute.
The validator implementation must provide a matching constructor.

*Remark : The feature is currently under development and not 100% done. There will still be improvements regarding processing time validation and error output*

### Javas default methods in fluent api and backing bean in interfaces
Default methods will be ignored during processing of fluent api and backing bean interfaces and can be used for different tasks:

Expand Down
2 changes: 1 addition & 1 deletion fluapigen-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>

<name>fluapigen-api</name>
Expand Down
2 changes: 1 addition & 1 deletion fluapigen-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>

<name>fluapigen-example</name>
Expand Down
2 changes: 1 addition & 1 deletion fluapigen-integrationTest/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<parent>
<groupId>io.toolisticon.fluapigen</groupId>
<artifactId>fluapigen</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</parent>

<name>fluapigen-integrationTest</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import io.toolisticon.fluapigen.api.FluentApiBackingBeanMapping;
import io.toolisticon.fluapigen.api.FluentApiCommand;
import io.toolisticon.fluapigen.api.FluentApiImplicitValue;
import io.toolisticon.fluapigen.api.FluentApiInlineBackingBeanMapping;
import io.toolisticon.fluapigen.api.FluentApiInterface;
import io.toolisticon.fluapigen.api.FluentApiParentBackingBeanMapping;
import io.toolisticon.fluapigen.api.FluentApiRoot;
Expand All @@ -30,7 +29,6 @@ interface MyRootLevelBackingBean {
List<MyMidLevelBackingBean> midLevelBB();



}

@FluentApiBackingBean
Expand Down Expand Up @@ -143,22 +141,35 @@ public interface MyMidLevelInterface {
@FluentApiParentBackingBeanMapping(value = "midLevelBB")
MyRootInterface gotoParent();

MyMidLevelInterface setStringArray(@FluentApiBackingBeanMapping(value = "stringArray") String ... strings);
MyMidLevelInterface setStringArray(@FluentApiBackingBeanMapping(value = "stringArray") String... strings);

@FluentApiImplicitValue(id = "stringArray", value = {"XYZ","123"})
@FluentApiImplicitValue(id = "stringArray", value = {"XYZ", "123"})
MyMidLevelInterface setStringArrayImplicitly();


MyMidLevelInterface setStringList(@FluentApiBackingBeanMapping(value = "stringList") String ... strings);
MyMidLevelInterface setStringList(@FluentApiBackingBeanMapping(value = "stringList") String... strings);

MyMidLevelInterface addStringListValue(@FluentApiBackingBeanMapping(value = "stringList", action = MappingAction.ADD) String singleString);

MyMidLevelInterface addStringListValues(@FluentApiBackingBeanMapping(value = "stringList", action = MappingAction.ADD) String ... singleString);
MyMidLevelInterface addStringListValues(@FluentApiBackingBeanMapping(value = "stringList", action = MappingAction.ADD) String... singleString);

MyMidLevelInterface addStringListValues(@FluentApiBackingBeanMapping(value = "stringList", action = MappingAction.ADD) Iterable<String> iterable);

@FluentApiImplicitValue(id = "stringList", value = {"XYZ","123"})
@FluentApiImplicitValue(id = "stringList", value = {"XYZ", "123"})
MyMidLevelInterface setStringListImplicitly();

MyMidLevelInterface setStringSet(@FluentApiBackingBeanMapping(value = "stringSet") String... strings);

MyMidLevelInterface addStringSetValue(@FluentApiBackingBeanMapping(value = "stringSet", action = MappingAction.ADD) String singleString);

MyMidLevelInterface addStringSetValues(@FluentApiBackingBeanMapping(value = "stringSet", action = MappingAction.ADD) String... singleString);

MyMidLevelInterface addStringSetValues(@FluentApiBackingBeanMapping(value = "stringSet", action = MappingAction.ADD) Iterable<String> iterable);


@FluentApiImplicitValue(id = "stringSet", value = {"XYZ", "123"})
MyMidLevelInterface setStringSetImplicitly();

}

@FluentApiInterface(MyLowLevelBackingBean.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,15 @@
import io.toolisticon.fluapigen.api.FluentApiCommand;
import io.toolisticon.fluapigen.api.FluentApiInterface;
import io.toolisticon.fluapigen.api.FluentApiRoot;
import io.toolisticon.fluapigen.api.MappingAction;
import io.toolisticon.fluapigen.validation.api.HasNoArgConstructor;
import io.toolisticon.fluapigen.validation.api.Matches;
import io.toolisticon.fluapigen.validation.api.MaxLength;
import io.toolisticon.fluapigen.validation.api.NotNull;
import io.toolisticon.fluapigen.validation.api.Nullable;

import java.util.List;

@FluentApi("ValidatorExampleStarter")
public class ValidatorExample {

Expand All @@ -22,6 +26,12 @@ interface MyBackingBean {
@FluentApiBackingBeanField("name")
String getName();

@FluentApiBackingBeanField("variousNames")
List<String> getVariousNames();

@FluentApiBackingBeanField("classes")
List<Class<?>> getClasses();

}

// Fluent Api interfaces
Expand All @@ -38,6 +48,17 @@ public interface MyRootInterface {
@Nullable
MyRootInterface setNameWithNullableOnMethod(@NotNull @MaxLength(8) @Matches("aaa.*") @FluentApiBackingBeanMapping("name") String name);

@Nullable
MyRootInterface setVariousNamesWithNullableOnMethod(@NotNull @MaxLength(8) @Matches("aaa.*") @FluentApiBackingBeanMapping("variousNames") String... names);

@Nullable
MyRootInterface setVariousNamesWithNullableOnMethod(@NotNull @MaxLength(8) @Matches("aaa.*") @FluentApiBackingBeanMapping("variousNames") List<String> names);

MyRootInterface addClass(@NotNull @HasNoArgConstructor @FluentApiBackingBeanMapping(value = "classes", action = MappingAction.ADD) Class<?> clazz);

MyRootInterface addClasses(@NotNull @HasNoArgConstructor @FluentApiBackingBeanMapping(value = "classes", action = MappingAction.ADD) Class<?>... clazz);

MyRootInterface addClasses(@NotNull @HasNoArgConstructor @FluentApiBackingBeanMapping(value = "classes", action = MappingAction.ADD) Iterable<Class<?>> clazz);

@FluentApiCommand(MyCommand.class)
void myCommand();
Expand All @@ -49,6 +70,7 @@ public interface MyRootInterface {
static class MyCommand {
static void myCommand(MyBackingBean backingBean) {
System.out.println(backingBean.getName());
System.out.println(backingBean.getVariousNames());
}
}

Expand Down
Loading

0 comments on commit 7b626be

Please sign in to comment.