@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + (coalescing ? 1231 : 1237); result = prime * result + (expandEntityReferences ? 1231 : 1237); result = prime * result + (ignoringComments ? 1231 : 1237); result = prime * result + (ignoringElementContentWhitespace ? 1231 : 1237); result = prime * result + (namespaceAware ? 1231 : 1237); result = prime * result + (validating ? 1231 : 1237); result = prime * result + (xincludeAware ? 1231 : 1237); return result; }
/** * SuppressMarker should be initially null and changeable. */ @Test public void testSuppressMarker() { ParserOptions parserOptions = new ParserOptions(); Assert.assertNull(parserOptions.getSuppressMarker()); parserOptions.setSuppressMarker("foo"); Assert.assertEquals("foo", parserOptions.getSuppressMarker()); }
/** * Verify that the equals and hashCode methods work as expected. */ @Test public void testEqualsHashcode() { ParserOptions options1 = new ParserOptions(); options1.setSuppressMarker("foo"); ParserOptions options2 = new ParserOptions(); options2.setSuppressMarker("bar"); ParserOptions options3 = new ParserOptions(); options3.setSuppressMarker("foo"); ParserOptions options4 = new ParserOptions(); options4.setSuppressMarker("bar"); verifyOptionsEqualsHashcode(options1, options2, options3, options4); }
Assert.assertFalse(options1.equals(options2)); Assert.assertEquals(options1, options3); Assert.assertFalse(options1.equals(options4)); Assert.assertFalse(options2.equals(options1)); Assert.assertEquals(options2, options2); Assert.assertFalse(options2.equals(options3)); Assert.assertEquals(options2, options4); Assert.assertFalse(options3.equals(options2)); Assert.assertEquals(options3, options3); Assert.assertFalse(options3.equals(options4)); Assert.assertFalse(options4.equals(options1)); Assert.assertEquals(options4, options2); Assert.assertFalse(options4.equals(options3)); Assert.assertEquals(options4, options4); Assert.assertNotEquals(options1.hashCode(), options2.hashCode()); Assert.assertEquals(options1.hashCode(), options3.hashCode()); Assert.assertNotEquals(options1.hashCode(), options4.hashCode()); Assert.assertNotEquals(options2.hashCode(), options3.hashCode()); Assert.assertEquals(options2.hashCode(), options4.hashCode()); Assert.assertNotEquals(options3.hashCode(), options4.hashCode());
/** * This implementation returns a new instance of {@link ParserOptions} using * default settings. * * @see Rule#setPriority(RulePriority) */ @Override public ParserOptions getParserOptions() { return new ParserOptions(); }
/** * Subclass should override this method to modify the JavaParser as needed. */ protected JavaParser createJavaParser(Reader source) throws ParseException { parser = new JavaParser(new JavaCharStream(source)); String suppressMarker = getParserOptions().getSuppressMarker(); if (suppressMarker != null) { parser.setSuppressMarker(suppressMarker); } return parser; }
/** * Helper method to get a configured parser for the requested language. The * parser is configured based on the given {@link PMDConfiguration}. * * @param languageVersion * the requested language * @param configuration * the given configuration * @return the pre-configured parser */ public static Parser parserFor(LanguageVersion languageVersion, PMDConfiguration configuration) { // TODO Handle Rules having different parser options. LanguageVersionHandler languageVersionHandler = languageVersion.getLanguageVersionHandler(); ParserOptions options = languageVersionHandler.getDefaultParserOptions(); if (configuration != null) { options.setSuppressMarker(configuration.getSuppressMarker()); } return languageVersionHandler.getParser(options); }
/** * Verify that the equals and hashCode methods work as expected. */ @Test public void testEqualsHashcode() { ParserOptions options1 = new ParserOptions(); options1.setSuppressMarker("foo"); ParserOptions options2 = new ParserOptions(); options2.setSuppressMarker("bar"); ParserOptions options3 = new ParserOptions(); options3.setSuppressMarker("foo"); ParserOptions options4 = new ParserOptions(); options4.setSuppressMarker("bar"); verifyOptionsEqualsHashcode(options1, options2, options3, options4); }
Assert.assertFalse(options1.equals(options2)); Assert.assertEquals(options1, options3); Assert.assertFalse(options1.equals(options4)); Assert.assertFalse(options2.equals(options1)); Assert.assertEquals(options2, options2); Assert.assertFalse(options2.equals(options3)); Assert.assertEquals(options2, options4); Assert.assertFalse(options3.equals(options2)); Assert.assertEquals(options3, options3); Assert.assertFalse(options3.equals(options4)); Assert.assertFalse(options4.equals(options1)); Assert.assertEquals(options4, options2); Assert.assertFalse(options4.equals(options3)); Assert.assertEquals(options4, options4); Assert.assertNotEquals(options1.hashCode(), options2.hashCode()); Assert.assertEquals(options1.hashCode(), options3.hashCode()); Assert.assertNotEquals(options1.hashCode(), options4.hashCode()); Assert.assertNotEquals(options2.hashCode(), options3.hashCode()); Assert.assertEquals(options2.hashCode(), options4.hashCode()); Assert.assertNotEquals(options3.hashCode(), options4.hashCode());
@Override public ParserOptions getDefaultParserOptions() { return new ParserOptions(); }
/** * Subclass should override this method to modify the JavaParser as needed. */ protected JavaParser createJavaParser(Reader source) throws ParseException { parser = new JavaParser(new JavaCharStream(source)); String suppressMarker = getParserOptions().getSuppressMarker(); if (suppressMarker != null) { parser.setSuppressMarker(suppressMarker); } return parser; }
/** * Helper method to get a configured parser for the requested language. The * parser is configured based on the given {@link PMDConfiguration}. * * @param languageVersion * the requested language * @param configuration * the given configuration * @return the pre-configured parser */ public static Parser parserFor(LanguageVersion languageVersion, PMDConfiguration configuration) { // TODO Handle Rules having different parser options. LanguageVersionHandler languageVersionHandler = languageVersion.getLanguageVersionHandler(); ParserOptions options = languageVersionHandler.getDefaultParserOptions(); if (configuration != null) { options.setSuppressMarker(configuration.getSuppressMarker()); } return languageVersionHandler.getParser(options); }
/** * SuppressMarker should be initially null and changeable. */ @Test public void testSuppressMarker() { ParserOptions parserOptions = new ParserOptions(); Assert.assertNull(parserOptions.getSuppressMarker()); parserOptions.setSuppressMarker("foo"); Assert.assertEquals("foo", parserOptions.getSuppressMarker()); }
@Override public int hashCode() { final int prime = 31; int result = super.hashCode(); result = prime * result + (recordingComments ? 1231 : 1237); result = prime * result + (recordingLocalJsDocComments ? 1231 : 1237); result = prime * result + ((rhinoLanguageVersion == null) ? 0 : rhinoLanguageVersion.hashCode()); return result; }
/** * This implementation returns a new instance of {@link ParserOptions} using * default settings. * * @see Rule#setPriority(RulePriority) */ @Override public ParserOptions getParserOptions() { return new ParserOptions(); }
@Override public ParserOptions getDefaultParserOptions() { return new ParserOptions(); }