
org.snapscript.tree.StaticImportMatcher Maven / Gradle / Ivy
package org.snapscript.tree;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.snapscript.core.ModifierType;
import org.snapscript.core.function.Function;
import org.snapscript.core.property.Property;
import org.snapscript.core.type.Type;
public class StaticImportMatcher {
public StaticImportMatcher() {
super();
}
public List matchFunctions(Type type, String prefix) throws Exception {
List functions = type.getFunctions();
if (!functions.isEmpty()) {
List matches = new ArrayList();
for (Function function : functions) {
int modifiers = function.getModifiers();
if (ModifierType.isStatic(modifiers) && ModifierType.isPublic(modifiers)) {
String name = function.getName();
if (prefix == null || prefix.equals(name)) {
matches.add(function);
}
}
}
return matches;
}
return Collections.emptyList();
}
public List matchProperties(Type type, String prefix) throws Exception {
List properties = type.getProperties();
if (!properties.isEmpty()) {
List matches = new ArrayList();
for (Property property : properties) {
int modifiers = property.getModifiers();
if (ModifierType.isStatic(modifiers) && ModifierType.isPublic(modifiers)) {
String name = property.getName();
if (prefix == null || prefix.equals(name)) {
matches.add(property);
}
}
}
return matches;
}
return Collections.emptyList();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy