How do I restrict java function usage in intellij? -


i have project more 100 java classes. case is: - have button.java, dropdown.java, checkbox.java, listbox.java.... - also, business class represent page web app custom functions , mapping button.java , dropdown.java - want able use functions button , dropdown

an example:

public class fieldsproperties extends rhregion{     public static void setproperties(string strmap){         hashmap<string, string> mapproperties = getmapproperties();         if(strmap.equals("properties")){         mapproperties = uisummary.getproperties("uisummary");         }         setmapproperties(mapproperties);         rhregion.setproperties(strmap);     } } 

so in scenario want allowed functions uisummary.java or notified if used class

you can use illegaltype rule checkstyle:

checks particular classes never used types in variable declarations, return values or parameters.

rationale: helps reduce coupling on concrete classes.

simply add classes list of illegalclassnames. can configure checkstyle treat rule violation either warning or error.

note not prevent instantiation - example, assigning parent type still possible. better (or additional) rule might illegalinstantiation:

checks illegal instantiations factory method preferred.

assumed not have factory method restricted classes, violate instantiations of classes defined in classes property. of rule there intellij plugin checkstyle available.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -