Violation implements IFlexViolation { public int compareTo( final IFlexViolation otherViolation ) { int res; final int priorityOrder = getPrioriyOrder( otherViolation ); if ( priorityOrder == 0 ) { res = getLinePriority( otherViolation ); } else { res = priorityOrder; } return res; } Violation( final ViolationPosition position,
                     final IFlexRule violatedRule,
                     final IFlexFile violatedFile ); void appendToMessage( final String messageToAppend ); int compareTo( final IFlexViolation otherViolation ); int getBeginColumn(); int getBeginLine(); String getClassName(); String getDescription(); int getEndColumn(); int getEndLine(); String getFilename(); String getMethodName(); String getPackageName(); IFlexRule getRule(); String getRuleMessage(); String getVariableName(); boolean isSuppressed(); void replacePlaceholderInMessage( final String replacement,
                                            final int index ); void setEndColumn( final int column ); String toXmlString( final IFlexFile violatedFile,
                              final String ruleSetName ); static final String RULESET_CREATOR_URL; }
@Test public void testCompareTo() { final Violation infoViolation = new Violation( position, INFO_RULE, null ); final Violation infoViolation2 = new Violation( ViolationPosition.create( 11, 20, 30, 30 ), INFO_RULE, null ); final Violation warningViolation = new Violation( position, WARNING_RULE, null ); final Violation warningViolation2 = new Violation( position, WARNING_RULE, null ); assertEquals( -1, infoViolation.compareTo( infoViolation2 ) ); assertEquals( -1, warningViolation.compareTo( infoViolation ) ); assertEquals( 0, warningViolation.compareTo( warningViolation2 ) ); assertEquals( 1, infoViolation2.compareTo( infoViolation ) ); assertEquals( 1, infoViolation.compareTo( warningViolation ) ); }