if (variables == null)
return Collections. emptyList();
<<<<<<< HEAD:errai-codegen/src/main/java/org/jboss/errai/codegen/framework/Context.java
public void addLiteralizableClasses(Collection> clazzes) {
for (Class> cls : clazzes) {
addLiteralizableClass(cls);
}
}
public void addLiteralizableMetaClasses(Collection clazzes) {
for (MetaClass cls : clazzes) {
addLiteralizableClass(cls);
}
}
/**
* Mark a class "literalizable". Meaning that all classes that are assignable to this type, are candidates for
* reification to code snapshots for this context and all subcontexts. See {@link SnapshotMaker} for further
* details.
*
* @param clazz the class, interface or superclass to be considered literalizable.
*/
public void addLiteralizableClass(Class clazz) {
addLiteralizableClass(MetaClassFactory.get(clazz));
}
/**
* Mark a class "literalizable". Meaning that all classes that are assignable to this type, are candidates for
* reification to code snapshots for this context and all subcontexts. See {@link SnapshotMaker} for further
* details.
*
* @param clazz the class, interface or superclass to be considered literalizable.
*/
public void addLiteralizableClass(MetaClass clazz) {
literalizableClasses.add(clazz);
}
/**
* Returns true if the specified class is literalizable.
*
* @see #addLiteralizableClass(Class)
* @param clazz the class, interface or superclass to be tested if literalizable
* @return true if the specified class is literalizable
*/
public boolean isLiteralizableClass(final Class clazz) {
return isLiteralizableClass(MetaClassFactory.get(clazz));
}
/**
* Returns true if the specified class is literalizable.
*
* @see #addLiteralizableClass(org.jboss.errai.codegen.framework.meta.MetaClass)
* @param clazz the class, interface or superclass to be tested if literalizable
* @return true if the specified class is literalizable
*/
public boolean isLiteralizableClass(final MetaClass clazz) {
return getLiteralizableTargetType(clazz) != null;
}
/**
* Returns the literalizable target type for any matching subtype. Meaning, that if say, the type
* is a subtype of the interface com.bar.Foo, which is itself marked literalizable, this method will return
* a reference to the java.lang.Class instance for com.bar.Foo
*
* @param clazz the class, interface or superclass to obtain a literalizable target type for.
* @return the literalizable target type that matches {@param clazz}. If there are no matches, returns null.
*/
public Class getLiteralizableTargetType(final Class clazz) {
return getLiteralizableTargetType(MetaClassFactory.get(clazz));
}
/**
* Returns the literalizable target type for any matching subtype. Meaning, that if say, the type
* is a subtype of the interface com.bar.Foo, which is itself marked literalizable, this method will return
* a reference to the java.lang.Class instance for com.bar.Foo
*
* @param clazz the class, interface or superclass to obtain a literalizable target type for.
* @return the literalizable target type that matches {@param clazz}. If there are no matches, returns null.
*/
public Class getLiteralizableTargetType(final MetaClass clazz) {
Context ctx = this;
do {
MetaClass cls = clazz;
do {
if (ctx.literalizableClasses.contains(cls)) return cls.asClass();
for (MetaClass iface : cls.getInterfaces()) {
if (ctx.literalizableClasses.contains(iface)) return iface.asClass();
}
}
while ((cls = cls.getSuperClass()) != null);
}
while ((ctx = ctx.parent) != null);
return null;
}
=======
return variables.values();
}
/**
* Returns all variables in this scope (does not include variables of parent scopes).
*
* @return map of variable name to {@link Variable}, empty if no variables are in scope.
*/
public Map getVariables() {
if (variables == null)
return Collections. emptyMap();
return Collections. unmodifiableMap(variables);
}
/**
* Attaches a class to the current scope.
*
* @param clazz class to attach.
*/
public void attachClass(MetaClass clazz) {
this.classContexts.add(clazz);
}
/**
* Checks if automatic import is active.
*
* @return true if auto import active, otherwise false.
*/
>>>>>>> f2af4d2dc2686b08868316271c089b6ecc1156fa:errai-codegen/src/main/java/org/jboss/errai/codegen/Context.java
public boolean isAutoImportActive() {
return autoImportActive;
} |