We encountered a class in our codebase with a generic parameter T on one of its methods. T has bounds that involve classes with long names, and when we format this class with Palantir format, we get the following:
public class CrazyGenerics {
public <
T extends
FantasticVeryLongNamedContainerWithLongName<?, ?, ?, ?>
& OtherLongNamedTypeWithOnlyOneGenericType<?>>
void computeInfo() {}
public interface FantasticVeryLongNamedContainerWithLongName<FirstType, SecondType, ThirdType, FourthType> {
FirstType getFirst();
SecondType getSecond();
ThirdType getThird();
FourthType getFourth();
}
public interface OtherLongNamedTypeWithOnlyOneGenericType<FirstType> {
FirstType getFirst();
}
}
What did you want to happen?
I could see a few better alternatives.
Be consistent with the indentation after methods:
public <
T extends
FantasticVeryLongNamedContainerWithLongName<?, ?, ?, ?>
& OtherLongNamedTypeWithOnlyOneGenericType<?>>
void computeInfo() {}
Or perhaps leave the generic type on the original line:
What happened?
We encountered a class in our codebase with a generic parameter
T
on one of its methods.T
has bounds that involve classes with long names, and when we format this class with Palantir format, we get the following:What did you want to happen?
I could see a few better alternatives.
Be consistent with the indentation after methods:
Or perhaps leave the generic type on the original line:
Other suggestions welcome, but I hope it's clear why the original is not ideal.