1 package com.puppycrawl.tools.checkstyle.checks.design; 20 21 import com.puppycrawl.tools.checkstyle.api.Check; 22 import com.puppycrawl.tools.checkstyle.api.TokenTypes; 23 import com.puppycrawl.tools.checkstyle.api.DetailAST; 24 25 44 public final class InterfaceIsTypeCheck 45 extends Check 46 { 47 48 private boolean mAllowMarkerInterfaces = true; 49 50 51 public int[] getDefaultTokens() 52 { 53 return new int[] {TokenTypes.INTERFACE_DEF}; 54 } 55 56 57 public int[] getRequiredTokens() 58 { 59 return getDefaultTokens(); 60 } 61 62 63 public void visitToken(DetailAST aAST) 64 { 65 final DetailAST objBlock = 66 aAST.findFirstToken(TokenTypes.OBJBLOCK); 67 final DetailAST methodDef = 68 objBlock.findFirstToken(TokenTypes.METHOD_DEF); 69 final DetailAST variableDef = 70 objBlock.findFirstToken(TokenTypes.VARIABLE_DEF); 71 final boolean methodRequired = 72 !mAllowMarkerInterfaces || (variableDef != null); 73 74 if ((methodDef == null) && methodRequired) { 75 log(aAST.getLineNo(), "interface.type"); 76 } 77 78 } 79 80 84 public void setAllowMarkerInterfaces(boolean aFlag) 85 { 86 mAllowMarkerInterfaces = aFlag; 87 } 88 } 89 | Popular Tags |