org.snapscript.core.type.index.ClassIndex Maven / Gradle / Ivy
package org.snapscript.core.type.index;
import java.util.List;
import org.snapscript.core.annotation.Annotation;
import org.snapscript.core.constraint.Constraint;
import org.snapscript.core.error.InternalStateException;
import org.snapscript.core.function.Function;
import org.snapscript.core.module.Module;
import org.snapscript.core.property.Property;
import org.snapscript.core.type.Type;
public class ClassIndex {
private List annotations;
private List constraints;
private List properties;
private List functions;
private List types;
private ClassIndexer indexer;
private ClassType require;
private Module module;
private Type outer;
private Type entry;
private int modifiers;
public ClassIndex(ClassIndexer indexer, ClassType require) {
this.indexer = indexer;
this.require = require;
}
public List getAnnotations() {
if(annotations == null) {
try {
annotations = indexer.indexAnnotations(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return annotations;
}
public List getConstraints() {
if(constraints == null) {
try {
constraints = indexer.indexConstraints(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return constraints;
}
public List getProperties() {
if(properties == null) {
try {
properties = indexer.indexProperties(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return properties;
}
public List getFunctions() {
if(functions == null) {
try {
functions = indexer.indexFunctions(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return functions;
}
public List getTypes() {
if(types == null) {
try {
types = indexer.indexTypes(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return types;
}
public Module getModule() {
if(module == null) {
try {
module = indexer.indexModule(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return module;
}
public Type getOuter() {
if(outer == null) {
try {
outer = indexer.indexOuter(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return outer;
}
public Type getEntry() {
if(entry == null) {
try {
entry = indexer.indexEntry(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return entry;
}
public int getModifiers() {
if(modifiers == 0) {
try {
modifiers = indexer.indexModifiers(require);
} catch(Exception e) {
throw new InternalStateException("Could not index " + require, e);
}
}
return modifiers;
}
}