Regardless of which parameter annotations we use it's been a pain point
with Eclipse formatting. I played around a little in one of our Alerts
Rest handlers and I think the best I've seen is to enable these options
in the formatter, under the New Lines tab:
x Insert New Line after annotations on parameters
x Insert New Line after type annotations
The unfortunate thing is that at least with my version of Eclipse, it
works well only if you manually put the first parameter on a new line.
With the changes you'll get this from Eclipse:
@GET
@Path("/trigger/{triggerId}")
@Produces(APPLICATION_JSON)
@ApiOperation(value = "Find all threshold conditions",
responseClass =
"Collection<org.hawkular.alerts.api.model.condition.StringCondition>",
notes = "Pagination is not yet implemented")
public void findAllThresholdConditionsByTrigger(
@Suspended
final AsyncResponse response,
@ApiParam(value = "Trigger id to get threshold conditions",
required = true)
@PathParam("triggerId")
final String triggerId) {
try {
Collection<Condition> conditionsList =
definitions.getTriggerConditions(triggerId, null);
Collection<ThresholdCondition> thresholdConditions = new
ArrayList<ThresholdCondition>();
for (Condition cond : conditionsList) {
if (cond instanceof ThresholdCondition) {
thresholdConditions.add((ThresholdCondition) cond);
}
}
if (thresholdConditions.isEmpty()) {
log.debugf("GET - findAllThresholdConditions - Empty");
response.resume(Response.status(Response.Status.NO_CONTENT).type(APPLICATION_JSON_TYPE).build());
} else {
log.debugf("GET - findAllThresholdConditions - %s
compare conditions. ", thresholdConditions.size());
response.resume(Response.status(Response.Status.OK)
.entity(thresholdConditions).type(APPLICATION_JSON_TYPE).build());
}
} catch (Exception e) {
log.debugf(e.getMessage(), e);
Map<String, String> errors = new HashMap<String, String>();
errors.put("errorMsg", "Internal Error: " +
e.getMessage());
response.resume(Response.status(Response.Status.INTERNAL_SERVER_ERROR)
.entity(errors).type(APPLICATION_JSON_TYPE).build());
}
}
Basically the convention being that if you have annotations in the
params, each goes on it's own line. I actually don't care what options
we use but this is one formatting area where I still keep seeing
disparity between the IDEs.
On 3/2/2015 10:41 AM, Thomas Segismont wrote:
Le 02/03/2015 15:56, Heiko W.Rupp a écrit :
> The annotations from FindBugs and JSR-308 can allow for static code analysis,
> which may be helpful in error prevention as well.
Good point
_______________________________________________
hawkular-dev mailing list
hawkular-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/hawkular-dev