Child pages
  • Lucene Concepts
Skip to end of metadata
Go to start of metadata
assertFinal - Asserting Child Is Sealed
 protected TokenStream(AttributeFactory factory) {
    super(factory);
    assert assertFinal();
  }

  private boolean assertFinal() {
    try {
      final Class<?> clazz = getClass();
      assert clazz.isAnonymousClass() ||
        (clazz.getModifiers() & (Modifier.FINAL | Modifier.PRIVATE)) != 0 ||
        Modifier.isFinal(clazz.getMethod("incrementToken").getModifiers()) :
        "TokenStream implementation classes or at least their incrementToken() implementation must be final";
      return true;
    } catch (NoSuchMethodException nsme) {
      return false;
    }
  }		

This seems like a broken way to enforce design rules or idioms. You take a performance hit whenever the sub class initializes.  This kind of thing needs to be through FxCop or Tests that enforce design rules or both.  For now Lucene.Net 4 is omitting these rules. 

  • No labels