org.snapscript.tree.define.StaticConstantIndexer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of snap Show documentation
Show all versions of snap Show documentation
Dynamic scripting for the JVM
package org.snapscript.tree.define;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import org.snapscript.core.ModifierType;
import org.snapscript.core.type.Type;
import org.snapscript.core.property.Property;
public class StaticConstantIndexer {
private final String[] reserved;
public StaticConstantIndexer(String... reserved) {
this.reserved = reserved;
}
public Set index(Type type) {
Set names = new HashSet();
if(type != null) {
List properties = type.getProperties();
for(Property property : properties) {
int modifiers = property.getModifiers();
String name = property.getName();
if(ModifierType.isStatic(modifiers)) {
names.add(name);
}
}
}
for(String name : reserved) {
names.add(name);
}
return names;
}
}