private boolean addClassMemberStaticImports(String packageName) { try { Class c = Class.forName(packageName); initImports(); if (c.isEnum()) { //noinspection unchecked for (Enum e : (EnumSet<?>) EnumSet.allOf(c)) { imports.put(e.name(), e); } return true; } else { for (Field f : c.getDeclaredFields()) { if ((f.getModifiers() & (Modifier.STATIC | Modifier.PUBLIC)) != 0) { imports.put(f.getName(), f.get(null)); } } } } catch (ClassNotFoundException e) { // do nothing. } catch (IllegalAccessException e) { throw new RuntimeException("error adding static imports for: " + packageName, e); } return false; }
public void addAllImports(Map<String, Object> imports) { if (imports == null) return; initImports(); Object o; for (Map.Entry<String, Object> entry : imports.entrySet()) { if ((o = entry.getValue()) instanceof Method) { this.imports.put(entry.getKey(), new MethodStub((Method) o)); } else { this.imports.put(entry.getKey(), o); } } }
public void setAllImports(Map<String, Object> imports) { initImports(); this.imports.clear(); if (imports != null) this.imports.putAll(imports); }
public void addImport(String name, MethodStub method) { initImports(); this.imports.put(name, method); }
public void addImport(String name, Proto proto) { initImports(); this.imports.put(name, proto); }
public void addImport(String name, Class cls) { initImports(); this.imports.put(name, cls); }
public void addImport(Class cls) { initImports(); addImport(cls.getSimpleName(), cls); }