Well, you could move the if statement into the appendAttribute method. You would then only have the conditional in one place.
public boolean formRequest(
final String type,
final String orientation,
final String title,
final String width,
final String height,
final String xlabel,
final String ylabel) {
appendAttribute(HEIGHT_ATTRIBUTE_NAME, height, request);
appendAttribute(WIDTH_ATTRIBUTE_NAME, width, request);
appendAttribute(Y_LABEL_ATTRIBUTE_NAME, ylabel, request);
return request.toString();
}
and:
private void appendAttribute(final String attributeName,
final String attributeValue, final StringBuilder builder) {
if(attributeValue != null) {
builder.append(attributeName);
builder.append(EQUALS_CHAR);
builder.append(attributeValue);
builder.append(AMPERSAND_CHAR);
}
}