├── .travis.yml
├── CONTRIBUTORS.md
├── Documentation.java
├── LICENSE.txt
├── README.md
├── VERSION.md
├── flapi-build-plugin
├── pom.xml
└── src
│ └── main
│ └── java
│ └── unquietcode
│ └── tools
│ └── flapi
│ └── plugin
│ └── FlapiBuildPlugin.java
├── flapi-build-project
└── pom.xml
├── flapi-build-test-consumer
├── build.gradle
├── pom.xml
├── settings.gradle
└── src
│ └── test
│ └── java
│ └── unquietcode
│ └── tools
│ └── flapi
│ └── plugin
│ └── DescriptorTest.java
├── flapi-build-test-producer
├── build.gradle
├── pom.xml
├── settings.gradle
└── src
│ ├── main
│ └── java
│ │ └── unquietcode
│ │ └── tools
│ │ └── flapi
│ │ └── plugin
│ │ ├── EmailMessage.java
│ │ ├── TestAnnotation.java
│ │ ├── TestDescriptor.java
│ │ └── TestEnum.java
│ └── test
│ └── java
│ └── unquietcode
│ └── tools
│ └── flapi
│ └── plugin
│ └── TestDescriptorTest.java
├── flapi-descriptor
├── pom.xml
└── src
│ └── test
│ └── java
│ └── unquietcode
│ └── tools
│ └── flapi
│ └── builder
│ ├── DescriptorConfigurator.java
│ └── MainDescriptor.java
├── flapi-gradle-plugin
├── build.gradle
└── src
│ └── main
│ ├── groovy
│ └── unquietcode
│ │ └── tools
│ │ └── flapi
│ │ └── plugin
│ │ ├── FlapiPluginExtension.groovy
│ │ └── GradlePlugin.groovy
│ └── resources
│ └── META-INF
│ └── gradle-plugins
│ └── com.unquietcode.flapi.plugin.properties
├── flapi-parent
└── pom.xml
├── flapi-plugin
├── pom.xml
└── src
│ └── main
│ └── java
│ └── unquietcode
│ └── tools
│ └── flapi
│ └── plugin
│ ├── PluginHelper.java
│ └── compile
│ ├── CharSequenceJavaFileObject.java
│ ├── ClassFileManager.java
│ └── JavaClassObject.java
├── flapi-runtime
├── pom.xml
└── src
│ └── main
│ └── java
│ └── unquietcode
│ └── tools
│ └── flapi
│ ├── ExtractRuntime.java
│ ├── annotations
│ ├── After.java
│ ├── Any.java
│ ├── AtLeast.java
│ ├── AtMost.java
│ ├── Between.java
│ ├── Block.java
│ ├── BlockChain.java
│ ├── Documented.java
│ ├── EnumSelector.java
│ ├── Exactly.java
│ ├── FlapiAnnotation.java
│ ├── Last.java
│ └── MethodQuantifier.java
│ ├── runtime
│ ├── BlockInvocationHandler.java
│ ├── ChainInfo.java
│ ├── Constants.java
│ ├── Consumer.java
│ ├── EnumSelectorHint.java
│ ├── ExecutionListener.java
│ ├── ExpectedInvocationsException.java
│ ├── Helpers.java
│ ├── MethodInfo.java
│ ├── MethodLogger.java
│ ├── OriginalMethod.java
│ ├── PackageMarker.java
│ ├── SpringMethodUtils.java
│ ├── Supplier.java
│ ├── Tracked.java
│ ├── TrackingExecutionListener.java
│ └── TransitionType.java
│ └── support
│ ├── BuilderImplementation.java
│ ├── ExpectedInvocationsException.java
│ └── ObjectWrapper.java
├── pom.xml
├── release.sh
├── reversion.sh
└── src
├── main
├── java
│ └── unquietcode
│ │ └── tools
│ │ └── flapi
│ │ ├── CharacterGenerator.java
│ │ ├── ClassReference.java
│ │ ├── CodeWriter.java
│ │ ├── Constants.java
│ │ ├── Descriptor.java
│ │ ├── DescriptorBuilderException.java
│ │ ├── DescriptorMaker.java
│ │ ├── DescriptorPostValidator.java
│ │ ├── DescriptorPreValidator.java
│ │ ├── Flapi.java
│ │ ├── IntrospectorSupport.java
│ │ ├── Pair.java
│ │ ├── Utilities.java
│ │ ├── annotations
│ │ └── AnnotationIntrospector.java
│ │ ├── beans
│ │ └── BeanIntrospector.java
│ │ ├── generator
│ │ ├── AbstractGenerator.java
│ │ ├── DefaultTypeCreationStrategy.java
│ │ ├── DescriptorGenerator.java
│ │ ├── GeneratorContext.java
│ │ ├── GeneratorGenerator.java
│ │ ├── TypeCreationStrategy.java
│ │ └── naming
│ │ │ ├── CondensedNameGenerator.java
│ │ │ ├── DefaultNameGenerator.java
│ │ │ ├── HashedNameGenerator.java
│ │ │ ├── Hasher.java
│ │ │ ├── NameGenerator.java
│ │ │ └── TinyNameGenerator.java
│ │ ├── graph
│ │ ├── BlockMethodTracker.java
│ │ ├── GenericVisitor.java
│ │ ├── GraphBuilder.java
│ │ ├── TransitionVisitor.java
│ │ ├── components
│ │ │ ├── AscendingTransition.java
│ │ │ ├── LateralTransition.java
│ │ │ ├── RecursiveTransition.java
│ │ │ ├── StateClass.java
│ │ │ ├── TerminalTransition.java
│ │ │ └── Transition.java
│ │ └── processors
│ │ │ ├── GraphProcessor.java
│ │ │ └── ReturnTypeProcessor.java
│ │ ├── helpers
│ │ ├── AnnotationsHelperImpl.java
│ │ ├── BlockChainHelperImpl.java
│ │ ├── BlockHelperImpl.java
│ │ ├── DescriptorConfiguratorHelperImpl.java
│ │ ├── DescriptorHelperImpl.java
│ │ ├── DocumentationHelperImpl.java
│ │ └── MethodHelperImpl.java
│ │ ├── java
│ │ ├── JavaType.java
│ │ ├── MethodSignature.java
│ │ └── ParseException.java
│ │ └── outline
│ │ ├── BlockOutline.java
│ │ ├── BlockReference.java
│ │ ├── DescriptorOutline.java
│ │ ├── GeneratorOutline.java
│ │ ├── MethodInfo.java
│ │ ├── MethodOutline.java
│ │ └── Outline.java
└── resources
│ └── version
│ └── version.txt
└── test
├── java
└── unquietcode
│ └── tools
│ └── flapi
│ ├── AbstractCompiledTest.java
│ ├── AtLeast_T.java
│ ├── BlackHoleStream.java
│ ├── BlockReference_T.java
│ ├── BuildChecks_T.java
│ ├── ClassResolution_T.java
│ ├── GenerateEverything.java
│ ├── GraphNaming_T.java
│ ├── GroupedMethods_T.java
│ ├── LogMachineBuilderTest.java
│ ├── MethodParser_T.java
│ ├── Naming_T.java
│ ├── TriggeredMethods_T.java
│ ├── TypeParameters_T.java
│ ├── annotations
│ └── AnnotationBuilder_T.java
│ └── examples
│ ├── ExamplesTest.java
│ ├── GenerateExamples.java
│ ├── calculator
│ ├── Calculation.java
│ ├── CalculationHelperImpl.java
│ ├── Calculator.java
│ ├── CalculatorBuilderExample.java
│ ├── CalculatorHelperImpl.java
│ └── builder
│ │ ├── Calculation
│ │ ├── CalculationBuilder.java
│ │ └── CalculationBuilder_2abs_2divide_2minus_2mod_2plus_2power_2times.java
│ │ └── Calculator
│ │ ├── CalculatorBuilder.java
│ │ ├── CalculatorFactory.java
│ │ └── CalculatorGenerator.java
│ ├── email
│ ├── AnnotatedEmailHelper.java
│ ├── EmailBuilderExample.java
│ ├── EmailHelperImpl.java
│ ├── EmailMessage.java
│ └── builder
│ │ └── Email
│ │ ├── EmailBuilder.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2body.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2body_2sender.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2body_2sender_2subject.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2body_2subject.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2sender.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2sender_2subject.java
│ │ ├── EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2subject.java
│ │ ├── EmailFactory.java
│ │ ├── EmailGenerator.java
│ │ └── EmailHelper.java
│ ├── house
│ ├── AffordableHouse.java
│ ├── ExpensiveHouse.java
│ ├── House.java
│ ├── HouseBuilderExample.java
│ ├── HouseHelperImpl.java
│ ├── Wall.java
│ ├── WallHelperImpl.java
│ └── builder
│ │ ├── House
│ │ ├── HouseBuilder.java
│ │ ├── HouseFactory.java
│ │ ├── HouseGenerator.java
│ │ └── HouseHelper.java
│ │ └── Wall
│ │ ├── WallBuilder.java
│ │ ├── WallBuilder_2setColor_2setWidth.java
│ │ ├── WallBuilder_2setColor_5t.java
│ │ ├── WallBuilder_2setWidth_5t.java
│ │ └── WallHelper.java
│ ├── pipes
│ ├── IOUtils.java
│ ├── PipedProcessExample.java
│ ├── Piper.java
│ ├── ProcessHelperImpl.java
│ └── builder
│ │ └── Process
│ │ ├── ProcessBuilder.java
│ │ ├── ProcessBuilder_2addArgument_2addArgument_1A_2pipe.java
│ │ ├── ProcessBuilder_2addArgument_2addArgument_1A_2withProcess.java
│ │ ├── ProcessFactory.java
│ │ ├── ProcessGenerator.java
│ │ └── ProcessHelper.java
│ ├── pizza
│ ├── DisappearingPizzaExample.java
│ ├── PizzaHelperImpl.java
│ └── builder
│ │ └── Pizza
│ │ ├── PizzaBuilder.java
│ │ ├── PizzaBuilder_2addCheese.java
│ │ ├── PizzaBuilder_2addCheese_2addSauce.java
│ │ ├── PizzaBuilder_2addCheese_2addSauce_2addTopping.java
│ │ ├── PizzaBuilder_2addCheese_2addSauce_2addTopping_32.java
│ │ ├── PizzaBuilder_2addCheese_2addSauce_2addTopping_33.java
│ │ ├── PizzaBuilder_2addCheese_2addTopping.java
│ │ ├── PizzaBuilder_2addCheese_2addTopping_32.java
│ │ ├── PizzaBuilder_2addCheese_2addTopping_33.java
│ │ ├── PizzaBuilder_2addSauce.java
│ │ ├── PizzaBuilder_2addSauce_2addTopping.java
│ │ ├── PizzaBuilder_2addSauce_2addTopping_32.java
│ │ ├── PizzaBuilder_2addSauce_2addTopping_33.java
│ │ ├── PizzaBuilder_2addTopping.java
│ │ ├── PizzaBuilder_2addTopping_32.java
│ │ ├── PizzaBuilder_2addTopping_33.java
│ │ ├── PizzaFactory.java
│ │ ├── PizzaGenerator.java
│ │ └── PizzaHelper.java
│ └── xhtml
│ ├── ElementHelperImpl.java
│ ├── XHTMLBuilderExample.java
│ ├── XHTMLHelperImpl.java
│ └── builder
│ ├── Element
│ ├── ElementBuilder.java
│ ├── ElementBuilder_2addAttribute_2addComment_2endElement_2startElement.java
│ ├── ElementBuilder_2addAttribute_2addComment_2setValue_2startElement.java
│ └── ElementHelper.java
│ └── XHTML
│ ├── XHTMLBuilder.java
│ ├── XHTMLBuilder_2addComment_2startElement.java
│ ├── XHTMLFactory.java
│ ├── XHTMLGenerator.java
│ └── XHTMLHelper.java
└── resources
├── BlockChainTest.avaj
├── GroupedTest1.avaj
├── GroupedTest2.avaj
├── TopReference.avaj
├── TriggeredTest1.avaj
└── TriggeredTest2.avaj
/.travis.yml:
--------------------------------------------------------------------------------
1 | before_install: cd flapi-parent
2 | language: java
3 | jdk:
4 | - oraclejdk8
5 | - openjdk8
6 |
--------------------------------------------------------------------------------
/CONTRIBUTORS.md:
--------------------------------------------------------------------------------
1 | The following individuals and organizations have given their time and energy to help
2 | with the creation and maintenance of Flapi.
3 |
4 | * Jiri Jetmar - [#159]
5 | * Chris Wensel ([@cwensel](https://github.com/cwensel)) - [#5, #8, #12, #197]
6 |
--------------------------------------------------------------------------------
/flapi-build-plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 |
9 | flapi-parent
10 | com.unquietcode.tools.flapi
11 | 0.0-DEVELOPMENT
12 | ../flapi-parent
13 |
14 |
15 | flapi-build-plugin
16 | maven-plugin
17 |
18 |
19 | 3.3
20 |
21 |
22 |
23 |
24 |
25 | org.apache.maven.plugins
26 | maven-plugin-plugin
27 | ${maven.plugin.version}
28 |
29 | true
30 |
31 |
32 |
33 | mojo-descriptor
34 | process-classes
35 |
36 | descriptor
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | org.apache.maven
47 | maven-plugin-api
48 | 3.0.4
49 |
50 |
51 | org.apache.maven.plugin-tools
52 | maven-plugin-annotations
53 | ${maven.plugin.version}
54 |
55 |
56 | org.apache.maven
57 | maven-core
58 | 3.0.4
59 | provided
60 |
61 |
62 | com.unquietcode.tools.flapi
63 | flapi-plugin
64 | ${project.version}
65 |
66 |
67 |
68 |
--------------------------------------------------------------------------------
/flapi-build-test-consumer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | apply plugin: 'maven'
3 |
4 | group = 'com.unquietcode.tools.flapi.test'
5 | version = '0.0-DEVELOPMENT'
6 | sourceCompatibility = '1.8'
7 |
8 | install.dependsOn test
9 |
10 | repositories {
11 | mavenCentral()
12 | mavenLocal()
13 | }
14 |
15 | dependencies {
16 | implementation 'com.unquietcode.tools.flapi.test:flapi-gradle-test-producer:0.0-DEVELOPMENT'
17 | testImplementation 'junit:junit:4.11'
18 | }
--------------------------------------------------------------------------------
/flapi-build-test-consumer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 | com.unquietcode.tools.flapi.test
9 | build-test-consumer
10 | 0.0-DEVELOPMENT
11 | jar
12 |
13 |
14 |
15 |
16 | org.apache.maven.plugins
17 | maven-compiler-plugin
18 | 3.5.1
19 |
20 | 1.8
21 | 1.8
22 |
23 |
24 |
25 | org.apache.maven.plugins
26 | maven-deploy-plugin
27 | 2.8.2
28 |
29 | true
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 | com.unquietcode.tools.flapi.test
40 | build-test-producer
41 | ${project.version}
42 |
43 |
44 |
45 | junit
46 | junit
47 | 4.11
48 | test
49 |
50 |
51 |
52 |
53 |
--------------------------------------------------------------------------------
/flapi-build-test-consumer/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'flapi-gradle-consumer'
--------------------------------------------------------------------------------
/flapi-build-test-producer/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'java'
2 | apply plugin: 'maven'
3 |
4 | group = 'com.unquietcode.tools.flapi.test'
5 | version = '0.0-DEVELOPMENT'
6 | sourceCompatibility = '1.8'
7 |
8 | // add the gradle plugin
9 | buildscript {
10 | repositories {
11 | mavenLocal()
12 | }
13 |
14 | dependencies {
15 | classpath 'com.unquietcode.tools.flapi:flapi-gradle-plugin:0.0-DEVELOPMENT'
16 | }
17 | }
18 | apply plugin: 'com.unquietcode.flapi.plugin'
19 |
20 | install.dependsOn test
21 |
22 | // ------------------------------------------------------- //
23 |
24 |
25 | repositories {
26 | mavenLocal()
27 | }
28 |
29 | dependencies {
30 | compileOnly 'com.unquietcode.tools.flapi:flapi:0.0-DEVELOPMENT'
31 | testCompile 'com.unquietcode.tools.flapi:flapi:0.0-DEVELOPMENT'
32 | }
33 |
34 |
35 | import unquietcode.tools.flapi.Descriptor
36 | import unquietcode.tools.flapi.DescriptorMaker
37 | import unquietcode.tools.flapi.Flapi
38 |
39 | import java.util.concurrent.atomic.AtomicInteger
40 |
41 | class TestInlineDescriptor implements DescriptorMaker {
42 | static final def counter = new AtomicInteger(1);
43 |
44 |
45 | @Override
46 | Descriptor descriptor() {
47 | return Flapi.builder()
48 | .setPackage("unquietcode.tools.flapi.plugin.test.builder"+counter.getAndIncrement())
49 | .setDescriptorName("Test")
50 |
51 | .addMethod("done()").last()
52 | .build();
53 | }
54 | }
55 |
56 | flapi {
57 | descriptors = [
58 | 'unquietcode.tools.flapi.plugin.TestDescriptor', // DescriptorMaker FQCN
59 | TestInlineDescriptor, // DescriptorMaker class
60 | new TestInlineDescriptor(), // DescriptorMaker instance
61 | new TestInlineDescriptor().descriptor() // Descriptor instance
62 | ]
63 | includeRuntime = true
64 | }
--------------------------------------------------------------------------------
/flapi-build-test-producer/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 |
9 | com.unquietcode.tools.flapi
10 | flapi-build-project
11 | 0.0-DEVELOPMENT
12 | ../flapi-build-project
13 |
14 |
15 | com.unquietcode.tools.flapi.test
16 | build-test-producer
17 | jar
18 |
19 |
20 | unquietcode.tools.flapi.plugin.TestDescriptor
21 | true
22 |
23 |
24 |
25 |
26 |
27 | org.apache.maven.plugins
28 | maven-deploy-plugin
29 | 2.8.2
30 |
31 | true
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/flapi-build-test-producer/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'flapi-gradle-test-producer'
--------------------------------------------------------------------------------
/flapi-build-test-producer/src/main/java/unquietcode/tools/flapi/plugin/TestAnnotation.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.plugin;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * @author cwensel
26 | */
27 | @Retention(RetentionPolicy.RUNTIME)
28 | @Target(ElementType.METHOD)
29 | public @interface TestAnnotation {
30 |
31 | String someValue();
32 |
33 | String[] someValues() default {""};
34 | }
35 |
--------------------------------------------------------------------------------
/flapi-build-test-producer/src/main/java/unquietcode/tools/flapi/plugin/TestEnum.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.plugin;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 2013-07-03
22 | */
23 | public enum TestEnum {
24 | One, TWO, three
25 | }
26 |
--------------------------------------------------------------------------------
/flapi-build-test-producer/src/test/java/unquietcode/tools/flapi/plugin/TestDescriptorTest.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2018 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a basicCopy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.plugin;
18 |
19 | import unquietcode.tools.flapi.Descriptor;
20 |
21 | /**
22 | * @author Ben Fagin
23 | * @version 2018-05-13
24 | */
25 | public class TestDescriptorTest {
26 |
27 | public static void main(String[] args) {
28 | Descriptor descriptor = new TestDescriptor().descriptor();
29 | descriptor.writeToStream(System.out);
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/flapi-gradle-plugin/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'groovy'
2 | apply plugin: 'maven'
3 | apply plugin: 'maven-publish'
4 | apply plugin: 'signing'
5 |
6 | group = 'com.unquietcode.tools.flapi'
7 | version = '0.0-DEVELOPMENT'
8 | description = 'Flapi build plugin for Gradle'
9 |
10 | sourceCompatibility = '1.8'
11 |
12 | repositories {
13 | mavenLocal()
14 | }
15 |
16 | dependencies {
17 | compile gradleApi()
18 | compile localGroovy()
19 |
20 | compile 'com.unquietcode.tools.flapi:flapi-plugin:0.0-DEVELOPMENT'
21 | }
22 |
23 | task sourceJar(type: Jar, dependsOn: classes) {
24 | classifier = "sources"
25 | from sourceSets.main.allJava
26 | }
27 |
28 | task javadocJar(type: Jar, dependsOn: javadoc) {
29 | classifier = 'javadoc'
30 | from javadoc.destinationDir
31 | }
32 |
33 | artifacts {
34 | archives sourceJar
35 | archives javadocJar
36 | }
37 |
38 | uploadArchives {
39 | repositories {
40 | mavenDeployer {
41 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
42 |
43 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
44 | authentication(userName: ossrhUsername, password: ossrhPassword)
45 | }
46 |
47 | snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
48 | authentication(userName: ossrhUsername, password: ossrhPassword)
49 | }
50 |
51 | pom.project {
52 | name 'Flapi Gradle Plugin'
53 | description project.description
54 |
55 | packaging 'jar'
56 | url 'https://github.com/UnquietCode/Flapi'
57 |
58 | scm {
59 | connection 'scm:git:https://github.com/UnquietCode/Flapi.git'
60 | developerConnection 'scm:git:https://github.com/UnquietCode/Flapi.git'
61 | url 'https://github.com/UnquietCode/Flapi'
62 | }
63 |
64 | licenses {
65 | license {
66 | name 'The Apache License, Version 2.0'
67 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
68 | }
69 | }
70 |
71 | developers {
72 | developer {
73 | id 'UnquietCode'
74 | name 'Benjamin Fagin'
75 | email 'blouis@unquietcode.com'
76 | }
77 | }
78 | }
79 | }
80 | }
81 | }
82 |
83 | signing {
84 | sign configurations.archives
85 | }
--------------------------------------------------------------------------------
/flapi-gradle-plugin/src/main/resources/META-INF/gradle-plugins/com.unquietcode.flapi.plugin.properties:
--------------------------------------------------------------------------------
1 | implementation-class=unquietcode.tools.flapi.plugin.GradlePlugin
--------------------------------------------------------------------------------
/flapi-plugin/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
6 | 4.0.0
7 |
8 |
9 | flapi-parent
10 | com.unquietcode.tools.flapi
11 | 0.0-DEVELOPMENT
12 | ../flapi-parent
13 |
14 |
15 | flapi-plugin
16 |
17 |
18 |
19 | com.unquietcode.tools.flapi
20 | flapi
21 | ${project.version}
22 |
23 |
24 |
--------------------------------------------------------------------------------
/flapi-plugin/src/main/java/unquietcode/tools/flapi/plugin/compile/CharSequenceJavaFileObject.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.plugin.compile;
18 |
19 | import javax.tools.SimpleJavaFileObject;
20 | import java.net.URI;
21 |
22 | /**
23 | * Modified from code found at http://www.javablogging.com/dynamic-in-memory-compilation
24 | * Many thanks to the author, Miron Sadziak.
25 | */
26 | public class CharSequenceJavaFileObject extends SimpleJavaFileObject {
27 |
28 | /**
29 | * CharSequence representing the source code to be compiled
30 | */
31 | private CharSequence content;
32 |
33 | /**
34 | * This constructor will store the source code in the
35 | * internal "content" variable and register it as a
36 | * source code, using a URI containing the class full name
37 | *
38 | * @param className
39 | * name of the public class in the source code
40 | * @param content
41 | * source code to compile
42 | */
43 | public CharSequenceJavaFileObject(String className,CharSequence content) {
44 | super(URI.create("string:///" + className.replace('.', '/')
45 | + Kind.SOURCE.extension), Kind.SOURCE);
46 | this.content = content;
47 | }
48 |
49 | /**
50 | * Answers the CharSequence to be compiled. It will give
51 | * the source code stored in variable "content"
52 | */
53 | @Override
54 | public CharSequence getCharContent(boolean ignoreEncodingErrors) {
55 | return content;
56 | }
57 | }
--------------------------------------------------------------------------------
/flapi-plugin/src/main/java/unquietcode/tools/flapi/plugin/compile/JavaClassObject.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.plugin.compile;
18 |
19 | import javax.tools.SimpleJavaFileObject;
20 | import java.io.File;
21 | import java.io.FileOutputStream;
22 | import java.io.IOException;
23 | import java.io.OutputStream;
24 | import java.net.URI;
25 |
26 | /**
27 | * Modified from code found at http://www.javablogging.com/dynamic-in-memory-compilation
28 | * Many thanks to the author, Miron Sadziak.
29 | */
30 | public class JavaClassObject extends SimpleJavaFileObject {
31 | private final File file;
32 |
33 |
34 | /**
35 | * Registers the compiled class object under URI
36 | * containing the class full name
37 | *
38 | * @param name
39 | * Full name of the compiled class
40 | * @param kind
41 | * Kind of the data. It will be CLASS in our case
42 | */
43 | public JavaClassObject(String name, Kind kind, File output) {
44 | super(URI.create("string:///" + name.replace('.', '/')
45 | + kind.extension), kind);
46 |
47 | this.file = output;
48 | }
49 |
50 | /**
51 | * Will provide the compiler with an output stream that leads
52 | * to our byte array. This way the compiler will write everything
53 | * into the byte array that we will instantiate later
54 | */
55 | @Override
56 | public OutputStream openOutputStream() throws IOException {
57 | return new FileOutputStream(file);
58 | }
59 | }
--------------------------------------------------------------------------------
/flapi-runtime/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 |
5 |
6 | com.unquietcode.tools.flapi
7 | flapi-parent
8 | 0.0-DEVELOPMENT
9 | ../flapi-parent/pom.xml
10 |
11 |
12 | flapi-runtime
13 | jar
14 |
15 | flapi-runtime
16 | Flapi runtime classes
17 |
18 |
19 | UTF-8
20 | unquietcode/tools/flapi/runtime
21 |
22 |
23 |
24 |
25 |
26 | src/main/java/${source.package}
27 |
28 | *.java
29 | *.class
30 |
31 | sources/${source.package}
32 |
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/After.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marks a method as only being visible after the
26 | * group (specified by the value) has been triggered.
27 | *
28 | * @author Ben Fagin
29 | * @version 2014-08-03
30 | */
31 | @FlapiAnnotation
32 | @Target(ElementType.METHOD)
33 | @Retention(RetentionPolicy.RUNTIME)
34 | public @interface After {
35 | int value();
36 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/Any.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import unquietcode.tools.flapi.runtime.Constants;
20 |
21 | import java.lang.annotation.ElementType;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.RetentionPolicy;
24 | import java.lang.annotation.Target;
25 |
26 | /**
27 | * Marks a method as being executable any number of times.
28 | *
29 | * @author Ben Fagin
30 | * @version 2014-08-03
31 | */
32 | @FlapiAnnotation
33 | @MethodQuantifier
34 | @Target(ElementType.METHOD)
35 | @Retention(RetentionPolicy.RUNTIME)
36 | public @interface Any {
37 | int group() default Constants.DEFAULT_NULL_INT;
38 | }
39 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/AtLeast.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marks a method as needing to be executed a minimum of X times.
26 | *
27 | * @author Ben Fagin
28 | * @version 2014-08-03
29 | */
30 | @FlapiAnnotation
31 | @MethodQuantifier
32 | @Target(ElementType.METHOD)
33 | @Retention(RetentionPolicy.RUNTIME)
34 | public @interface AtLeast {
35 | int value();
36 | }
37 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/AtMost.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import unquietcode.tools.flapi.runtime.Constants;
20 |
21 | import java.lang.annotation.ElementType;
22 | import java.lang.annotation.Retention;
23 | import java.lang.annotation.RetentionPolicy;
24 | import java.lang.annotation.Target;
25 |
26 | /**
27 | * Marks a method as being executable a maximum of X times.
28 | * Can also be associated with a group.
29 | *
30 | * @author Ben Fagin
31 | * @version 2014-08-03
32 | */
33 | @FlapiAnnotation
34 | @MethodQuantifier
35 | @Target(ElementType.METHOD)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface AtMost {
38 | int value();
39 | int group() default Constants.DEFAULT_NULL_INT;
40 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/Between.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marks method as needing to be executed a minimum of X times and
26 | * a maximum of Y times.
27 | *
28 | * @author Ben Fagin
29 | * @version 2014-08-03
30 | */
31 | @FlapiAnnotation
32 | @MethodQuantifier
33 | @Target(ElementType.METHOD)
34 | @Retention(RetentionPolicy.RUNTIME)
35 | public @interface Between {
36 | int minInc();
37 | int maxInc();
38 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/Block.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marks a block type with additional information
26 | * which can be used to customize the associated
27 | * generated builder.
28 | *
29 | * @author Ben Fagin
30 | * @version 2014-08-03
31 | */
32 | @FlapiAnnotation
33 | @Target(ElementType.TYPE)
34 | @Retention(RetentionPolicy.RUNTIME)
35 | public @interface Block {
36 | String name() default "";
37 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/BlockChain.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Specifies a method parameter that is to be used for building
26 | * a block chain around the method. The parameter must be of
27 | * type {@link java.util.concurrent.atomic.AtomicReference}.
28 | *
29 | * @author Ben Fagin
30 | * @version 2014-08-03
31 | */
32 | @FlapiAnnotation
33 | @Target(ElementType.PARAMETER)
34 | @Retention(RetentionPolicy.RUNTIME)
35 | public @interface BlockChain { }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/Documented.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Provides documentation for a method, which would otherwise be
26 | * unavailable at runtime.
27 | *
28 | * @author Ben Fagin
29 | * @version 2014-08-03
30 | */
31 | @FlapiAnnotation
32 | @Target(ElementType.METHOD)
33 | @Retention(RetentionPolicy.RUNTIME)
34 | public @interface Documented {
35 | String[] value();
36 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/EnumSelector.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Specifies a method which is to be turned into an enum selector.
26 | * The method should have a single parameter of the desired enum type.
27 | *
28 | * @author Ben Fagin
29 | * @version 2015-02-18
30 | */
31 | @FlapiAnnotation
32 | @Target(ElementType.METHOD)
33 | @Retention(RetentionPolicy.RUNTIME)
34 | public @interface EnumSelector {
35 |
36 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/Exactly.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marks a method as having to be executed exactly X times.
26 | *
27 | * @author Ben Fagin
28 | * @version 2014-08-03
29 | */
30 | @FlapiAnnotation
31 | @MethodQuantifier
32 | @Target(ElementType.METHOD)
33 | @Retention(RetentionPolicy.RUNTIME)
34 | public @interface Exactly {
35 | int value();
36 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/FlapiAnnotation.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marker annotation for Flapi annotations.
26 | *
27 | * @author Ben Fagin
28 | * @version 2014-08-09
29 | */
30 | @Target(ElementType.ANNOTATION_TYPE)
31 | @Retention(RetentionPolicy.RUNTIME)
32 | /*package*/ @interface FlapiAnnotation {
33 | // nothing for now
34 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/Last.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marks a method as being the last in a block.
26 | * The method may return a value. Every block must
27 | * have at least one @Last method in order to be
28 | * valid (and truly, to be at all escapable).
29 | *
30 | * @author Ben Fagin
31 | * @version 2014-08-03
32 | */
33 | @FlapiAnnotation
34 | @MethodQuantifier
35 | @Target(ElementType.METHOD)
36 | @Retention(RetentionPolicy.RUNTIME)
37 | public @interface Last {
38 | // nothing for now
39 | }
40 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/annotations/MethodQuantifier.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marker annotation for method quantifiers.
26 | *
27 | * @author Ben Fagin
28 | * @version 2014-08-03
29 | */
30 | @Target(ElementType.ANNOTATION_TYPE)
31 | @Retention(RetentionPolicy.RUNTIME)
32 | /*package*/ @interface MethodQuantifier {
33 | // nothing for now
34 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/ChainInfo.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Information about the position and type of a block
26 | * chain parameter.
27 | *
28 | * @author Ben Fagin
29 | * @version 2014-11-02
30 | */
31 | @Target(ElementType.ANNOTATION_TYPE)
32 | @Retention(RetentionPolicy.RUNTIME)
33 | public @interface ChainInfo {
34 | Class> type();
35 | int position();
36 | }
37 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/Constants.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2016 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 2016-04-23
22 | */
23 | public final class Constants {
24 | private Constants() { }
25 |
26 | public static final int DEFAULT_NULL_INT = Integer.MIN_VALUE;
27 | }
28 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/Consumer.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | /**
20 | * Simple little ditty to consume things.
21 | *
22 | * This is meant to be replaced by the real type
23 | * contained within Java 8, whenever JDK 7 support
24 | * is discontinued.
25 | *
26 | * @author Ben Fagin
27 | * @version 2015-02-18
28 | */
29 | public interface Consumer {
30 | void accept(T element);
31 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/EnumSelectorHint.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * @author Ben Fagin
26 | * @version 2015-02-18
27 | */
28 | @Target(ElementType.METHOD)
29 | @Retention(RetentionPolicy.RUNTIME)
30 | public @interface EnumSelectorHint {
31 | Class extends Enum> value();
32 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/ExecutionListener.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | import java.lang.reflect.Method;
20 |
21 | /**
22 | * Listen and respond to executions of methods in a builder.
23 | *
24 | * @author Ben Fagin
25 | * @version 2013-07-02
26 | */
27 | public interface ExecutionListener {
28 |
29 | /**
30 | * Respond to the next method about to be invoked.
31 | * @param method the current interface method being invoked
32 | * @param args the current args to the method
33 | */
34 | void next(Method method, Object[] args);
35 | }
36 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/ExpectedInvocationsException.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 05-31-2012
22 | *
23 | * Thrown when the number of invocations of a particular method
24 | * is greater or less than the expected number, as determined
25 | * by the individual descriptor.
26 | */
27 | public class ExpectedInvocationsException extends RuntimeException {
28 | public ExpectedInvocationsException(String message) {
29 | super(message);
30 | }
31 |
32 | public ExpectedInvocationsException(Throwable cause) {
33 | super(cause);
34 | }
35 |
36 | public ExpectedInvocationsException(String message, Throwable cause) {
37 | super(message, cause);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/MethodInfo.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * @author Ben Fagin
26 | * @version 2013-06-30
27 | */
28 | @Retention(RetentionPolicy.RUNTIME)
29 | @Target(ElementType.METHOD)
30 | public @interface MethodInfo {
31 | TransitionType type();
32 |
33 | ChainInfo[] chainInfo() default {};
34 |
35 | Class> next() default MethodInfo.class;
36 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/OriginalMethod.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Pointer to the original method name, or none.
26 | *
27 | * @author Ben Fagin
28 | * @version 2014-09-07
29 | */
30 | @Target(ElementType.METHOD)
31 | @Retention(RetentionPolicy.RUNTIME)
32 | public @interface OriginalMethod {
33 |
34 | String value() default DEFAULT_NONE;
35 |
36 | String DEFAULT_NONE = "=:D_-";
37 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/PackageMarker.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | /**
20 | * Marker which can be used to reflectively access the package name.
21 | *
22 | * @author Ben Fagin
23 | * @version 2013-08-16
24 | */
25 | public final class PackageMarker {
26 | private PackageMarker() { }
27 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/Supplier.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | /**
20 | * Simple little ditty to provide things.
21 | *
22 | * This is meant to be replaced by the real type
23 | * contained within Java 8, whenever JDK 7 support
24 | * is discontinued.
25 | *
26 | * @author Ben Fagin
27 | * @version 2015-01-16
28 | */
29 | public interface Supplier {
30 | T get();
31 | }
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/Tracked.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | import java.lang.annotation.ElementType;
20 | import java.lang.annotation.Retention;
21 | import java.lang.annotation.RetentionPolicy;
22 | import java.lang.annotation.Target;
23 |
24 | /**
25 | * Marks a method for invocation tracking.
26 | *
27 | * @author Ben Fagin
28 | * @version 2013-06-09
29 | */
30 | @Retention(RetentionPolicy.RUNTIME)
31 | @Target(ElementType.METHOD)
32 | public @interface Tracked {
33 | int atLeast();
34 | String key();
35 | }
36 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/runtime/TransitionType.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.runtime;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 07-11-2012
22 | */
23 | public enum TransitionType {
24 | Recursive, // goes back to itself
25 | Lateral, // goes to a version of itself minus a method
26 | Terminal, // exits the graph
27 | Ascending, // moves upwards by 1 step
28 | }
29 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/support/BuilderImplementation.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.support;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 05-31-2012
22 | *
23 | * Unifying interface for all builder implementations, providing several
24 | * guarantees which are used within the generated logic.
25 | */
26 | public interface BuilderImplementation {
27 | BuilderImplementation _getParent();
28 | void _checkInvocations();
29 | }
30 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/support/ExpectedInvocationsException.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.support;
18 | /**
19 | * @author Ben Fagin
20 | * @version 05-31-2012
21 | *
22 | * Thrown when the number of invocations of a particular method
23 | * is greater or less than the expected number, as determined
24 | * by the individual descriptor.
25 | */
26 | public class ExpectedInvocationsException extends RuntimeException {
27 | public ExpectedInvocationsException(String message) {
28 | super(message);
29 | }
30 |
31 | public ExpectedInvocationsException(Throwable cause) {
32 | super(cause);
33 | }
34 |
35 | public ExpectedInvocationsException(String message, Throwable cause) {
36 | super(message, cause);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/flapi-runtime/src/main/java/unquietcode/tools/flapi/support/ObjectWrapper.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.support;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 04-24-2012
22 | *
23 | * It is what it says it is.
24 | */
25 | public class ObjectWrapper<_Type> {
26 | private _Type value;
27 |
28 |
29 | public ObjectWrapper() { }
30 |
31 | public ObjectWrapper(_Type value) {
32 | this.value = value;
33 | }
34 |
35 | public void set(_Type value) {
36 | this.value = value;
37 | }
38 |
39 | public _Type get() {
40 | return value;
41 | }
42 |
43 | public @Override String toString() {
44 | return String.valueOf(value);
45 | }
46 | }
--------------------------------------------------------------------------------
/release.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$#" -ne 2 ]; then
4 | echo "usage: "
5 | exit 1
6 | fi
7 |
8 | version=$1
9 | repository=$2
10 |
11 | # replace all development versions with release version
12 | replacement="s/0.0-DEVELOPMENT/$version/g"
13 | find . -name "pom.xml" -exec sed -i -e "$replacement" {} \;
14 | find . -name "build.gradle" -exec sed -i -e "$replacement" {} \;
15 |
16 | # commit tag of version name
17 | #git add pom.xml
18 | #git add flapi-build-plugin/pom.xml
19 | #git add flapi-build-project/pom.xml
20 | #git add flapi-build-test-consumer/pom.xml
21 | #git add flapi-build-test-producer/pom.xml
22 | #git add flapi-descriptor/pom.xml
23 | #git add flapi-gradle-plugin/pom.xml
24 | #git add flapi-parent/pom.xml
25 | #git add flapi-plugin/pom.xml
26 | #git add flapi-runtime/pom.xml
27 |
28 | #git commit -m"releasing version $version"
29 | #git tag $version
30 |
31 |
32 | # build and release the project
33 | cd flapi-parent
34 | mvn -DaltDeploymentRepository=micro::default::"$2" clean install deploy
35 | cd ..
36 |
37 | # replace all release versions with development version
38 | #replacement="s/$version/0.0-DEVELOPMENT/g"
39 | #find . -name "pom.xml" -exec sed -i -e "$replacement" {} \;
40 |
41 | # reset to the last working commit
42 | #git reset --hard HEAD~1
43 |
--------------------------------------------------------------------------------
/reversion.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | if [ "$#" -ne 1 ]; then
4 | echo "usage: "
5 | exit 1
6 | fi
7 |
8 | version=$1
9 |
10 | replacement="s/0.0-DEVELOPMENT/$version/g"
11 | find . -name "pom.xml" -exec sed -i -e "$replacement" {} \;
12 | find . -name "build.gradle" -exec sed -i -e "$replacement" {} \;
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/ClassReference.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | /**
20 | * A ClassReference is similar to a {@link Class} object, but
21 | * acts only as a reference to the fully qualified type (class or
22 | * interface). This special container is used within the Flapi
23 | * descriptor builder to avoid requiring a class to be present
24 | * at runtime.
25 | *
26 | * @author Ben Fagin
27 | * @version 2014-07-22
28 | */
29 | public class ClassReference {
30 | private final String fqcn;
31 |
32 | public ClassReference(String fqcn) {
33 | if (fqcn == null || fqcn.trim().isEmpty()) {
34 | throw new IllegalArgumentException("a fully qualified class name is required");
35 | }
36 | this.fqcn = fqcn;
37 | }
38 |
39 | public String getFQCN() {
40 | return fqcn;
41 | }
42 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/Constants.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import java.io.InputStream;
20 | import java.util.Scanner;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 04-28-2012
25 | *
26 | * Y'arr, here be project constants!
27 | */
28 | public final class Constants {
29 | private Constants() { }
30 |
31 | public static final String PROJECT_URL = "https://github.com/UnquietCode/Flapi";
32 | public static final String RETURN_TYPE_NAME = "_ReturnType";
33 | public static final String HELPER_VALUE_NAME = "_helper";
34 |
35 | public static final String PROJECT_VERSION; static {
36 | InputStream is = Constants.class.getClassLoader().getResourceAsStream("version/version.txt");
37 | PROJECT_VERSION = new Scanner(is).useDelimiter("\\A").next();
38 | }
39 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/DescriptorBuilderException.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | public class DescriptorBuilderException extends RuntimeException {
20 |
21 | public DescriptorBuilderException(String message) {
22 | super(message);
23 | }
24 |
25 | public DescriptorBuilderException(Throwable cause) {
26 | super(cause);
27 | }
28 |
29 | public DescriptorBuilderException(String message, Throwable cause) {
30 | super(message, cause);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/DescriptorMaker.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | /**
20 | * Classes which wish to make use of reflective tools
21 | * should implement this to signal that they can
22 | * return a valid descriptor. Implementations should
23 | * probably also guarantee a no-args constructor is
24 | * available.
25 | *
26 | * @author Ben Fagin
27 | * @version 2013-07-05
28 | */
29 | public interface DescriptorMaker {
30 | Descriptor descriptor();
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/Pair.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | /**
20 | * @author Ben Fagin
21 | */
22 | public class Pair {
23 | public final A first;
24 | public final B second;
25 |
26 |
27 | public Pair(A first, B second) {
28 | this.first = first;
29 | this.second = second;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/Utilities.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import com.google.common.collect.Sets;
20 |
21 | import java.util.*;
22 | import java.util.function.Function;
23 |
24 | public final class Utilities {
25 |
26 | private Utilities() { }
27 |
28 |
29 | public static void safeRecurse(T first, Function> function) {
30 | safeRecurse(Arrays.asList(first), function);
31 | }
32 |
33 | public static void safeRecurse(Collection first, Function> function) {
34 | safeRecurse(Sets.newIdentityHashSet(), first, function);
35 | }
36 |
37 | private static void safeRecurse(Set seen, Collection first, Function> function) {
38 | List> collections = new ArrayList<>();
39 | collections.add(first);
40 |
41 | while (!collections.isEmpty()) {
42 | Collection collection = collections.remove(0);
43 | if (collection == null || collection.isEmpty()) { continue; }
44 |
45 | for (T e : collection) {
46 | if (seen.contains(e)) { continue; }
47 | else { seen.add(e); }
48 |
49 | Collection next = function.apply(e);
50 | if (next != null) { collections.add(next); }
51 | }
52 | }
53 | }
54 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/generator/DefaultTypeCreationStrategy.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.generator;
18 |
19 | import com.sun.codemodel.JClass;
20 | import unquietcode.tools.flapi.graph.components.StateClass;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 2014-08-03
25 | */
26 | public abstract class DefaultTypeCreationStrategy implements TypeCreationStrategy {
27 |
28 | @Override
29 | public final JClass createWeakType(GeneratorContext ctx, StateClass state) {
30 | return createStrongType(ctx, state);
31 | }
32 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/generator/TypeCreationStrategy.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.generator;
18 |
19 | import com.sun.codemodel.JClass;
20 | import com.sun.codemodel.JDefinedClass;
21 | import unquietcode.tools.flapi.graph.components.StateClass;
22 |
23 | /**
24 | * @author Ben Fagin
25 | * @version 08-06-2012
26 | */
27 | public interface TypeCreationStrategy {
28 | JDefinedClass createStrongType(GeneratorContext ctx, StateClass state);
29 | JClass createWeakType(GeneratorContext ctx, StateClass state);
30 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/generator/naming/CondensedNameGenerator.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.generator.naming;
18 |
19 |
20 | import java.util.function.Function;
21 |
22 | /**
23 | * Name generator implementation which shortens
24 | * method names into a smaller string, while
25 | * leaving class names unaltered.
26 | *
27 | * @author Ben Fagin
28 | * @version 2015-01-14
29 | */
30 | public class CondensedNameGenerator extends DefaultNameGenerator {
31 | private final Function methodNameHasher = new Hasher("m");
32 |
33 | @Override
34 | public String methodName(String methodKey) {
35 | return methodNameHasher.apply(methodKey);
36 | }
37 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/generator/naming/HashedNameGenerator.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.generator.naming;
18 |
19 | import com.google.common.hash.Hashing;
20 |
21 | import java.nio.charset.Charset;
22 | import java.util.function.Function;
23 |
24 | /**
25 | * Name generator implementation which shortens names into
26 | * smaller strings using an MD5 hasher. This has the added
27 | * advantage that, since it is a consistent hash, if there
28 | * are no differences between names then the hash will
29 | * always be the same.
30 | *
31 | * @author Ben Fagin
32 | * @version 2015-01-14
33 | */
34 | public class HashedNameGenerator extends DefaultNameGenerator {
35 | private final Function stateNameHasher = string -> {
36 | String hashed = Hashing.md5().hashString(string, Charset.forName("UTF-8")).toString();
37 | return "S"+hashed;
38 | };
39 |
40 | @Override
41 | public String className(String stateKey) {
42 | return stateNameHasher.apply(stateKey);
43 | }
44 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/generator/naming/Hasher.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.generator.naming;
18 |
19 |
20 | import javax.lang.model.SourceVersion;
21 | import java.util.HashMap;
22 | import java.util.Map;
23 | import java.util.Objects;
24 | import java.util.function.Function;
25 |
26 | import static com.google.common.base.Preconditions.checkArgument;
27 |
28 | /**
29 | * Helper class which can internally keep track of hashed
30 | * names and a mapping from their original value.
31 | *
32 | * @author Ben Fagin
33 | * @version 2015-01-14
34 | */
35 | /* package */ class Hasher implements Function {
36 | private Map nameMap = new HashMap<>();
37 | private int nameIdCounter = 1;
38 | private final String prefix;
39 |
40 | public Hasher(String prefix) {
41 | this.prefix = Objects.requireNonNull(prefix);
42 | checkArgument(SourceVersion.isIdentifier(prefix));
43 | }
44 |
45 | @Override
46 | public String apply(String string) {
47 | if (nameMap.containsKey(string)) {
48 | return nameMap.get(string);
49 | } else {
50 | String gen = prefix + (nameIdCounter++);
51 | nameMap.put(string, gen);
52 | return gen;
53 | }
54 | }
55 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/generator/naming/TinyNameGenerator.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.generator.naming;
18 |
19 | import java.util.function.Function;
20 |
21 | /**
22 | * Name generator implementation which shortens names into
23 | * smaller strings.
24 | *
25 | * @author Ben Fagin
26 | * @version 2015-01-14
27 | */
28 | public class TinyNameGenerator extends DefaultNameGenerator {
29 | private final Function methodNameHasher = new Hasher("m");
30 | private final Function stateNameHasher = new Hasher("S");
31 |
32 | @Override
33 | public String methodName(String methodKey) {
34 | return methodNameHasher.apply(methodKey);
35 | }
36 |
37 | @Override
38 | public String className(String stateKey) {
39 | return stateNameHasher.apply(stateKey);
40 | }
41 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/graph/BlockMethodTracker.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.graph;
18 |
19 | import unquietcode.tools.flapi.graph.components.Transition;
20 |
21 | import java.util.HashMap;
22 | import java.util.HashSet;
23 | import java.util.Map;
24 | import java.util.Set;
25 |
26 | /**
27 | * @author Ben Fagin
28 | * @version 2013-06-29
29 | */
30 | public class BlockMethodTracker {
31 | private final Map> seenMethods = new HashMap<>();
32 | private final boolean useMethodKey;
33 |
34 | public BlockMethodTracker() {
35 | this(false);
36 | }
37 |
38 | public BlockMethodTracker(boolean useMethodKey) {
39 | this.useMethodKey = useMethodKey;
40 | }
41 |
42 | public boolean seen(Transition transition) {
43 | final String name = transition.getOwner().getName();
44 | final String key = useMethodKey
45 | ? transition.info().keyString()
46 | : transition.getMethodSignature().toString();
47 |
48 | Set methods = seenMethods.get(name);
49 |
50 | if (methods == null) {
51 | methods = new HashSet<>();
52 | seenMethods.put(name, methods);
53 | }
54 |
55 | if (methods.contains(key)) {
56 | return true;
57 | } else {
58 | methods.add(key);
59 | return false;
60 | }
61 | }
62 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/graph/GenericVisitor.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.graph;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 08-17-2012
22 | */
23 | public interface GenericVisitor {
24 | void visit(T object);
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/graph/TransitionVisitor.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.graph;
18 |
19 | import unquietcode.tools.flapi.graph.components.*;
20 |
21 | /**
22 | * @author Ben Fagin
23 | * @version 08-16-2012
24 | */
25 | public interface TransitionVisitor {
26 | void visit(Transition transition);
27 | void visit(AscendingTransition transition);
28 | void visit(LateralTransition transition);
29 | void visit(RecursiveTransition transition);
30 | void visit(TerminalTransition transition);
31 |
32 | /**
33 | * Abstract base class which can be used to selectively implement
34 | * the {@link unquietcode.tools.flapi.graph.TransitionVisitor} interface methods.
35 | */
36 | public abstract static class $ implements TransitionVisitor {
37 | public @Override void visit(Transition transition) {
38 | // nothing
39 | }
40 |
41 | public @Override void visit(AscendingTransition transition) {
42 | // nothing
43 | }
44 |
45 | public @Override void visit(LateralTransition transition) {
46 | // nothing
47 | }
48 |
49 | public @Override void visit(RecursiveTransition transition) {
50 | // nothing
51 | }
52 |
53 | public @Override void visit(TerminalTransition transition) {
54 | // nothing
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/graph/components/AscendingTransition.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.graph.components;
18 |
19 | import unquietcode.tools.flapi.graph.TransitionVisitor;
20 | import unquietcode.tools.flapi.runtime.TransitionType;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 08-15-2012
25 | */
26 | public class AscendingTransition extends Transition {
27 | private final boolean isRequired;
28 |
29 | public AscendingTransition(boolean isRequired) {
30 | super(TransitionType.Ascending);
31 | this.isRequired = isRequired;
32 | }
33 |
34 | public boolean isRequired() {
35 | return isRequired;
36 | }
37 |
38 | @Override
39 | public void accept(TransitionVisitor visitor) {
40 | visitor.visit(this);
41 | }
42 |
43 | @Override
44 | public Transition basicCopy() {
45 | AscendingTransition copy = new AscendingTransition(isRequired);
46 | copy(copy);
47 | return copy;
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/graph/components/RecursiveTransition.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.graph.components;
18 |
19 | import unquietcode.tools.flapi.graph.TransitionVisitor;
20 | import unquietcode.tools.flapi.runtime.TransitionType;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 08-15-2012
25 | */
26 | public class RecursiveTransition extends Transition {
27 | public RecursiveTransition() {
28 | super(TransitionType.Recursive);
29 | }
30 |
31 |
32 | /**
33 | * Alias for {@link #getOwner()}.
34 | * @return the {@link StateClass} for this transition
35 | */
36 | public StateClass getSelf() {
37 | return getOwner();
38 | }
39 |
40 | @Override
41 | public void accept(TransitionVisitor visitor) {
42 | visitor.visit(this);
43 | }
44 |
45 | @Override
46 | public Transition basicCopy() {
47 | RecursiveTransition copy = new RecursiveTransition();
48 | copy(copy);
49 | return copy;
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/graph/components/TerminalTransition.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.graph.components;
18 |
19 | import unquietcode.tools.flapi.graph.TransitionVisitor;
20 | import unquietcode.tools.flapi.java.JavaType;
21 | import unquietcode.tools.flapi.runtime.TransitionType;
22 |
23 | /**
24 | * @author Ben Fagin
25 | * @version 08-15-2012
26 | */
27 | public class TerminalTransition extends Transition {
28 | private JavaType returnType;
29 |
30 | public TerminalTransition() {
31 | super(TransitionType.Terminal);
32 | }
33 |
34 | public TerminalTransition(JavaType returnType) {
35 | this();
36 | this.returnType = returnType;
37 | }
38 |
39 | public JavaType getReturnType() {
40 | return returnType;
41 | }
42 |
43 | public void setReturnType(JavaType returnType) {
44 | this.returnType = returnType;
45 | }
46 |
47 | @Override
48 | public void accept(TransitionVisitor visitor) {
49 | visitor.visit(this);
50 | }
51 |
52 | @Override
53 | public Transition basicCopy() {
54 | TerminalTransition copy = new TerminalTransition();
55 | copy(copy);
56 | copy.returnType = this.returnType;
57 |
58 | return copy;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/helpers/DocumentationHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.helpers;
18 |
19 | import unquietcode.tools.flapi.builder.Documentation.DocumentationHelper;
20 | import unquietcode.tools.flapi.outline.MethodOutline;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 01-27-2013
25 | */
26 | public class DocumentationHelperImpl implements DocumentationHelper {
27 | private final MethodOutline method;
28 | private final StringBuilder buffer = new StringBuilder();
29 |
30 |
31 | public DocumentationHelperImpl(MethodOutline method) {
32 | this.method = method;
33 | }
34 |
35 | @Override
36 | public void addContent(String content) {
37 | if (content == null) {
38 | throw new IllegalArgumentException("Content cannot be null!");
39 | }
40 |
41 | buffer.append(content);
42 | }
43 |
44 | @Override
45 | public void finish() {
46 | method.setDocumentation(buffer.toString());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/java/ParseException.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.java;
18 |
19 | /**
20 | * @author Ben Fagin
21 | */
22 | public class ParseException extends Exception {
23 | /*package*/ ParseException(String message) {
24 | super(message);
25 | }
26 |
27 | /*package*/ ParseException(String message, Throwable cause) {
28 | super(message, cause);
29 | }
30 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/outline/BlockReference.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.outline;
18 |
19 |
20 | import static com.google.common.base.Preconditions.checkNotNull;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 03-10-2012
25 | *
26 | * A block which serves as a reference to an already created block.
27 | * Instances should therefore not be treated as 'definitions' of
28 | * blocks but rather containers of information related to an existing
29 | * block. Certain properties however, such as the {@link #getConstructor()},
30 | * are unique to each {@link BlockOutline}, including references.
31 | */
32 | public class BlockReference extends BlockOutline {
33 | private final BlockOutline directReference;
34 |
35 | public BlockReference(BlockOutline directReference) {
36 | this.directReference = checkNotNull(directReference);
37 | }
38 |
39 | public BlockReference(String name) {
40 | directReference = null;
41 | setName(name);
42 | }
43 |
44 | public BlockOutline directReference() {
45 | return directReference;
46 | }
47 | }
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/outline/GeneratorOutline.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.outline;
18 |
19 |
20 | /**
21 | * @author Ben Fagin
22 | * @version 03-07-2012
23 | */
24 | public class GeneratorOutline implements Outline {
25 | public String methodName = "create";
26 | public BlockOutline descriptorBlock;
27 |
28 | public GeneratorOutline(BlockOutline descriptorBlock) {
29 | this.descriptorBlock = descriptorBlock;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/unquietcode/tools/flapi/outline/Outline.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2014 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.outline;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 03-07-2012
22 | *
23 | * Marker interface for outlines.
24 | */
25 | public interface Outline {
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/resources/version/version.txt:
--------------------------------------------------------------------------------
1 | ${flapi.build.version}
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/AtLeast_T.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import org.junit.Test;
20 | import unquietcode.tools.flapi.builder.Descriptor.DescriptorGenerator;
21 | import unquietcode.tools.flapi.helpers.DescriptorHelperImpl;
22 | import unquietcode.tools.flapi.runtime.ExpectedInvocationsException;
23 |
24 | /**
25 | * @author Ben Fagin
26 | * @version 04-28-2012
27 | */
28 | public class AtLeast_T {
29 |
30 | /*
31 | A small test to ensure that exceptions are thrown when a minimum invocation
32 | is not reached.
33 | */
34 | @Test(expected = ExpectedInvocationsException.class)
35 | public void testAtLeast() {
36 | DescriptorGenerator.create(new DescriptorHelperImpl())
37 | .setPackage("some.package")
38 | .setStartingMethodName("create")
39 | //.setDescriptorName("something") // should trigger a failure
40 | .addMethod("done()").last()
41 | .build();
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/BlackHoleStream.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import java.io.IOException;
20 | import java.io.OutputStream;
21 |
22 | public final class BlackHoleStream extends OutputStream {
23 | public static final BlackHoleStream $ = new BlackHoleStream();
24 |
25 | @Override
26 | public final void write(int b) throws IOException {
27 | // nothing
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/ClassResolution_T.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import org.junit.Test;
20 |
21 | public class ClassResolution_T extends AbstractCompiledTest {
22 |
23 | @Test
24 | public void testImplicitPackage() {
25 | Descriptor descriptor = Flapi.builder()
26 | .setPackage("some.thing")
27 | .setDescriptorName("Something")
28 | .addMethod("method(Map variable)").last()
29 | .build();
30 |
31 | descriptor.writeToFolder(getTemporaryFolder());
32 | testCompile();
33 | }
34 |
35 | @Test
36 | public void testArrayType() {
37 | Descriptor descriptor = Flapi.builder()
38 | .setPackage("some.thing")
39 | .setDescriptorName("Something")
40 | .addMethod("method(byte[] variable)").last()
41 | .build();
42 |
43 | descriptor.writeToFolder(getTemporaryFolder());
44 |
45 | addTestClassMethod("Test",
46 | "some.thing.Something.SomethingGenerator.create(null)"
47 | + " .method(new byte[]{'a', 'b'})"
48 | + ";"
49 | );
50 |
51 | testCompile();
52 | }
53 | }
54 |
55 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/GenerateEverything.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import unquietcode.tools.flapi.examples.GenerateExamples;
20 |
21 | /**
22 | * @author Ben Fagin
23 | * @version 2013-07-01
24 | */
25 | public final class GenerateEverything {
26 |
27 | /*
28 | Regenerates the examples.
29 | */
30 | public static void main(String[] args) {
31 | String[] mainPath = new String[]{args[0]};
32 | String[] examplePath = new String[]{args[1]};
33 |
34 | GenerateExamples.main(examplePath);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/GroupedMethods_T.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import org.junit.Test;
20 |
21 | /**
22 | * @author Ben Fagin
23 | */
24 | public class GroupedMethods_T extends AbstractCompiledTest {
25 |
26 | @Test
27 | public void testGroupedAnyMethod() {
28 | Descriptor descriptor = Flapi.builder()
29 | .setDescriptorName("Something")
30 | .setPackage("something")
31 |
32 | .addMethod("regular()").any()
33 | .addMethod("terminal()").last()
34 |
35 | .addMethod("required1()").any(1)
36 | .addMethod("optional1()").atMost(2, 1)
37 |
38 | .addMethod("required2A()").any(2)
39 | .addMethod("required2B()").any(2)
40 | .build();
41 |
42 | descriptor.writeToFolder(getTemporaryFolder());
43 | testCompile();
44 |
45 | testCompile("GroupedTest1.avaj");
46 | testCompile("GroupedTest2.avaj");
47 | }
48 | }
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/LogMachineBuilderTest.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import org.junit.Test;
20 |
21 | /**
22 | * @author Ben Fagin
23 | * @version 09-05-2012
24 | */
25 | public class LogMachineBuilderTest extends AbstractCompiledTest {
26 |
27 | @Test
28 | public void test() {
29 | generateBuilder(getTemporaryFolder());
30 | testCompile();
31 | }
32 |
33 | private void generateBuilder(String folder) {
34 | Descriptor builder = Flapi.builder()
35 | .setPackage("unquietcode.tools.logmachine.builder")
36 | .setDescriptorName("LogMachine")
37 | .setStartingMethodName("start")
38 |
39 | .addMethod("from(String location)").exactly(1)
40 | .addMethod("to(Enum...categories)").exactly(1)
41 | .addMethod("because(Throwable cause)").exactly(1)
42 |
43 | .addMethod("debug(String message, Object...data)").last()
44 | .addMethod("info(String message, Object...data)").last()
45 | .addMethod("trace(String message, Object...data)").last()
46 | .addMethod("warn(String message, Object...data)").last()
47 | .addMethod("error(String message, Object...data)").last()
48 | .build();
49 |
50 | builder.writeToFolder(folder);
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/Naming_T.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi;
18 |
19 | import org.junit.Test;
20 |
21 | public class Naming_T extends AbstractCompiledTest {
22 |
23 | @Test
24 | public void test() {
25 | Descriptor descriptor = Flapi.builder()
26 | .setPackage("some.thing")
27 | .setDescriptorName("Something")
28 | .addMethod("method(int a, int b)").last()
29 | .addMethod("method(int a)").last()
30 | .build();
31 |
32 | descriptor.writeToFolder(getTemporaryFolder());
33 | testCompile();
34 | }
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/annotations/AnnotationBuilder_T.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.annotations;
18 |
19 | import org.junit.Test;
20 | import unquietcode.tools.flapi.DescriptorBuilderException;
21 | import unquietcode.tools.flapi.Flapi;
22 |
23 | /**
24 | * @author Ben Fagin
25 | * @version 2014-08-03
26 | */
27 | public class AnnotationBuilder_T {
28 |
29 | @Test(expected=DescriptorBuilderException.class)
30 | public void testThatOnlyLastMethodsCanReturnValues() {
31 | Flapi.create(MyHelper.class).build();
32 | }
33 |
34 | public interface MyHelper {
35 | @Any Integer one();
36 | @Last String two();
37 | }
38 |
39 | @Test(expected=DescriptorBuilderException.class)
40 | public void testThatOnlyOneAnnotationIsPermittedPerMethod() {
41 | Flapi.create(MultiHelper.class).build();
42 | }
43 |
44 | public interface MultiHelper {
45 | @Last
46 | @AtMost(1)
47 | void done();
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/GenerateExamples.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples;
18 |
19 | import unquietcode.tools.flapi.Descriptor;
20 | import unquietcode.tools.flapi.DescriptorMaker;
21 | import unquietcode.tools.flapi.examples.calculator.CalculatorBuilderExample;
22 | import unquietcode.tools.flapi.examples.email.EmailBuilderExample;
23 | import unquietcode.tools.flapi.examples.house.HouseBuilderExample;
24 | import unquietcode.tools.flapi.examples.pipes.PipedProcessExample;
25 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample;
26 | import unquietcode.tools.flapi.examples.xhtml.XHTMLBuilderExample;
27 |
28 | /**
29 | * @author Ben Fagin
30 | * @version 2013-07-01
31 | */
32 | public final class GenerateExamples {
33 |
34 | private static void generate(DescriptorMaker provider, String[] args) {
35 | Descriptor descriptor = provider.descriptor();
36 | descriptor.writeToFolder(args[0]);
37 | }
38 |
39 | /*
40 | Regenerates all of the examples.
41 | */
42 | public static void main(String[] args) {
43 | generate(new CalculatorBuilderExample(), args);
44 | generate(new EmailBuilderExample(), args);
45 | generate(new HouseBuilderExample(), args);
46 | generate(new PipedProcessExample(), args);
47 | generate(new DisappearingPizzaExample(), args);
48 | generate(new XHTMLBuilderExample(), args);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/Calculation.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.calculator;
18 |
19 | import unquietcode.tools.flapi.annotations.Any;
20 | import unquietcode.tools.flapi.annotations.Last;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 2014-08-05
25 | */
26 | public interface Calculation {
27 |
28 | @Any void plus(int value);
29 | @Any void minus(int value);
30 | @Any void times(int value);
31 | @Any void divide(int value);
32 | @Any void power(int value);
33 | @Any void mod(int value);
34 | @Any void abs();
35 |
36 | @Last CalculatorBuilderExample.Result equals();
37 | }
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/CalculationHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.calculator;
18 |
19 | import java.math.BigInteger;
20 |
21 | /**
22 | * @author Ben Fagin
23 | * @version 05-12-2012
24 | */
25 | public class CalculationHelperImpl implements Calculation {
26 | private final CalculatorBuilderExample.Result _value;
27 |
28 | public CalculationHelperImpl(CalculatorBuilderExample.Result value) {
29 | _value = value;
30 | }
31 |
32 | @Override
33 | public void plus(int value) {
34 | _value.set(_value.get().add(BigInteger.valueOf(value)));
35 | }
36 |
37 | @Override
38 | public void minus(int value) {
39 | _value.set(_value.get().subtract(BigInteger.valueOf(value)));
40 | }
41 |
42 | @Override
43 | public void times(int value) {
44 | _value.set(_value.get().multiply(BigInteger.valueOf(value)));
45 | }
46 |
47 | @Override
48 | public void divide(int value) {
49 | _value.set(_value.get().divide(BigInteger.valueOf(value)));
50 | }
51 |
52 | @Override
53 | public void mod(int value) {
54 | _value.set(_value.get().mod(BigInteger.valueOf(value)));
55 | }
56 |
57 | @Override
58 | public void power(int value) {
59 | _value.set(_value.get().pow(value));
60 | }
61 |
62 | @Override
63 | public void abs() {
64 | _value.set(_value.get().abs());
65 | }
66 |
67 | @Override
68 | public CalculatorBuilderExample.Result equals() {
69 | return _value;
70 | }
71 | }
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/Calculator.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.calculator;
18 |
19 | import unquietcode.tools.flapi.annotations.BlockChain;
20 | import unquietcode.tools.flapi.annotations.Last;
21 |
22 | import java.util.concurrent.atomic.AtomicReference;
23 |
24 | /**
25 | * @author Ben Fagin
26 | * @version 2014-08-05
27 | */
28 | public interface Calculator {
29 |
30 | @Last
31 | void $(int startingValue, @BlockChain AtomicReference helper);
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/CalculatorHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.calculator;
18 |
19 | import java.math.BigInteger;
20 | import java.util.concurrent.atomic.AtomicReference;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 05-12-2012
25 | */
26 | public class CalculatorHelperImpl implements Calculator {
27 | private final CalculatorBuilderExample.Result value = new CalculatorBuilderExample.Result();
28 |
29 | CalculatorHelperImpl() { }
30 |
31 | @Override
32 | public void $(int startingValue, AtomicReference _helper1) {
33 | _helper1.set(new CalculationHelperImpl(value));
34 | value.set(BigInteger.valueOf(startingValue));
35 | }
36 | }
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/builder/Calculation/CalculationBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.calculator.builder.Calculation;
3 |
4 | import javax.annotation.Generated;
5 |
6 |
7 | /**
8 | * This class was generated using Flapi, the fluent API generator for Java.
9 | * Modifications to this file will be lost upon regeneration.
10 | * You have been warned!
11 | *
12 | * Visit https://github.com/UnquietCode/Flapi for more information.
13 | *
14 | *
15 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
16 | */
17 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
18 | public interface CalculationBuilder {
19 |
20 | /**
21 | * Marker interface denoting the main entry point for this block.
22 | */
23 | public interface Head<_ReturnType>
24 | extends CalculationBuilder_2abs_2divide_2minus_2mod_2plus_2power_2times<_ReturnType>
25 | {
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/builder/Calculation/CalculationBuilder_2abs_2divide_2minus_2mod_2plus_2power_2times.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.calculator.builder.Calculation;
3 |
4 | import unquietcode.tools.flapi.examples.calculator.CalculatorBuilderExample.Result;
5 | import unquietcode.tools.flapi.examples.calculator.builder.Calculation.CalculationBuilder.Head;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.calculator.Calculation
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface CalculationBuilder_2abs_2divide_2minus_2mod_2plus_2power_2times<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Recursive)
26 | Head<_ReturnType> abs();
27 |
28 | @MethodInfo(type = TransitionType.Recursive)
29 | Head<_ReturnType> divide(int arg0);
30 |
31 | @MethodInfo(type = TransitionType.Terminal)
32 | Result equals();
33 |
34 | @MethodInfo(type = TransitionType.Recursive)
35 | Head<_ReturnType> minus(int arg0);
36 |
37 | @MethodInfo(type = TransitionType.Recursive)
38 | Head<_ReturnType> mod(int arg0);
39 |
40 | @MethodInfo(type = TransitionType.Recursive)
41 | Head<_ReturnType> plus(int arg0);
42 |
43 | @MethodInfo(type = TransitionType.Recursive)
44 | Head<_ReturnType> power(int arg0);
45 |
46 | @MethodInfo(type = TransitionType.Recursive)
47 | Head<_ReturnType> times(int arg0);
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/builder/Calculator/CalculatorBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.calculator.builder.Calculator;
3 |
4 | import unquietcode.tools.flapi.runtime.ChainInfo;
5 | import unquietcode.tools.flapi.runtime.MethodInfo;
6 | import unquietcode.tools.flapi.runtime.TransitionType;
7 |
8 | import javax.annotation.Generated;
9 |
10 |
11 | /**
12 | * This class was generated using Flapi, the fluent API generator for Java.
13 | * Modifications to this file will be lost upon regeneration.
14 | * You have been warned!
15 | *
16 | * Visit https://github.com/UnquietCode/Flapi for more information.
17 | *
18 | *
19 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
20 | */
21 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
22 | public interface CalculatorBuilder<_ReturnType> {
23 | @MethodInfo(type = TransitionType.Ascending, chainInfo = {
24 | @ChainInfo(type = unquietcode.tools.flapi.examples.calculator.builder.Calculation.CalculationBuilder.Head.class, position = 1)
25 | })
26 | unquietcode.tools.flapi.examples.calculator.builder.Calculation.CalculationBuilder.Head<_ReturnType> $(int arg0);
27 |
28 |
29 | /**
30 | * Marker interface denoting the main entry point for this block.
31 | */
32 | public interface Head<_ReturnType>
33 | extends CalculatorBuilder<_ReturnType>
34 | {
35 |
36 | }
37 |
38 |
39 | /**
40 | * Marker interface denoting the main entry point for this descriptor.
41 | */
42 | public interface Start
43 | extends CalculatorBuilder.Head
44 | {
45 |
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/builder/Calculator/CalculatorFactory.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.calculator.builder.Calculator;
3 |
4 | import unquietcode.tools.flapi.examples.calculator.builder.Calculator.CalculatorBuilder.Start;
5 |
6 | import javax.annotation.Generated;
7 |
8 |
9 | /**
10 | * This class was generated using Flapi, the fluent API generator for Java.
11 | * Modifications to this file will be lost upon regeneration.
12 | * You have been warned!
13 | *
14 | * Visit https://github.com/UnquietCode/Flapi for more information.
15 | *
16 | *
17 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
18 | */
19 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
20 | public interface CalculatorFactory {
21 | Start begin();
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/calculator/builder/Calculator/CalculatorGenerator.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.calculator.builder.Calculator;
3 |
4 | import unquietcode.tools.flapi.examples.calculator.Calculator;
5 | import unquietcode.tools.flapi.examples.calculator.builder.Calculator.CalculatorBuilder.Start;
6 | import unquietcode.tools.flapi.runtime.BlockInvocationHandler;
7 | import unquietcode.tools.flapi.runtime.ExecutionListener;
8 |
9 | import javax.annotation.Generated;
10 | import java.util.function.Supplier;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public class CalculatorGenerator {
25 | public static Start begin(Calculator helper, ExecutionListener... listeners) {
26 | if (helper == null) {
27 | throw new IllegalArgumentException("Helper cannot be null.");
28 | }
29 |
30 | BlockInvocationHandler handler = new BlockInvocationHandler(helper, null);
31 | handler.addListeners(listeners);
32 | return handler._proxy(Start.class);
33 | }
34 |
35 | public static CalculatorFactory factory(final Supplier provider, final ExecutionListener... listeners) {
36 | return new CalculatorFactory() {
37 | public Start begin() {
38 | Calculator helper = provider.get();
39 | return CalculatorGenerator.begin(helper, listeners);
40 | }
41 | };
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/email/AnnotatedEmailHelper.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.email;
18 |
19 | import unquietcode.tools.flapi.annotations.*;
20 |
21 | import java.io.File;
22 |
23 | /**
24 | * @author Ben Fagin
25 | * @version 2014-11-03
26 | */
27 | @Block(name="Email")
28 | public interface AnnotatedEmailHelper {
29 |
30 | @AtMost(1)
31 | void subject(String subject);
32 |
33 | @AtLeast(1)
34 | void addRecipient(String emailAddress);
35 |
36 | @Exactly(1)
37 | void sender(String emailAddress);
38 |
39 | @Any
40 | void addCC(String emailAddress);
41 |
42 | @Any
43 | void addBCC(String emailAddress);
44 |
45 | @AtMost(1)
46 | void body(String text);
47 |
48 | @Any
49 | void addAttachment(File file);
50 |
51 | @Last
52 | EmailMessage send();
53 | }
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/email/builder/Email/EmailBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.email.builder.Email;
3 |
4 | import javax.annotation.Generated;
5 |
6 |
7 | /**
8 | * This class was generated using Flapi, the fluent API generator for Java.
9 | * Modifications to this file will be lost upon regeneration.
10 | * You have been warned!
11 | *
12 | * Visit https://github.com/UnquietCode/Flapi for more information.
13 | *
14 | *
15 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
16 | */
17 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
18 | public interface EmailBuilder {
19 |
20 | /**
21 | * Marker interface denoting the main entry point for this block.
22 | */
23 | public interface Head<_ReturnType>
24 | extends EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient_2body_2sender_2subject<_ReturnType>
25 | {
26 |
27 | }
28 |
29 |
30 | /**
31 | * Marker interface denoting the main entry point for this descriptor.
32 | */
33 | public interface Start
34 | extends EmailBuilder.Head
35 | {
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/email/builder/Email/EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.email.builder.Email;
3 |
4 | import unquietcode.tools.flapi.examples.email.EmailMessage;
5 | import unquietcode.tools.flapi.runtime.MethodInfo;
6 | import unquietcode.tools.flapi.runtime.Tracked;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 | import java.io.File;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.email.builder.Email.EmailHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient<_ReturnType> {
26 | @MethodInfo(type = TransitionType.Recursive)
27 | EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient<_ReturnType> addAttachment(File file);
28 |
29 | @MethodInfo(type = TransitionType.Recursive)
30 | EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient<_ReturnType> addBCC(String emailAddress);
31 |
32 | @MethodInfo(type = TransitionType.Recursive)
33 | EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient<_ReturnType> addCC(String emailAddress);
34 |
35 | @MethodInfo(type = TransitionType.Recursive)
36 | @Tracked(atLeast = 1, key = "addRecipient_1String_emailAddre")
37 | EmailBuilder_2addAttachment_2addBCC_2addCC_2addRecipient<_ReturnType> addRecipient(String emailAddress);
38 |
39 | @MethodInfo(type = TransitionType.Terminal)
40 | EmailMessage send();
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/email/builder/Email/EmailFactory.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.email.builder.Email;
3 |
4 | import unquietcode.tools.flapi.examples.email.builder.Email.EmailBuilder.Start;
5 |
6 | import javax.annotation.Generated;
7 |
8 |
9 | /**
10 | * This class was generated using Flapi, the fluent API generator for Java.
11 | * Modifications to this file will be lost upon regeneration.
12 | * You have been warned!
13 | *
14 | * Visit https://github.com/UnquietCode/Flapi for more information.
15 | *
16 | *
17 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
18 | */
19 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
20 | public interface EmailFactory {
21 | Start compose();
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/email/builder/Email/EmailGenerator.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.email.builder.Email;
3 |
4 | import unquietcode.tools.flapi.examples.email.builder.Email.EmailBuilder.Start;
5 | import unquietcode.tools.flapi.runtime.BlockInvocationHandler;
6 | import unquietcode.tools.flapi.runtime.ExecutionListener;
7 |
8 | import javax.annotation.Generated;
9 | import java.util.function.Supplier;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public class EmailGenerator {
24 | public static Start compose(EmailHelper helper, ExecutionListener... listeners) {
25 | if (helper == null) {
26 | throw new IllegalArgumentException("Helper cannot be null.");
27 | }
28 |
29 | BlockInvocationHandler handler = new BlockInvocationHandler(helper, null);
30 | handler.addListeners(listeners);
31 | return handler._proxy(Start.class);
32 | }
33 |
34 | public static EmailFactory factory(final Supplier provider, final ExecutionListener... listeners) {
35 | return new EmailFactory() {
36 | public Start compose() {
37 | EmailHelper helper = provider.get();
38 | return EmailGenerator.compose(helper, listeners);
39 | }
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/email/builder/Email/EmailHelper.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.email.builder.Email;
3 |
4 | import unquietcode.tools.flapi.examples.email.EmailMessage;
5 |
6 | import javax.annotation.Generated;
7 | import java.io.File;
8 |
9 |
10 | /**
11 | * This class was generated using Flapi, the fluent API generator for Java.
12 | * Modifications to this file will be lost upon regeneration.
13 | * You have been warned!
14 | *
15 | * Visit https://github.com/UnquietCode/Flapi for more information.
16 | *
17 | *
18 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
19 | */
20 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
21 | public interface EmailHelper {
22 | void addAttachment(File file);
23 |
24 | void addBCC(String emailAddress);
25 |
26 | void addCC(String emailAddress);
27 |
28 | void addRecipient(String emailAddress);
29 |
30 | void body(String text);
31 |
32 | EmailMessage send();
33 |
34 | void sender(String emailAddress);
35 |
36 | void subject(String subject);
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/AffordableHouse.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.house;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 05-28-2012
22 | */
23 | public class AffordableHouse extends House {
24 | @Override
25 | String getCost() {
26 | return "$75,000.00";
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/ExpensiveHouse.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.house;
18 |
19 | /**
20 | * @author Ben Fagin
21 | * @version 05-28-2012
22 | */
23 | public class ExpensiveHouse extends House{
24 | @Override
25 | String getCost() {
26 | return "$2,100,000.00";
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/House.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.house;
18 |
19 | import java.util.List;
20 |
21 | /**
22 | * @author Ben Fagin
23 | * @version 05-28-2012
24 | */
25 | public abstract class House {
26 | private List walls;
27 |
28 |
29 | public List getWalls() {
30 | return walls;
31 | }
32 |
33 | public void setWalls(List walls) {
34 | this.walls = walls;
35 | }
36 |
37 | public String getShape() {
38 | switch (walls.size()) {
39 | case 0:
40 | case 1:
41 | case 2: return "Impossible! How is your house standing??";
42 | case 3: return "triangular";
43 | case 4: return "rectangular";
44 | case 5: return "pentagonal";
45 | case 6: return "hexagonal";
46 | case 7: return "heptagonal";
47 | case 8: return "octagonal";
48 | case 9: return "nonagonal";
49 | default: return "really big";
50 | }
51 | }
52 |
53 | abstract String getCost();
54 | }
55 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/HouseHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.house;
18 |
19 |
20 | import unquietcode.tools.flapi.examples.house.builder.House.HouseHelper;
21 | import unquietcode.tools.flapi.examples.house.builder.Wall.WallHelper;
22 |
23 | import java.util.ArrayList;
24 | import java.util.List;
25 | import java.util.concurrent.atomic.AtomicReference;
26 |
27 | /**
28 | * @author Ben Fagin
29 | * @version 05-28-2012
30 | */
31 | public class HouseHelperImpl implements HouseHelper {
32 | private List walls = new ArrayList();
33 |
34 | @Override
35 | public ExpensiveHouse constructExpensiveHouse() {
36 | ExpensiveHouse house = new ExpensiveHouse();
37 | house.setWalls(walls);
38 | return house;
39 | }
40 |
41 | @Override
42 | public AffordableHouse constructAffordableHouse() {
43 | AffordableHouse house = new AffordableHouse();
44 | house.setWalls(walls);
45 | return house;
46 | }
47 |
48 | @Override
49 | public Wall addWall(AtomicReference _helper1) {
50 | WallHelperImpl wallHelper = new WallHelperImpl();
51 | _helper1.set(wallHelper);
52 | walls.add(wallHelper.wall);
53 |
54 | return wallHelper.wall;
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/Wall.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.house;
18 |
19 | import java.awt.*;
20 |
21 | /**
22 | * @author Ben Fagin
23 | * @version 05-28-2012
24 | */
25 | public class Wall {
26 | private Color color;
27 | private double width;
28 | private boolean isWeightBearing;
29 |
30 | public Color getColor() {
31 | return color;
32 | }
33 |
34 | public void setColor(Color color) {
35 | this.color = color;
36 | }
37 |
38 | public double getWidth() {
39 | return width;
40 | }
41 |
42 | public void setWidth(double width) {
43 | this.width = width;
44 | }
45 |
46 | public void isWeightBearing(boolean value) {
47 | isWeightBearing = value;
48 | }
49 |
50 | public boolean isWeightBearing() {
51 | return isWeightBearing;
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/WallHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.house;
18 |
19 |
20 | import unquietcode.tools.flapi.examples.house.builder.Wall.WallHelper;
21 |
22 | import java.awt.*;
23 |
24 | /**
25 | * @author Ben Fagin
26 | * @version 05-28-2012
27 | */
28 | public class WallHelperImpl implements WallHelper {
29 | final Wall wall = new Wall();
30 |
31 | @Override
32 | public void setColor(Color color) {
33 | wall.setColor(color);
34 | }
35 |
36 | @Override
37 | public void setWidth(double inches) {
38 | wall.setWidth(inches);
39 | }
40 | }
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/House/HouseBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.House;
3 |
4 | import unquietcode.tools.flapi.examples.house.AffordableHouse;
5 | import unquietcode.tools.flapi.examples.house.ExpensiveHouse;
6 | import unquietcode.tools.flapi.examples.house.Wall;
7 | import unquietcode.tools.flapi.runtime.ChainInfo;
8 | import unquietcode.tools.flapi.runtime.MethodInfo;
9 | import unquietcode.tools.flapi.runtime.TransitionType;
10 |
11 | import javax.annotation.Generated;
12 |
13 |
14 | /**
15 | * This class was generated using Flapi, the fluent API generator for Java.
16 | * Modifications to this file will be lost upon regeneration.
17 | * You have been warned!
18 | *
19 | * Visit https://github.com/UnquietCode/Flapi for more information.
20 | *
21 | *
22 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface HouseBuilder<_ReturnType> {
26 | @MethodInfo(type = TransitionType.Terminal, chainInfo = {
27 | @ChainInfo(type = unquietcode.tools.flapi.examples.house.builder.Wall.WallBuilder.Head.class, position = 0)
28 | })
29 | unquietcode.tools.flapi.examples.house.builder.Wall.WallBuilder.Head addWall();
30 |
31 | @MethodInfo(type = TransitionType.Terminal)
32 | AffordableHouse constructAffordableHouse();
33 |
34 | @MethodInfo(type = TransitionType.Terminal)
35 | ExpensiveHouse constructExpensiveHouse();
36 |
37 |
38 | /**
39 | * Marker interface denoting the main entry point for this block.
40 | */
41 | public interface Head<_ReturnType>
42 | extends HouseBuilder<_ReturnType>
43 | {
44 |
45 | }
46 |
47 |
48 | /**
49 | * Marker interface denoting the main entry point for this descriptor.
50 | */
51 | public interface Start
52 | extends HouseBuilder.Head
53 | {
54 |
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/House/HouseFactory.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.House;
3 |
4 | import unquietcode.tools.flapi.examples.house.builder.House.HouseBuilder.Start;
5 |
6 | import javax.annotation.Generated;
7 |
8 |
9 | /**
10 | * This class was generated using Flapi, the fluent API generator for Java.
11 | * Modifications to this file will be lost upon regeneration.
12 | * You have been warned!
13 | *
14 | * Visit https://github.com/UnquietCode/Flapi for more information.
15 | *
16 | *
17 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
18 | */
19 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
20 | public interface HouseFactory {
21 | Start create();
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/House/HouseGenerator.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.House;
3 |
4 | import unquietcode.tools.flapi.examples.house.builder.House.HouseBuilder.Start;
5 | import unquietcode.tools.flapi.runtime.BlockInvocationHandler;
6 | import unquietcode.tools.flapi.runtime.ExecutionListener;
7 |
8 | import javax.annotation.Generated;
9 | import java.util.function.Supplier;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public class HouseGenerator {
24 | public static Start create(HouseHelper helper, ExecutionListener... listeners) {
25 | if (helper == null) {
26 | throw new IllegalArgumentException("Helper cannot be null.");
27 | }
28 |
29 | BlockInvocationHandler handler = new BlockInvocationHandler(helper, null);
30 | handler.addListeners(listeners);
31 | return handler._proxy(Start.class);
32 | }
33 |
34 | public static HouseFactory factory(final Supplier provider, final ExecutionListener... listeners) {
35 | return new HouseFactory() {
36 | public Start create() {
37 | HouseHelper helper = provider.get();
38 | return HouseGenerator.create(helper, listeners);
39 | }
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/House/HouseHelper.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.House;
3 |
4 | import unquietcode.tools.flapi.examples.house.AffordableHouse;
5 | import unquietcode.tools.flapi.examples.house.ExpensiveHouse;
6 | import unquietcode.tools.flapi.examples.house.Wall;
7 | import unquietcode.tools.flapi.examples.house.builder.Wall.WallHelper;
8 |
9 | import javax.annotation.Generated;
10 | import java.util.concurrent.atomic.AtomicReference;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface HouseHelper {
25 | Wall addWall(AtomicReference _helper1);
26 |
27 | AffordableHouse constructAffordableHouse();
28 |
29 | ExpensiveHouse constructExpensiveHouse();
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/Wall/WallBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.Wall;
3 |
4 | import javax.annotation.Generated;
5 |
6 |
7 | /**
8 | * This class was generated using Flapi, the fluent API generator for Java.
9 | * Modifications to this file will be lost upon regeneration.
10 | * You have been warned!
11 | *
12 | * Visit https://github.com/UnquietCode/Flapi for more information.
13 | *
14 | *
15 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
16 | */
17 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
18 | public interface WallBuilder {
19 |
20 | /**
21 | * Marker interface denoting the main entry point for this block.
22 | */
23 | public interface Head<_ReturnType>
24 | extends WallBuilder_2setColor_2setWidth<_ReturnType>
25 | {
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/Wall/WallBuilder_2setColor_2setWidth.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.Wall;
3 |
4 | import unquietcode.tools.flapi.runtime.MethodInfo;
5 | import unquietcode.tools.flapi.runtime.TransitionType;
6 |
7 | import javax.annotation.Generated;
8 | import java.awt.*;
9 |
10 |
11 | /**
12 | * This class was generated using Flapi, the fluent API generator for Java.
13 | * Modifications to this file will be lost upon regeneration.
14 | * You have been warned!
15 | *
16 | * Visit https://github.com/UnquietCode/Flapi for more information.
17 | *
18 | *
19 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
20 | * @see unquietcode.tools.flapi.examples.house.builder.Wall.WallHelper
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public interface WallBuilder_2setColor_2setWidth<_ReturnType> {
24 | @MethodInfo(type = TransitionType.Lateral)
25 | WallBuilder_2setWidth_5t<_ReturnType> setColor(Color color);
26 |
27 | @MethodInfo(type = TransitionType.Lateral)
28 | WallBuilder_2setColor_5t<_ReturnType> setWidth(double inches);
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/Wall/WallBuilder_2setColor_5t.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.Wall;
3 |
4 | import unquietcode.tools.flapi.examples.house.Wall;
5 | import unquietcode.tools.flapi.runtime.MethodInfo;
6 | import unquietcode.tools.flapi.runtime.TransitionType;
7 |
8 | import javax.annotation.Generated;
9 | import java.awt.*;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.house.builder.Wall.WallHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface WallBuilder_2setColor_5t<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Terminal)
26 | Wall setColor(Color color);
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/Wall/WallBuilder_2setWidth_5t.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.Wall;
3 |
4 | import unquietcode.tools.flapi.examples.house.Wall;
5 | import unquietcode.tools.flapi.runtime.MethodInfo;
6 | import unquietcode.tools.flapi.runtime.TransitionType;
7 |
8 | import javax.annotation.Generated;
9 |
10 |
11 | /**
12 | * This class was generated using Flapi, the fluent API generator for Java.
13 | * Modifications to this file will be lost upon regeneration.
14 | * You have been warned!
15 | *
16 | * Visit https://github.com/UnquietCode/Flapi for more information.
17 | *
18 | *
19 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
20 | * @see unquietcode.tools.flapi.examples.house.builder.Wall.WallHelper
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public interface WallBuilder_2setWidth_5t<_ReturnType> {
24 | @MethodInfo(type = TransitionType.Terminal)
25 | Wall setWidth(double inches);
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/house/builder/Wall/WallHelper.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.house.builder.Wall;
3 |
4 | import javax.annotation.Generated;
5 | import java.awt.*;
6 |
7 |
8 | /**
9 | * This class was generated using Flapi, the fluent API generator for Java.
10 | * Modifications to this file will be lost upon regeneration.
11 | * You have been warned!
12 | *
13 | * Visit https://github.com/UnquietCode/Flapi for more information.
14 | *
15 | *
16 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
17 | */
18 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
19 | public interface WallHelper {
20 | void setColor(Color color);
21 |
22 | void setWidth(double inches);
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pipes/builder/Process/ProcessBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pipes.builder.Process;
3 |
4 | import javax.annotation.Generated;
5 |
6 |
7 | /**
8 | * This class was generated using Flapi, the fluent API generator for Java.
9 | * Modifications to this file will be lost upon regeneration.
10 | * You have been warned!
11 | *
12 | * Visit https://github.com/UnquietCode/Flapi for more information.
13 | *
14 | *
15 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
16 | */
17 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
18 | public interface ProcessBuilder {
19 |
20 | /**
21 | * Marker interface denoting the main entry point for this block.
22 | */
23 | public interface Head<_ReturnType>
24 | extends ProcessBuilder_2addArgument_2addArgument_1A_2withProcess<_ReturnType>
25 | {
26 |
27 | }
28 |
29 |
30 | /**
31 | * Marker interface denoting the main entry point for this descriptor.
32 | */
33 | public interface Start
34 | extends ProcessBuilder.Head
35 | {
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pipes/builder/Process/ProcessBuilder_2addArgument_2addArgument_1A_2pipe.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pipes.builder.Process;
3 |
4 | import unquietcode.tools.flapi.examples.pipes.builder.Process.ProcessBuilder.Head;
5 | import unquietcode.tools.flapi.runtime.ChainInfo;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 | import java.io.InputStream;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.pipes.builder.Process.ProcessHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface ProcessBuilder_2addArgument_2addArgument_1A_2pipe<_ReturnType> {
26 | @MethodInfo(type = TransitionType.Recursive)
27 | ProcessBuilder_2addArgument_2addArgument_1A_2pipe<_ReturnType> addArgument(String argument);
28 |
29 | @MethodInfo(type = TransitionType.Recursive)
30 | ProcessBuilder_2addArgument_2addArgument_1A_2pipe<_ReturnType> addArgument(String name, String value);
31 |
32 | @MethodInfo(type = TransitionType.Ascending, chainInfo = {
33 | @ChainInfo(type = Head.class, position = 0)
34 | })
35 | Head<_ReturnType> pipe();
36 |
37 | @MethodInfo(type = TransitionType.Terminal)
38 | InputStream run();
39 | }
40 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pipes/builder/Process/ProcessBuilder_2addArgument_2addArgument_1A_2withProcess.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pipes.builder.Process;
3 |
4 | import unquietcode.tools.flapi.examples.pipes.builder.Process.ProcessBuilder.Head;
5 | import unquietcode.tools.flapi.runtime.ChainInfo;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.Tracked;
8 | import unquietcode.tools.flapi.runtime.TransitionType;
9 |
10 | import javax.annotation.Generated;
11 | import java.io.InputStream;
12 |
13 |
14 | /**
15 | * This class was generated using Flapi, the fluent API generator for Java.
16 | * Modifications to this file will be lost upon regeneration.
17 | * You have been warned!
18 | *
19 | * Visit https://github.com/UnquietCode/Flapi for more information.
20 | *
21 | *
22 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
23 | * @see unquietcode.tools.flapi.examples.pipes.builder.Process.ProcessHelper
24 | */
25 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
26 | public interface ProcessBuilder_2addArgument_2addArgument_1A_2withProcess<_ReturnType> {
27 | @MethodInfo(type = TransitionType.Recursive)
28 | Head<_ReturnType> addArgument(String argument);
29 |
30 | @MethodInfo(type = TransitionType.Recursive)
31 | Head<_ReturnType> addArgument(String name, String value);
32 |
33 | @MethodInfo(type = TransitionType.Ascending, chainInfo = {
34 | @ChainInfo(type = Head.class, position = 0)
35 | })
36 | Head<_ReturnType> pipe();
37 |
38 | @MethodInfo(type = TransitionType.Terminal)
39 | InputStream run();
40 |
41 | @MethodInfo(type = TransitionType.Lateral)
42 | @Tracked(atLeast = 1, key = "withProcess_1String_na")
43 | ProcessBuilder_2addArgument_2addArgument_1A_2pipe<_ReturnType> withProcess(String name);
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pipes/builder/Process/ProcessFactory.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pipes.builder.Process;
3 |
4 | import unquietcode.tools.flapi.examples.pipes.builder.Process.ProcessBuilder.Start;
5 |
6 | import javax.annotation.Generated;
7 |
8 |
9 | /**
10 | * This class was generated using Flapi, the fluent API generator for Java.
11 | * Modifications to this file will be lost upon regeneration.
12 | * You have been warned!
13 | *
14 | * Visit https://github.com/UnquietCode/Flapi for more information.
15 | *
16 | *
17 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
18 | */
19 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
20 | public interface ProcessFactory {
21 | Start begin();
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pipes/builder/Process/ProcessGenerator.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pipes.builder.Process;
3 |
4 | import unquietcode.tools.flapi.examples.pipes.builder.Process.ProcessBuilder.Start;
5 | import unquietcode.tools.flapi.runtime.BlockInvocationHandler;
6 | import unquietcode.tools.flapi.runtime.ExecutionListener;
7 |
8 | import javax.annotation.Generated;
9 | import java.util.function.Supplier;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public class ProcessGenerator {
24 | public static Start begin(ProcessHelper helper, ExecutionListener... listeners) {
25 | if (helper == null) {
26 | throw new IllegalArgumentException("Helper cannot be null.");
27 | }
28 |
29 | BlockInvocationHandler handler = new BlockInvocationHandler(helper, null);
30 | handler.addListeners(listeners);
31 | return handler._proxy(Start.class);
32 | }
33 |
34 | public static ProcessFactory factory(final Supplier provider, final ExecutionListener... listeners) {
35 | return new ProcessFactory() {
36 | public Start begin() {
37 | ProcessHelper helper = provider.get();
38 | return ProcessGenerator.begin(helper, listeners);
39 | }
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pipes/builder/Process/ProcessHelper.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pipes.builder.Process;
3 |
4 | import javax.annotation.Generated;
5 | import java.io.InputStream;
6 | import java.util.concurrent.atomic.AtomicReference;
7 |
8 |
9 | /**
10 | * This class was generated using Flapi, the fluent API generator for Java.
11 | * Modifications to this file will be lost upon regeneration.
12 | * You have been warned!
13 | *
14 | * Visit https://github.com/UnquietCode/Flapi for more information.
15 | *
16 | *
17 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
18 | */
19 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
20 | public interface ProcessHelper {
21 | void addArgument(String argument);
22 |
23 | void addArgument(String name, String value);
24 |
25 | void pipe(AtomicReference _helper1);
26 |
27 | InputStream run();
28 |
29 | void withProcess(String name);
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/PizzaHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.pizza;
18 |
19 |
20 | import unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper;
21 |
22 | /**
23 | * @author Ben Fagin
24 | * @version 04-28-2012
25 | */
26 | public class PizzaHelperImpl implements PizzaHelper {
27 | private final DisappearingPizzaExample.Pizza pizza = new DisappearingPizzaExample.Pizza();
28 |
29 | @Override
30 | public void addSauce(DisappearingPizzaExample.SauceType sauceType) {
31 | pizza.sauce = sauceType;
32 | }
33 |
34 | @Override
35 | public void addTopping(DisappearingPizzaExample.Topping topping) {
36 | pizza.toppings.add(topping);
37 | }
38 |
39 | @Override
40 | public void addCheese() {
41 | pizza.hasCheese = true;
42 | }
43 |
44 | @Override
45 | public DisappearingPizzaExample.Pizza bake() {
46 | new Thread() {
47 | int time = 0;
48 |
49 | public @Override void run() {
50 | while (true) {
51 | if (time++ == 3) {
52 | System.out.println("done\n");
53 | break;
54 | }
55 |
56 | System.out.println("baking...");
57 | try {
58 | sleep(1000);
59 | } catch (InterruptedException ex) {
60 | throw new RuntimeException(ex);
61 | }
62 | }
63 | }
64 | }.run();
65 |
66 | return pizza;
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.runtime.MethodInfo;
6 | import unquietcode.tools.flapi.runtime.TransitionType;
7 |
8 | import javax.annotation.Generated;
9 |
10 |
11 | /**
12 | * This class was generated using Flapi, the fluent API generator for Java.
13 | * Modifications to this file will be lost upon regeneration.
14 | * You have been warned!
15 | *
16 | * Visit https://github.com/UnquietCode/Flapi for more information.
17 | *
18 | *
19 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
20 | */
21 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
22 | public interface PizzaBuilder<_ReturnType> {
23 | @MethodInfo(type = TransitionType.Terminal)
24 | Pizza bake();
25 |
26 |
27 | /**
28 | * Marker interface denoting the main entry point for this block.
29 | */
30 | public interface Head<_ReturnType>
31 | extends PizzaBuilder_2addCheese_2addSauce_2addTopping_33 <_ReturnType>
32 | {
33 |
34 | }
35 |
36 |
37 | /**
38 | * Marker interface denoting the main entry point for this descriptor.
39 | */
40 | public interface Start
41 | extends PizzaBuilder.Head
42 | {
43 |
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.runtime.MethodInfo;
6 | import unquietcode.tools.flapi.runtime.TransitionType;
7 |
8 | import javax.annotation.Generated;
9 |
10 |
11 | /**
12 | * This class was generated using Flapi, the fluent API generator for Java.
13 | * Modifications to this file will be lost upon regeneration.
14 | * You have been warned!
15 | *
16 | * Visit https://github.com/UnquietCode/Flapi for more information.
17 | *
18 | *
19 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
20 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public interface PizzaBuilder_2addCheese<_ReturnType> {
24 | @MethodInfo(type = TransitionType.Lateral)
25 | PizzaBuilder<_ReturnType> addCheese();
26 |
27 | @MethodInfo(type = TransitionType.Terminal)
28 | Pizza bake();
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese_2addSauce.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addCheese_2addSauce<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder_2addSauce<_ReturnType> addCheese();
27 |
28 | @MethodInfo(type = TransitionType.Lateral)
29 | PizzaBuilder_2addCheese<_ReturnType> addSauce(SauceType sauceType);
30 |
31 | @MethodInfo(type = TransitionType.Terminal)
32 | Pizza bake();
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese_2addSauce_2addTopping.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
7 | import unquietcode.tools.flapi.runtime.MethodInfo;
8 | import unquietcode.tools.flapi.runtime.TransitionType;
9 |
10 | import javax.annotation.Generated;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface PizzaBuilder_2addCheese_2addSauce_2addTopping<_ReturnType> {
26 | @MethodInfo(type = TransitionType.Lateral)
27 | PizzaBuilder_2addSauce_2addTopping<_ReturnType> addCheese();
28 |
29 | @MethodInfo(type = TransitionType.Lateral)
30 | PizzaBuilder_2addCheese_2addTopping<_ReturnType> addSauce(SauceType sauceType);
31 |
32 | @MethodInfo(type = TransitionType.Lateral)
33 | PizzaBuilder_2addCheese_2addSauce<_ReturnType> addTopping(Topping topping);
34 |
35 | @MethodInfo(type = TransitionType.Terminal)
36 | Pizza bake();
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese_2addSauce_2addTopping_32.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
7 | import unquietcode.tools.flapi.runtime.MethodInfo;
8 | import unquietcode.tools.flapi.runtime.TransitionType;
9 |
10 | import javax.annotation.Generated;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface PizzaBuilder_2addCheese_2addSauce_2addTopping_32 <_ReturnType> {
26 | @MethodInfo(type = TransitionType.Lateral)
27 | PizzaBuilder_2addSauce_2addTopping_32 <_ReturnType> addCheese();
28 |
29 | @MethodInfo(type = TransitionType.Lateral)
30 | PizzaBuilder_2addCheese_2addTopping_32 <_ReturnType> addSauce(SauceType sauceType);
31 |
32 | @MethodInfo(type = TransitionType.Lateral)
33 | PizzaBuilder_2addCheese_2addSauce_2addTopping<_ReturnType> addTopping(Topping topping);
34 |
35 | @MethodInfo(type = TransitionType.Terminal)
36 | Pizza bake();
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese_2addSauce_2addTopping_33.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
7 | import unquietcode.tools.flapi.runtime.MethodInfo;
8 | import unquietcode.tools.flapi.runtime.TransitionType;
9 |
10 | import javax.annotation.Generated;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface PizzaBuilder_2addCheese_2addSauce_2addTopping_33 <_ReturnType> {
26 | @MethodInfo(type = TransitionType.Lateral)
27 | PizzaBuilder_2addSauce_2addTopping_33 <_ReturnType> addCheese();
28 |
29 | @MethodInfo(type = TransitionType.Lateral)
30 | PizzaBuilder_2addCheese_2addTopping_33 <_ReturnType> addSauce(SauceType sauceType);
31 |
32 | @MethodInfo(type = TransitionType.Lateral)
33 | PizzaBuilder_2addCheese_2addSauce_2addTopping_32 <_ReturnType> addTopping(Topping topping);
34 |
35 | @MethodInfo(type = TransitionType.Terminal)
36 | Pizza bake();
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese_2addTopping.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addCheese_2addTopping<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder_2addTopping<_ReturnType> addCheese();
27 |
28 | @MethodInfo(type = TransitionType.Lateral)
29 | PizzaBuilder_2addCheese<_ReturnType> addTopping(Topping topping);
30 |
31 | @MethodInfo(type = TransitionType.Terminal)
32 | Pizza bake();
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese_2addTopping_32.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addCheese_2addTopping_32 <_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder_2addTopping_32 <_ReturnType> addCheese();
27 |
28 | @MethodInfo(type = TransitionType.Lateral)
29 | PizzaBuilder_2addCheese_2addTopping<_ReturnType> addTopping(Topping topping);
30 |
31 | @MethodInfo(type = TransitionType.Terminal)
32 | Pizza bake();
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addCheese_2addTopping_33.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addCheese_2addTopping_33 <_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder_2addTopping_33 <_ReturnType> addCheese();
27 |
28 | @MethodInfo(type = TransitionType.Lateral)
29 | PizzaBuilder_2addCheese_2addTopping_32 <_ReturnType> addTopping(Topping topping);
30 |
31 | @MethodInfo(type = TransitionType.Terminal)
32 | Pizza bake();
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addSauce.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addSauce<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder<_ReturnType> addSauce(SauceType sauceType);
27 |
28 | @MethodInfo(type = TransitionType.Terminal)
29 | Pizza bake();
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addSauce_2addTopping.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
7 | import unquietcode.tools.flapi.runtime.MethodInfo;
8 | import unquietcode.tools.flapi.runtime.TransitionType;
9 |
10 | import javax.annotation.Generated;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface PizzaBuilder_2addSauce_2addTopping<_ReturnType> {
26 | @MethodInfo(type = TransitionType.Lateral)
27 | PizzaBuilder_2addTopping<_ReturnType> addSauce(SauceType sauceType);
28 |
29 | @MethodInfo(type = TransitionType.Lateral)
30 | PizzaBuilder_2addSauce<_ReturnType> addTopping(Topping topping);
31 |
32 | @MethodInfo(type = TransitionType.Terminal)
33 | Pizza bake();
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addSauce_2addTopping_32.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
7 | import unquietcode.tools.flapi.runtime.MethodInfo;
8 | import unquietcode.tools.flapi.runtime.TransitionType;
9 |
10 | import javax.annotation.Generated;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface PizzaBuilder_2addSauce_2addTopping_32 <_ReturnType> {
26 | @MethodInfo(type = TransitionType.Lateral)
27 | PizzaBuilder_2addTopping_32 <_ReturnType> addSauce(SauceType sauceType);
28 |
29 | @MethodInfo(type = TransitionType.Lateral)
30 | PizzaBuilder_2addSauce_2addTopping<_ReturnType> addTopping(Topping topping);
31 |
32 | @MethodInfo(type = TransitionType.Terminal)
33 | Pizza bake();
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addSauce_2addTopping_33.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
7 | import unquietcode.tools.flapi.runtime.MethodInfo;
8 | import unquietcode.tools.flapi.runtime.TransitionType;
9 |
10 | import javax.annotation.Generated;
11 |
12 |
13 | /**
14 | * This class was generated using Flapi, the fluent API generator for Java.
15 | * Modifications to this file will be lost upon regeneration.
16 | * You have been warned!
17 | *
18 | * Visit https://github.com/UnquietCode/Flapi for more information.
19 | *
20 | *
21 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
22 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
23 | */
24 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
25 | public interface PizzaBuilder_2addSauce_2addTopping_33 <_ReturnType> {
26 | @MethodInfo(type = TransitionType.Lateral)
27 | PizzaBuilder_2addTopping_33 <_ReturnType> addSauce(SauceType sauceType);
28 |
29 | @MethodInfo(type = TransitionType.Lateral)
30 | PizzaBuilder_2addSauce_2addTopping_32 <_ReturnType> addTopping(Topping topping);
31 |
32 | @MethodInfo(type = TransitionType.Terminal)
33 | Pizza bake();
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addTopping.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addTopping<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder<_ReturnType> addTopping(Topping topping);
27 |
28 | @MethodInfo(type = TransitionType.Terminal)
29 | Pizza bake();
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addTopping_32.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addTopping_32 <_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder_2addTopping<_ReturnType> addTopping(Topping topping);
27 |
28 | @MethodInfo(type = TransitionType.Terminal)
29 | Pizza bake();
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaBuilder_2addTopping_33.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface PizzaBuilder_2addTopping_33 <_ReturnType> {
25 | @MethodInfo(type = TransitionType.Lateral)
26 | PizzaBuilder_2addTopping_32 <_ReturnType> addTopping(Topping topping);
27 |
28 | @MethodInfo(type = TransitionType.Terminal)
29 | Pizza bake();
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaFactory.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaBuilder.Start;
5 |
6 | import javax.annotation.Generated;
7 |
8 |
9 | /**
10 | * This class was generated using Flapi, the fluent API generator for Java.
11 | * Modifications to this file will be lost upon regeneration.
12 | * You have been warned!
13 | *
14 | * Visit https://github.com/UnquietCode/Flapi for more information.
15 | *
16 | *
17 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
18 | */
19 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
20 | public interface PizzaFactory {
21 | Start makePizza();
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaGenerator.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.builder.Pizza.PizzaBuilder.Start;
5 | import unquietcode.tools.flapi.runtime.BlockInvocationHandler;
6 | import unquietcode.tools.flapi.runtime.ExecutionListener;
7 |
8 | import javax.annotation.Generated;
9 | import java.util.function.Supplier;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public class PizzaGenerator {
24 | public static Start makePizza(PizzaHelper helper, ExecutionListener... listeners) {
25 | if (helper == null) {
26 | throw new IllegalArgumentException("Helper cannot be null.");
27 | }
28 |
29 | BlockInvocationHandler handler = new BlockInvocationHandler(helper, null);
30 | handler.addListeners(listeners);
31 | return handler._proxy(Start.class);
32 | }
33 |
34 | public static PizzaFactory factory(final Supplier provider, final ExecutionListener... listeners) {
35 | return new PizzaFactory() {
36 | public Start makePizza() {
37 | PizzaHelper helper = provider.get();
38 | return PizzaGenerator.makePizza(helper, listeners);
39 | }
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/pizza/builder/Pizza/PizzaHelper.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.pizza.builder.Pizza;
3 |
4 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Pizza;
5 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.SauceType;
6 | import unquietcode.tools.flapi.examples.pizza.DisappearingPizzaExample.Topping;
7 |
8 | import javax.annotation.Generated;
9 |
10 |
11 | /**
12 | * This class was generated using Flapi, the fluent API generator for Java.
13 | * Modifications to this file will be lost upon regeneration.
14 | * You have been warned!
15 | *
16 | * Visit https://github.com/UnquietCode/Flapi for more information.
17 | *
18 | *
19 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
20 | */
21 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
22 | public interface PizzaHelper {
23 | void addCheese();
24 |
25 | void addSauce(SauceType sauceType);
26 |
27 | void addTopping(Topping topping);
28 |
29 | Pizza bake();
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/ElementHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.xhtml;
18 |
19 | import org.w3c.dom.Comment;
20 | import org.w3c.dom.Element;
21 | import unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementHelper;
22 |
23 | import java.util.concurrent.atomic.AtomicReference;
24 |
25 | /*
26 | * @author Ben Fagin
27 | * @version 04-27-2012
28 | */
29 | public class ElementHelperImpl implements ElementHelper {
30 | private final Element element;
31 |
32 | ElementHelperImpl(Element element) {
33 | this.element = element;
34 | }
35 |
36 | @Override
37 | public void endElement() {
38 | // nothing
39 | }
40 |
41 | @Override
42 | public void startElement(String tagName, AtomicReference _helper1) {
43 | Element newElement = element.getOwnerDocument().createElement(tagName);
44 | element.appendChild(newElement);
45 | _helper1.set(new ElementHelperImpl(newElement));
46 | }
47 |
48 | @Override
49 | public void addAttribute(String key, String value) {
50 | element.setAttribute(key, value);
51 | }
52 |
53 | @Override
54 | public void addComment(String comment) {
55 | Comment commentNode = element.getOwnerDocument().createComment(comment);
56 | element.appendChild(commentNode);
57 | }
58 |
59 | @Override
60 | public void setValue(String value) {
61 | element.setTextContent(value);
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/XHTMLHelperImpl.java:
--------------------------------------------------------------------------------
1 | /*********************************************************************
2 | Copyright 2015 the Flapi authors
3 |
4 | Licensed under the Apache License, Version 2.0 (the "License");
5 | you may not use this file except in compliance with the License.
6 | You may obtain a copy of the License at
7 |
8 | http://www.apache.org/licenses/LICENSE-2.0
9 |
10 | Unless required by applicable law or agreed to in writing, software
11 | distributed under the License is distributed on an "AS IS" BASIS,
12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | See the License for the specific language governing permissions and
14 | limitations under the License.
15 | ********************************************************************/
16 |
17 | package unquietcode.tools.flapi.examples.xhtml;
18 |
19 | import org.w3c.dom.Document;
20 | import org.w3c.dom.Element;
21 | import unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementHelper;
22 | import unquietcode.tools.flapi.examples.xhtml.builder.XHTML.XHTMLHelper;
23 |
24 | import javax.xml.parsers.DocumentBuilderFactory;
25 | import java.util.concurrent.atomic.AtomicReference;
26 |
27 | /**
28 | *
29 | * @author Ben Fagin
30 | * @version 04-27-2012
31 | */
32 | public class XHTMLHelperImpl implements XHTMLHelper {
33 | final Document document;
34 |
35 | public XHTMLHelperImpl() {
36 | try {
37 | document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
38 | } catch (Exception ex) {
39 | throw new RuntimeException(ex);
40 | }
41 | }
42 |
43 | @Override
44 | public Document done() {
45 | return document;
46 | }
47 |
48 | @Override
49 | public void startElement(String tagName, AtomicReference _helper1) {
50 | Element element = document.createElement(tagName);
51 | document.appendChild(element);
52 | _helper1.set(new ElementHelperImpl(element));
53 | }
54 |
55 |
56 | @Override
57 | public void addComment(String comment) {
58 | document.appendChild(document.createComment(comment));
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/Element/ElementBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.Element;
3 |
4 | import javax.annotation.Generated;
5 |
6 |
7 | /**
8 | * This class was generated using Flapi, the fluent API generator for Java.
9 | * Modifications to this file will be lost upon regeneration.
10 | * You have been warned!
11 | *
12 | * Visit https://github.com/UnquietCode/Flapi for more information.
13 | *
14 | *
15 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
16 | */
17 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
18 | public interface ElementBuilder {
19 |
20 | /**
21 | * Marker interface denoting the main entry point for this block.
22 | */
23 | public interface Head<_ReturnType>
24 | extends ElementBuilder_2addAttribute_2addComment_2setValue_2startElement<_ReturnType>
25 | {
26 |
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/Element/ElementBuilder_2addAttribute_2addComment_2endElement_2startElement.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.Element;
3 |
4 | import unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementBuilder.Head;
5 | import unquietcode.tools.flapi.runtime.ChainInfo;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface ElementBuilder_2addAttribute_2addComment_2endElement_2startElement<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Recursive)
26 | ElementBuilder_2addAttribute_2addComment_2endElement_2startElement<_ReturnType> addAttribute(String key, String value);
27 |
28 | @MethodInfo(type = TransitionType.Recursive)
29 | ElementBuilder_2addAttribute_2addComment_2endElement_2startElement<_ReturnType> addComment(String comment);
30 |
31 | @MethodInfo(type = TransitionType.Ascending)
32 | _ReturnType endElement();
33 |
34 | @MethodInfo(type = TransitionType.Recursive, chainInfo = {
35 | @ChainInfo(type = Head.class, position = 1)
36 | })
37 | Head> startElement(String tagName);
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/Element/ElementBuilder_2addAttribute_2addComment_2setValue_2startElement.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.Element;
3 |
4 | import unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementBuilder.Head;
5 | import unquietcode.tools.flapi.runtime.ChainInfo;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface ElementBuilder_2addAttribute_2addComment_2setValue_2startElement<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Recursive)
26 | Head<_ReturnType> addAttribute(String key, String value);
27 |
28 | @MethodInfo(type = TransitionType.Recursive)
29 | Head<_ReturnType> addComment(String comment);
30 |
31 | @MethodInfo(type = TransitionType.Ascending)
32 | _ReturnType endElement();
33 |
34 | @MethodInfo(type = TransitionType.Lateral)
35 | ElementBuilder_2addAttribute_2addComment_2endElement_2startElement<_ReturnType> setValue(String value);
36 |
37 | @MethodInfo(type = TransitionType.Recursive, chainInfo = {
38 | @ChainInfo(type = Head.class, position = 1)
39 | })
40 | Head> startElement(String tagName);
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/Element/ElementHelper.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.Element;
3 |
4 | import javax.annotation.Generated;
5 | import java.util.concurrent.atomic.AtomicReference;
6 |
7 |
8 | /**
9 | * This class was generated using Flapi, the fluent API generator for Java.
10 | * Modifications to this file will be lost upon regeneration.
11 | * You have been warned!
12 | *
13 | * Visit https://github.com/UnquietCode/Flapi for more information.
14 | *
15 | *
16 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
17 | */
18 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
19 | public interface ElementHelper {
20 | void addAttribute(String key, String value);
21 |
22 | void addComment(String comment);
23 |
24 | void endElement();
25 |
26 | void setValue(String value);
27 |
28 | void startElement(String tagName, AtomicReference _helper1);
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/XHTML/XHTMLBuilder.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.XHTML;
3 |
4 | import javax.annotation.Generated;
5 |
6 |
7 | /**
8 | * This class was generated using Flapi, the fluent API generator for Java.
9 | * Modifications to this file will be lost upon regeneration.
10 | * You have been warned!
11 | *
12 | * Visit https://github.com/UnquietCode/Flapi for more information.
13 | *
14 | *
15 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
16 | */
17 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
18 | public interface XHTMLBuilder {
19 |
20 | /**
21 | * Marker interface denoting the main entry point for this block.
22 | */
23 | public interface Head<_ReturnType>
24 | extends XHTMLBuilder_2addComment_2startElement<_ReturnType>
25 | {
26 |
27 | }
28 |
29 |
30 | /**
31 | * Marker interface denoting the main entry point for this descriptor.
32 | */
33 | public interface Start
34 | extends XHTMLBuilder.Head
35 | {
36 |
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/XHTML/XHTMLBuilder_2addComment_2startElement.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.XHTML;
3 |
4 | import org.w3c.dom.Document;
5 | import unquietcode.tools.flapi.runtime.ChainInfo;
6 | import unquietcode.tools.flapi.runtime.MethodInfo;
7 | import unquietcode.tools.flapi.runtime.TransitionType;
8 |
9 | import javax.annotation.Generated;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | * @see unquietcode.tools.flapi.examples.xhtml.builder.XHTML.XHTMLHelper
22 | */
23 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
24 | public interface XHTMLBuilder_2addComment_2startElement<_ReturnType> {
25 | @MethodInfo(type = TransitionType.Recursive)
26 | unquietcode.tools.flapi.examples.xhtml.builder.XHTML.XHTMLBuilder.Head<_ReturnType> addComment(String comment);
27 |
28 | @MethodInfo(type = TransitionType.Terminal)
29 | Document done();
30 |
31 | @MethodInfo(type = TransitionType.Recursive, chainInfo = {
32 | @ChainInfo(type = unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementBuilder.Head.class, position = 1)
33 | })
34 | unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementBuilder.Head> startElement(String tagName);
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/XHTML/XHTMLFactory.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.XHTML;
3 |
4 | import unquietcode.tools.flapi.examples.xhtml.builder.XHTML.XHTMLBuilder.Start;
5 |
6 | import javax.annotation.Generated;
7 |
8 |
9 | /**
10 | * This class was generated using Flapi, the fluent API generator for Java.
11 | * Modifications to this file will be lost upon regeneration.
12 | * You have been warned!
13 | *
14 | * Visit https://github.com/UnquietCode/Flapi for more information.
15 | *
16 | *
17 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
18 | */
19 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
20 | public interface XHTMLFactory {
21 | Start createDocument();
22 | }
23 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/XHTML/XHTMLGenerator.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.XHTML;
3 |
4 | import unquietcode.tools.flapi.examples.xhtml.builder.XHTML.XHTMLBuilder.Start;
5 | import unquietcode.tools.flapi.runtime.BlockInvocationHandler;
6 | import unquietcode.tools.flapi.runtime.ExecutionListener;
7 |
8 | import javax.annotation.Generated;
9 | import java.util.function.Supplier;
10 |
11 |
12 | /**
13 | * This class was generated using Flapi, the fluent API generator for Java.
14 | * Modifications to this file will be lost upon regeneration.
15 | * You have been warned!
16 | *
17 | * Visit https://github.com/UnquietCode/Flapi for more information.
18 | *
19 | *
20 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
21 | */
22 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
23 | public class XHTMLGenerator {
24 | public static Start createDocument(XHTMLHelper helper, ExecutionListener... listeners) {
25 | if (helper == null) {
26 | throw new IllegalArgumentException("Helper cannot be null.");
27 | }
28 |
29 | BlockInvocationHandler handler = new BlockInvocationHandler(helper, null);
30 | handler.addListeners(listeners);
31 | return handler._proxy(Start.class);
32 | }
33 |
34 | public static XHTMLFactory factory(final Supplier provider, final ExecutionListener... listeners) {
35 | return new XHTMLFactory() {
36 | public Start createDocument() {
37 | XHTMLHelper helper = provider.get();
38 | return XHTMLGenerator.createDocument(helper, listeners);
39 | }
40 | };
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/unquietcode/tools/flapi/examples/xhtml/builder/XHTML/XHTMLHelper.java:
--------------------------------------------------------------------------------
1 |
2 | package unquietcode.tools.flapi.examples.xhtml.builder.XHTML;
3 |
4 | import org.w3c.dom.Document;
5 | import unquietcode.tools.flapi.examples.xhtml.builder.Element.ElementHelper;
6 |
7 | import javax.annotation.Generated;
8 | import java.util.concurrent.atomic.AtomicReference;
9 |
10 |
11 | /**
12 | * This class was generated using Flapi, the fluent API generator for Java.
13 | * Modifications to this file will be lost upon regeneration.
14 | * You have been warned!
15 | *
16 | * Visit https://github.com/UnquietCode/Flapi for more information.
17 | *
18 | *
19 | * Generated on February 28, 2016 16:29:18 PST using version 0.0-DEVELOPMENT
20 | */
21 | @Generated(value = "unquietcode.tools.flapi", date = "2016-02-28T16:29:18-08:00", comments = "generated using Flapi, the fluent API generator for Java, version 0.0-DEVELOPMENT")
22 | public interface XHTMLHelper {
23 | void addComment(String comment);
24 |
25 | Document done();
26 |
27 | void startElement(String tagName, AtomicReference _helper1);
28 | }
29 |
--------------------------------------------------------------------------------
/src/test/resources/BlockChainTest.avaj:
--------------------------------------------------------------------------------
1 | some.thing.Something.SomethingGenerator.create(null)
2 | .one()
3 | .exit()
4 |
5 | .two()
6 | .exit() // bc one
7 | .twoRef() // bc three
8 | .exit() // two
9 |
10 | .exit() // two
11 | .exit();
--------------------------------------------------------------------------------
/src/test/resources/GroupedTest1.avaj:
--------------------------------------------------------------------------------
1 | // optional and then required
2 |
3 | something.Something.SomethingGenerator.create(null)
4 | .regular()
5 | .regular()
6 |
7 | .optional1()
8 |
9 | // it's gone
10 | << .required1() >>
11 |
12 | // still one left...
13 | .optional1()
14 |
15 | // now it's gone
16 | << .optional1() >>
17 |
18 | // still got these though
19 | .regular()
20 | .regular()
21 |
22 | .terminal();
23 |
24 |
25 | // required and then optional
26 |
27 | something.Something.SomethingGenerator.create(null)
28 | .required1()
29 |
30 | // gone
31 | << .optional1() >>
32 |
33 | // the any one is still around though
34 | .required1()
35 | .required1()
36 | .regular()
37 | .regular()
38 |
39 | .terminal();
--------------------------------------------------------------------------------
/src/test/resources/GroupedTest2.avaj:
--------------------------------------------------------------------------------
1 | // two required methods competing with each other
2 |
3 | something.Something.SomethingGenerator.create(null)
4 | .required2A()
5 |
6 | // gone
7 | << .required2B() >>
8 |
9 | .required2A()
10 | .required2A()
11 | .required2A()
12 |
13 | .terminal();
14 |
15 |
16 | something.Something.SomethingGenerator.create(null)
17 | .required2B()
18 |
19 | // gone
20 | << .required2A() >>
21 |
22 | .required2B()
23 | .required2B()
24 | .regular()
25 |
26 | .terminal();
--------------------------------------------------------------------------------
/src/test/resources/TopReference.avaj:
--------------------------------------------------------------------------------
1 | some.thing.Something.SomethingGenerator.create(null)
2 | .one()
3 | .topLevel()
4 | .one()
5 | .topLevel()
6 | .one()
7 | .exit()
8 | .exit()
9 | .topLevel()
10 | .one()
11 | .exit()
12 | .exit()
13 | ;
--------------------------------------------------------------------------------
/src/test/resources/TriggeredTest1.avaj:
--------------------------------------------------------------------------------
1 | something.Something.SomethingGenerator.create(null)
2 |
3 | // not yet
4 | // .triggered()
5 |
6 | // any of these
7 | .required()
8 | .required()
9 | .required()
10 |
11 | // the trigger...
12 | .requiredWithGroup()
13 |
14 | // what's up!
15 | .triggered()
16 |
17 | // but not a second time
18 | //.triggered()
19 |
20 | // still any number of these
21 | .required()
22 | .required()
23 |
24 | // these too, and they should not reset
25 | .requiredWithGroup()
26 | .requiredWithGroup()
27 |
28 | // but this should NOT work
29 | // .triggered()
30 |
31 | .terminal();
--------------------------------------------------------------------------------
/src/test/resources/TriggeredTest2.avaj:
--------------------------------------------------------------------------------
1 | something.Something.SomethingGenerator.create(null)
2 |
3 | .dynamic()
4 |
5 | // gone
6 | <<.dynamic()>>
7 |
8 | // not yet
9 | <<.triggered()>>
10 |
11 | .dynamicWithGroup()
12 | .triggered()
13 |
14 | // shouldn't be here
15 | <<.dynamicWithGroup()>>
16 |
17 | .terminal();
--------------------------------------------------------------------------------