Příklad

public interface ICommonParsingConstants {
public static final int IF_TOKEN = 1;
public static final int WHILE_TOKEN = 2;
public static final String END_OF_LINE = "\n"; //$NON-NLS-1$
}

public class Parser implements ICommonParsingConstants {
public void processToken( int iToken ) {
if ( iToken == IF_TOKEN ) {
System.out.println( "if" ); //$NON-NLS-1$
} else if ( iToken == WHILE_TOKEN ) {
System.out.println( "zatímco" ); //$NON-NLS-1$
}
}
}

public class Tokenizer implements ICommonParsingConstants {
public String getToken( String str ) {
return ( END_OF_LINE.equals( str ) ? "" : str ); //$NON-NLS-1$
}
}

Řešení
  1. Přesuňte jednotlivé konstanty do rozhraní nebo do tříd, do kterých logicky náleží.
  2. Odeberte prázdné rozhraní.

public class Parser {

public static final int IF_TOKEN = 1;
public static final int WHILE_TOKEN = 2;

public void processToken( int iToken ) {
if ( iToken == IF_TOKEN ) {
System.out.println( "if" ); //$NON-NLS-1$
} else if ( iToken == WHILE_TOKEN ) {
System.out.println( "zatímco" ); //$NON-NLS-1$
}
}
}

public class Tokenizer {
public static final String END_OF_LINE = "\n"; //$NON-NLS-1$

public String getToken( String str ) {
return ( END_OF_LINE.equals( str ) ? "" : str ); //$NON-NLS-1$
}
}