1 package com.puppycrawl.tools.checkstyle.checks.coding; 20 21 import com.puppycrawl.tools.checkstyle.api.Check; 22 import java.util.HashSet ; 23 import java.util.Set ; 24 25 29 public abstract class AbstractIllegalCheck extends Check 30 { 31 32 private final Set mIllegalClassNames = new HashSet (); 33 34 38 protected AbstractIllegalCheck(final String [] aInitialNames) 39 { 40 assert aInitialNames != null; 41 setIllegalClassNames(aInitialNames); 42 } 43 44 51 protected final boolean isIllegalClassName(final String aIdent) 52 { 53 return mIllegalClassNames.contains(aIdent); 54 } 55 56 62 public final void setIllegalClassNames(final String [] aClassNames) 63 { 64 assert aClassNames != null; 65 mIllegalClassNames.clear(); 66 for (int i = 0; i < aClassNames.length; i++) { 67 final String name = aClassNames[i]; 68 mIllegalClassNames.add(name); 69 final int lastDot = name.lastIndexOf("."); 70 if ((lastDot > 0) && (lastDot < (name.length() - 1))) { 71 final String shortName = name 72 .substring(name.lastIndexOf(".") + 1); 73 mIllegalClassNames.add(shortName); 74 } 75 } 76 } 77 } 78 | Popular Tags |