Coder Social home page Coder Social logo

fluflu's People

Contributors

lukaseder avatar orlandocr avatar verhas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

fluflu's Issues

How to use this tool ?

Hi , I am very interested in this tool, but I don't know how to use it in my maven project for the code generation part.

I write a small class like:

@Fluentize(className = "CoreClass", startState = "new", startMethod = "create")
public class CriticalPathMethod implements Cloneable {

.....

}

And in the command line, I try:

apt -cp ./:./fluflu-2.0.0.jar monmouth/schedule/logic/CriticalPathMethod.java

But nothing happens.
Will you please give some use case samples? Really appreciate.

Ken

The end method signature should mimick the annotated end method signature

Assume I have these "end" methods:

@Transition(from = "X", end = true)
public String end1() throws Exception {
    return null;
}

@Transition(from = "Y", end = true)
public void end2() throws Throwable {
    return null;
}

I'd expect the generated method to look like this:

public String end1() throws Exception {
    return core.end();  
}
public void end2() throws Throwable {
    core.end(); 
}

Enhance @Fluentize to allow for several start states and methods

Currently, @Fluentize allows only a single start state and method. For a more sophisticated fluent API, it would be nice if @Fluentize had a signature like this:

@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface Fluentize {
    String className() default "";
    String[] startStates() default ""; // Change here
    String[] startMethods() default ""; // Change here
}

The above is just a suggestion to show the idea. I don't think that two String[] arrays would be the ideal way to model this. Probably, more annotations should be introduced.

Make it possible to define a cloner method

Instead of generating code that relies on the Java clone capability let the programmer create a method in the annotated class that makes the cloning class specific and annotate the method so that the generated methods call that method to get a new instance of the class instead of cloning.

The method annotated using the annotation

@Cloner

should return the base class.

Separate fluflu artefacts into a Maven plugin / runtime dependency

I'm spamming you with ideas / features ;-)

Ideally, fluflu's APT tools shouldn't be a runtime / compile-time dependency. Instead they should be used as a Maven plugin, if that's possible. Once the generated code is compiled and packaged, the only thing left to stay might be the annotations.

As a matter of fact, I can see some use-cases where the annotations might be useful at runtime, if they were changed to RetentionPolicy.RUNTIME

Cloneable semantics / promise might not be correct

Hi Peter,

So I'll just tell you my thoughts through issues, I guess that's the easiest and most trackable way to communicate. BTW, too bad you already released 1.0.0 to Maven Central. Maybe you could add a disclaimer that fluflu doesn't (yet?) follow semantic versioning: http://semver.org/

About Cloneable, your example contains a reference to:

protected List<byte[]> b = new LinkedList<>();

This list, when cloned, will not deep-clone all the byte arrays. Note, that it works for this Set:

Set<Integer> j = new HashSet<>(); 

... because Integer is immutable.

So I think that the promise of supporting Cloneable might be a false one. What do you think?

Remove sources in target directory

XJC removes sources from the target directory (typically target/generated-sources/xjc), if they are no longer needed / valid. I guess this should be done as well in fluflu, without requiring to call mvn clean

States should be "reusable" in fluent API methods

When I have intermediate states "X" and "Y" as such:

@Transition(from = "X", to = "Y")
abstract Impl fromXtoY();

I would like to be able to consume those states in API methods, e.g.

@Transition(from = "A", to = "B")
abstract Impl fromAtoB(X x, Y y);

A more real-life example from jOOQ:

// T is created through a fluent API:
Table T = T1.join(T2).on("...");

// T can be consumed in another, related fluent API:
select().from(T);

Unfortunately, with the current implementation, I cannot use the types X and Y in my annotated fromAtoB() method, as those types are not generated yet. I'm not sure how to solve this problem...

Add an optional method argument to @Transition

Currently, @Transition implicitly generates a new method with the annotated method's name, as can be seen here:

  private String replaceMethodParams(String s, TransitionEdge edge, String arglist, String paramlist, String javaDoc) {
    return InThe.string(s).replace(//
        "methodName", edge.method.getSimpleName().toString(),//
        "arglist", arglist,//
        "paramlist", paramlist,//
        "toState", edge.targetState,
        "javaDoc",javaDoc);
  }

From this revision:

"methodName", edge.method.getSimpleName().toString(),//

It would be nice if @Transition was changed to this:

@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.METHOD)
public @interface Transition {
    String[] from() default "";
    String to() default "";
    String method() default ""; // Add this
    boolean end() default false;
}

When left empty, then the behaviour would be as today.

Make @AddTo a bit more sophisticated

Currently, @AddTo just assumes that the target member can accept an .add(...) method call. This is not very versatile yet. For instance, I would like to be able to write these things:

    List<String> list = new ArrayList<>();

    @Transition(from = "A", to = "B")
    public abstract XXX from(@AddTo("list") String... elements);

    @Transition(from = "A", to = "B")
    public abstract XXX from(@AddTo("list") Collection<String> elements);

This is what the resulting generated methods would have to execute:

// First method:
list.addAll(java.util.Arrays.asList(elements));

// Second method:
list.addAll(elements);

Of course, it becomes clear that @AddTo, @AssignTo and similar annotations would have to be well conceived, to foresee many more cases like the above

Any potential in using Xtend for templating?

I've made great experiences with Xtend as a templating engine for generating code:
http://www.eclipse.org/xtend/

I'm using it to generate all the row value expression related stuff in jOOQ, where similar code has to be duplicated, such as Record1, Record2, Record3, etc...

Do you see any potential in using it for fluflu?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.