[
https://issues.jboss.org/browse/ROASTER-51?page=com.atlassian.jira.plugin...
]
Antonio Goncalves commented on ROASTER-51:
------------------------------------------
[~gastaldi]] There are a few issues with this.
h3. Typed interface
A {{ConstraintValidator}} needs to be typed, such as :
{code}
public class MaxValidatorForString implements ConstraintValidator<Max, Number> {
@Override
public void initialize(Max constraint) {
}
@Override
public boolean isValid(Number value, ConstraintValidatorContext context) {
return false;
}
}
{code}
For this to work, at the moment we use the following syntax, plus, we create the methods
to implement:
{code}
javaClass.addInterface("ConstraintValidator<" + constraintAnnotation +
", " + dataType + ">");
{code}
Unfortunatelly we cannot override such syntax
h3. Naming parameters
When we override an interface, the method parameters are named arg0, arg1.... such as :
{code}
javaClassSource.setPackage("org.agoncal.myproj").setName("MyJSFConverter2").addInterface(Converter.class,
true);
public class MyJSFConverter2 implements Converter {
@Override
public Object getAsObject(FacesContext arg0, UIComponent arg1, String arg2) {
return null;
}
@Override
public String getAsString(FacesContext arg0, UIComponent arg1, Object arg2) {
return null;
}
}
{code}
Why not naming parameters with lowercase(className) and maybe something different for
datatypes (s1, s2... for strings). And when there is only one of the same type, forget the
numbering :
{code}
@Override
public Object getAsObject(FacesContext facesContext, UIComponent uiComponent, String s)
{
return null;
}
@Override
public String getAsString(FacesContext facesContext, UIComponent uiComponent, Object
object) {
return null;
}
{code}
h3. Duplicate method
If you orverride an interface, and then create the exact same method signature, the method
is duplicated and it doesn't compile (I suppose there is not much we can do)
{code}
javaClassSource.setPackage("org.agoncal.myproj").setName("MyJSFConverter2").addInterface(Converter.class,
true)
.addAnnotation(FacesConverter.class);
// Methods
MethodSource<?> getAsObject =
javaClassSource.addMethod().setPublic().setName("getAsObject")
.setReturnType(Object.class);
getAsObject.addParameter(FacesContext.class, "context").setFinal(true);
getAsObject.addParameter(UIComponent.class, "component").setFinal(true);
getAsObject.addParameter(String.class, "value").setFinal(true);
getAsObject.setBody("throw new UnsupportedOperationException(\"not yet
implemented\");")
.addAnnotation(Override.class);
MethodSource<?> getAsString =
javaClassSource.addMethod().setPublic().setName("getAsString")
.setReturnType(String.class);
getAsString.addParameter(FacesContext.class, "context").setFinal(true);
getAsString.addParameter(UIComponent.class, "component").setFinal(true);
getAsString.addParameter(Object.class, "value").setFinal(true);
getAsString.setBody("return value.toString();")
.addAnnotation(Override.class);
{code}
Add interface or abstract class should implement inherited methods
------------------------------------------------------------------
Key: ROASTER-51
URL:
https://issues.jboss.org/browse/ROASTER-51
Project: Roaster
Issue Type: Enhancement
Affects Versions: 2.11.1.Final
Reporter: Nicolas Challut
Assignee: George Gastaldi
Priority: Minor
Fix For: 2.15.1.Final
When you use addInterface or setExtends, Roaster should bring back automatically (or via
a method explicitly call) all inherited method.
--
This message was sent by Atlassian JIRA
(v6.4.11#64026)