checkstyle: enable OneTopLevelClass

The only remaining error was ClipboardCompat, which was unnecessarily
exposing three top-level classes. Make the two implementation classes be
nested, private and static.
This commit is contained in:
Daniel Martí 2016-05-05 11:02:26 +01:00
parent 6311ad5c6b
commit 78af79cd4f
2 changed files with 26 additions and 27 deletions

View File

@ -17,34 +17,33 @@ public abstract class ClipboardCompat {
return new OldClipboard();
}
}
@TargetApi(11)
private static class HoneycombClipboard extends ClipboardCompat {
@TargetApi(11)
class HoneycombClipboard extends ClipboardCompat {
private final ClipboardManager manager;
private final ClipboardManager manager;
HoneycombClipboard(Context context) {
this.manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
}
@Override
public String getText() {
CharSequence text = null;
if (manager.hasPrimaryClip()) {
ClipData data = manager.getPrimaryClip();
if (data.getItemCount() > 0) {
text = data.getItemAt(0).getText();
}
HoneycombClipboard(Context context) {
this.manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
}
@Override
public String getText() {
CharSequence text = null;
if (manager.hasPrimaryClip()) {
ClipData data = manager.getPrimaryClip();
if (data.getItemCount() > 0) {
text = data.getItemAt(0).getText();
}
}
return text != null ? text.toString() : null;
}
}
private static class OldClipboard extends ClipboardCompat {
@Override
public String getText() {
return null;
}
return text != null ? text.toString() : null;
}
}
class OldClipboard extends ClipboardCompat {
@Override
public String getText() {
return null;
}
}

View File

@ -62,7 +62,7 @@
</module>
<module name="NoLineWrap"/>
<!--<module name="OneTopLevelClass" />-->
<module name="OneTopLevelClass" />
<module name="OneStatementPerLine" />
<module name="EmptyBlock">