View Javadoc
1   package net.florianschoppmann.java.reflect;
2   
3   import javax.lang.model.element.Modifier;
4   import java.util.Set;
5   
6   abstract class ElementImpl extends AnnotatedConstructImpl implements ReflectionElement {
7       private boolean finished = false;
8   
9       @Override
10      public final Set<Modifier> getModifiers() {
11          throw new UnsupportedOperationException(String.format(
12              "Modifiers not currently supported by %s.", ReflectionTypes.class
13          ));
14      }
15  
16      final void requireFinished() {
17          if (!finished) {
18              throw new IllegalStateException(String.format("Instance of %s used before it was ready.", getClass()));
19          }
20      }
21  
22      abstract void finishDerivedFromElement(MirrorContext mirrorContext);
23  
24      final void finish(MirrorContext mirrorContext) {
25          if (finished) {
26              throw new IllegalStateException(String.format(
27                  "Attempt to finish instance of %s more than once.", getClass()
28              ));
29          }
30  
31          finished = true;
32          finishDerivedFromElement(mirrorContext);
33      }
34  }