static SuggestedFix . Builder makeConcreteClassAbstract ( ClassTree classTree , VisitorState state ) { Set < Modifier > flags = EnumSet . noneOf ( Modifier . class ) ; flags . addAll ( classTree . getModifiers ( ) . getFlags ( ) ) ; boolean wasFinal = flags . remove ( FINAL ) ; boolean wasAbstract = ! flags . add ( ABSTRACT ) ; if ( classTree . getKind ( ) . equals ( INTERFACE ) || ( ! wasFinal && wasAbstract ) ) { return SuggestedFix . builder ( ) ; // no-op } ImmutableList . Builder < Object > modifiers = ImmutableList . builder ( ) ; for ( AnnotationTree annotation : classTree . getModifiers ( ) . getAnnotations ( ) ) { modifiers . add ( state . getSourceForNode ( annotation ) ) ; } modifiers . addAll ( flags ) ; SuggestedFix . Builder makeAbstract = SuggestedFix . builder ( ) ; if ( ( ( JCModifiers ) classTree . getModifiers ( ) ) . pos == - 1 ) { makeAbstract . prefixWith ( classTree , Joiner . on ( ' ' ) . join ( modifiers . build ( ) ) ) ; } else { makeAbstract . replace ( classTree . getModifiers ( ) , Joiner . on ( ' ' ) . join ( modifiers . build ( ) ) ) ; } if ( wasFinal && HAS_GENERATED_CONSTRUCTOR . matches ( classTree , state ) ) { makeAbstract . merge ( addPrivateConstructor ( classTree ) ) ; } return makeAbstract ; }
Returns a fix that changes a concrete class to an abstract class .