Skip to content

Instantly share code, notes, and snippets.

@pauldijou
Created June 21, 2012 17:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pauldijou/2967186 to your computer and use it in GitHub Desktop.
Save pauldijou/2967186 to your computer and use it in GitHub Desktop.
Generating methods on CDK
// Abstract component inside CDK. Will serve as base to generate final UIComponent.
@JsfComponent(...)
public abstract class AbstractInput extends UIInput implements CoreProps, UIComponentUtil {
...
}
// Implementation for the #hasFacet() method
return getFacet(facetName) != null;
// Interface that provide the signature of the method to add to CDK Abstract components
public interface UIComponentUtil {
@GeneratedMethod("hasFacet.ftl")
boolean hasFacet(String facetName);
}
// Generated UIComponent by the CDK from the Abstract one, including the generated method from the UIComponentUtil interface.
@Generated({"RichFaces CDK", "4.3.0-SNAPSHOT"})
public class UIInput extends AbstractInput implements CoreProps, UIComponentUtil {
...
public boolean hasFacet(String facetName) {
return getFacet(facetName) != null;
}
...
}
@bleathem
Copy link

Why not (optionally) put the implementation in the @GeneratedMethod annotation?

@GeneratedMethod(implementation="return getFacet(facetName) != null;")
boolean hasFacet(String facetName);

@pauldijou
Copy link
Author

Fine with me, I'm always fine when you provide more tools but don't force people to use them. I'm not sure if it will be so much usefull, but for small methods, it will clearly increase productivity and readability.

@bleathem
Copy link

Is there a RFSBOX jira for this?

@pauldijou
Copy link
Author

Nope, the idea is brand new from a talk between Lukas and myself this afternoon. I can create it tomorrow with this gist as reference is you want.

@pauldijou
Copy link
Author

@bleathem
Copy link

Great Paul - thanks for your terrific ideas moving the project forward!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment