Skip to content

Commit

Permalink
[FLAPI-47] [FLAPI-53] [FLAPI-51]
Browse files Browse the repository at this point in the history
+ removes runtime dependencies for examples (regenerated builders)
+ fixes a test error
+ improves email example with new syntax
  • Loading branch information
UnquietCode committed May 28, 2012
1 parent d6d6f4e commit e0a0e5c
Show file tree
Hide file tree
Showing 90 changed files with 805 additions and 770 deletions.

This file was deleted.

50 changes: 0 additions & 50 deletions src/main/java/unquietcode/tools/flapi/ObjectWrapper.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,5 @@ public void descriptorGenerator() {

.build()
;

builder.writeToFolder("/Users/bfagin/Documents/Code Projects/Flapi/temp");
}
}
20 changes: 20 additions & 0 deletions src/test/java/unquietcode/tools/flapi/AtLeast_T.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
/*******************************************************************************
Copyright 2012 Benjamin Fagin
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Read the included LICENSE.TXT for more information.
******************************************************************************/

package unquietcode.tools.flapi;

import org.junit.Test;
import unquietcode.tools.flapi.builder.DescriptorGenerator;
import unquietcode.tools.flapi.builder.MinimumInvocationsException;

/**
* @author Ben Fagin
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package unquietcode.tools.flapi.examples.calculator;

import unquietcode.tools.flapi.ObjectWrapper;
import unquietcode.tools.flapi.examples.calculator.builder.CalculationHelper;
import unquietcode.tools.flapi.examples.calculator.builder.ObjectWrapper;

import java.math.BigInteger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
import org.junit.Test;
import unquietcode.tools.flapi.Descriptor;
import unquietcode.tools.flapi.Flapi;
import unquietcode.tools.flapi.ObjectWrapper;
import unquietcode.tools.flapi.examples.calculator.builder.CalculationBuilder;
import unquietcode.tools.flapi.examples.calculator.builder.CalculatorBuilder;
import unquietcode.tools.flapi.examples.calculator.builder.CalculatorGenerator;
import unquietcode.tools.flapi.examples.calculator.builder.ObjectWrapper;

import java.math.BigInteger;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package unquietcode.tools.flapi.examples.calculator;

import unquietcode.tools.flapi.ObjectWrapper;
import unquietcode.tools.flapi.examples.calculator.builder.CalculationHelper;
import unquietcode.tools.flapi.examples.calculator.builder.CalculatorHelper;
import unquietcode.tools.flapi.examples.calculator.builder.ObjectWrapper;

import java.math.BigInteger;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 12, 2012 24:56:40 CDT using version 0.1
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public interface CalculationBuilder<_ReturnType >{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,26 +11,26 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 12, 2012 24:56:40 CDT using version 0.1
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public interface CalculationHelper {


void mod(int value);

void power(int value);
void divide(int value);

void abs();
void times(int value);

void divide(int value);
void power(int value);

void minus(int value);

void times(int value);
void abs();

void plus(int value);

void equals();

void mod(int value);

}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 12, 2012 24:56:40 CDT using version 0.1
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public interface CalculatorBuilder<_ReturnType >{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@

package unquietcode.tools.flapi.examples.calculator.builder;

import unquietcode.tools.flapi.DescriptorBuilderException;
import unquietcode.tools.flapi.ObjectWrapper;


/**
* This class was generated using Flapi, the fluent API generator for Java.
Expand All @@ -13,7 +10,7 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 12, 2012 24:56:40 CDT using version 0.1
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public class CalculatorGenerator {
Expand All @@ -22,7 +19,7 @@ public class CalculatorGenerator {
@SuppressWarnings("unchecked")
public static CalculatorBuilder<ObjectWrapper> begin(CalculatorHelper helper) {
if (helper == null) {
throw new DescriptorBuilderException("Helper cannot be null.");
throw new IllegalArgumentException("Helper cannot be null.");
}

return new ImplCalculatorBuilder(helper, helper._getReturnValue());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package unquietcode.tools.flapi.examples.calculator.builder;

import unquietcode.tools.flapi.ObjectWrapper;


/**
Expand All @@ -12,12 +11,11 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 12, 2012 24:56:40 CDT using version 0.1
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public interface CalculatorHelper {


ObjectWrapper _getReturnValue();

void $(int startingValue, ObjectWrapper<CalculationHelper> _helper1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 12, 2012 24:56:40 CDT using version 0.1
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public class ImplCalculationBuilder
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

package unquietcode.tools.flapi.examples.calculator.builder;

import unquietcode.tools.flapi.ObjectWrapper;


/**
Expand All @@ -12,7 +11,7 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 12, 2012 24:56:40 CDT using version 0.1
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public class ImplCalculatorBuilder
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@

package unquietcode.tools.flapi.examples.calculator.builder;



/**
* This class was generated using Flapi, the fluent API generator for Java.
* Modifications to this file will be lost upon regeneration.
* You have been warned!
*
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 28, 2012 10:12:35 CDT using version 0.2
*
*/
public class ObjectWrapper<_Type >{

private _Type _value;

public ObjectWrapper() {
}

public ObjectWrapper(_Type value) {
_value = value;
}

public void set(_Type value) {
_value = value;
}

public _Type get() {
return _value;
}

@Override
public String toString() {
if (_value == null) {
return null;
} else {
return _value.toString();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ public void descriptorGenerator() {
.setDescriptorName("Email")
.setReturnType(EmailMessage.class)

.addMethod("setSubject(String subject)").once()
.addMethod("subject(String subject)").once()
.addMethod("addRecipient(String emailAddress)").atLeast(1)
.addMethod("setSender(String emailAddress)").between(1,1)
.addMethod("sender(String emailAddress)").between(1,1)
.addMethod("addCC(String emailAddress)").any()
.addMethod("addBCC(String emailAddress)").any()
.addMethod("setBody(String text)").once()
.addMethod("body(String text)").once()
.addMethod("addAttachment(java.io.File file)").any()
.addMethod("send()").last()
.build()
Expand All @@ -38,11 +38,11 @@ public void descriptorGenerator() {
@Test
public void usage() {
EmailMessage message = EmailGenerator.compose(new EmailHelperImpl())
.setSender("iamthewalrus@hotmail.com")
.sender("iamthewalrus@hotmail.com")
.addRecipient("unclebob@unquietcode.com")
.setSubject("Has you seen my bucket?")
.setBody("Dear sir,\nI was wondering, have you seen my bucket? It is small, metallic, somewhat used, " +
"and slightly smells of fish. Please let me know if you have or do ever see it.\n\nThanks!")
.subject("Has you seen my bucket?")
.body("Dear sir,\nI was wondering, have you seen my bucket? It is small, metallic, somewhat used, " +
"and slightly smells of fish. Please let me know if you have or do ever see it.\n\nThanks!")
.send();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public EmailMessage _getReturnValue() {
}

@Override
public void setSubject(String subject) {
public void subject(String subject) {
email.setSubject(subject);
}

Expand All @@ -32,12 +32,12 @@ public void send() {
}

@Override
public void setSender(String emailAddress) {
public void sender(String emailAddress) {
email.setSender(emailAddress);
}

@Override
public void setBody(String text) {
public void body(String text) {
email.setBody(text);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* Visit http://www.unquietcode.com/flapi for more information.
*
*
* Generated on May 13, 2012 24:29:29 CDT using version 0.2
* Generated on May 28, 2012 10:14:26 CDT using version 0.2
*
*/
public interface EmailBuilder<_ReturnType >{
Expand Down
Loading

0 comments on commit e0a0e5c

Please sign in to comment.