For annotation-based implementors.  Custom impl classes cannot be compiled, so this crude
parsing mechanism is used to determine image icon.  Kotlin limitation: file name must be the same as impl class name.
437521
private ActivityImplementor getImpl(File file) throws IOException {
        String contents = new String(Files.readAllBytes(file.toPath()));

        Matcher matcher = ACTIVITY_ANNOTATION.matcher(contents);
        if (matcher.find()) {
            // only implClass and image are needed (other values are hardcoded)
            String asset = file.getAbsolutePath().substring(assetLoc.getAbsolutePath().length() + 1).replace('/', '.');
            String implClass = asset.substring(0, asset.lastIndexOf('.'));
            String label = implClass.substring(implClass.lastIndexOf('.') + 1);
            String category = "com.centurylink.mdw.activity.types.GeneralActivity";
            String icon = "shape:activity";
            // set icon if specified
            String params = matcher.group(1);
            Matcher iconMatcher = ICON_VALUE.matcher(params);
            if (iconMatcher.find()) {
                icon = iconMatcher.group(1);
            }
            return new ActivityImplementor(implClass, category, label, icon, "{}");
        }
        return null;
    }
343908
function processIcon({ filePath, relativePath }, destPathRoot) {

    // The patterns we're looking for. Only write the new file if all are met.
    const pureImportRegex = /^import pure from 'recompose\/pure';\s*\n/gm;
    const componentDeclRegex = /let (\w+) = \(props\) =>/;
    const pureWrapRegex = /^((\w+)) = pure\(\1\);\s*\n/gm;

    // We'll const the component declaration while we're at it
    const componentDeclReplacement = 'const $1 = (props) =>';

    const destPath = pathUtils.resolve(destPathRoot, relativePath);

    return fs.readFileAsync(filePath, { encoding: 'UTF8' })
        .then(sourceCode => {

            const pureImportMatch = sourceCode.match(pureImportRegex);
            const componentDeclMatch = sourceCode.match(componentDeclRegex);
            const pureWrapMatch = sourceCode.match(pureWrapRegex);

            if (!(pureImportMatch && componentDeclMatch && pureWrapMatch)) {
                // Could not make sense of this file
                return {
                    filePath,
                    relativePath,
                    error: 'Could not recognise the source',
                };
            }

            // Update the source
            const newSourceCode = sourceCode
                .replace(pureImportRegex, '')
                .replace(pureWrapRegex, '')
                .replace(componentDeclRegex, componentDeclReplacement);

            return fs.writeFileAsync(destPath, newSourceCode, { encoding: 'UTF8' })
                .then(() => ({
                    filePath,
                    relativePath,
                    success: true,
                    className: componentDeclMatch[1],
                }))
        });
}
918950
@Override
	public void setCustomPostprocessors(Map<String, String> keysClassNames) {
		for (Entry<String, String> entry : keysClassNames.entrySet()) {
			ResourceBundlePostProcessor customProcessor = (ResourceBundlePostProcessor) ClassLoaderResourceUtils
					.buildObjectInstance((String) entry.getValue());
			boolean isVariantPostProcessor = customProcessor.getClass()
					.getAnnotation(VariantPostProcessor.class) != null;

			if (customProcessor instanceof BundlingProcessLifeCycleListener) {
				listeners.add((BundlingProcessLifeCycleListener) customProcessor);
			}
			String key = (String) entry.getKey();
			customPostProcessors.put(key, getCustomProcessorWrapper(customProcessor, key, isVariantPostProcessor));
		}
	}
242375
function() {
    this.uuid = undefined;
    this.icon = undefined;
    this.customIcon = undefined;
    this.fgColor = undefined;
    this.bgColor = undefined;
    this.overrideUrl = undefined;
    this.tags = [];
    this.times = new KdbxTimes();
    this.fields = {};
    this.binaries = {};
    this.autoType = {
        enabled: true, obfuscation: undefined, defaultSequence: undefined, items: []
    };
    this.history = [];
    this.parentGroup = undefined;
    this.customData = undefined;
    this._editState = undefined;
    Object.preventExtensions(this);
}
796309
@VisibleForTesting
  Map<String, Plugin> instantiatePluginClasses(Map<PluginClassLoaderDef, ClassLoader> classloaders) {
    // instantiate plugins
    Map<String, Plugin> instancesByPluginKey = new HashMap<>();
    for (Map.Entry<PluginClassLoaderDef, ClassLoader> entry : classloaders.entrySet()) {
      PluginClassLoaderDef def = entry.getKey();
      ClassLoader classLoader = entry.getValue();

      // the same classloader can be used by multiple plugins
      for (Map.Entry<String, String> mainClassEntry : def.getMainClassesByPluginKey().entrySet()) {
        String pluginKey = mainClassEntry.getKey();
        String mainClass = mainClassEntry.getValue();
        try {
          instancesByPluginKey.put(pluginKey, (Plugin) classLoader.loadClass(mainClass).newInstance());
        } catch (UnsupportedClassVersionError e) {
          throw new IllegalStateException(String.format("The plugin [%s] does not support Java %s",
            pluginKey, SystemUtils.JAVA_VERSION_TRIMMED), e);
        } catch (Throwable e) {
          throw new IllegalStateException(String.format(
            "Fail to instantiate class [%s] of plugin [%s]", mainClass, pluginKey), e);
        }
      }
    }
    return instancesByPluginKey;
  }
131346
public void finish() throws IOException {
        //Map<String,Set<TypeLibInfo>> byPackage = new HashMap<String,Set<TypeLibInfo>>();
        //for( TypeLibInfo tli : generatedTypeLibs ) {
        //    Set<TypeLibInfo> s = byPackage.get(tli.packageName);
        //    if(s==null)
        //        byPackage.put(tli.packageName,s=new HashSet<TypeLibInfo>());
        //    s.add(tli);
        //}

        // for( Map.Entry<String,Set<TypeLibInfo>> e : byPackage.entrySet() ) {
        for( Package pkg : packages.values() ) {
            LibBinder lib1 = pkg.typeLibs.iterator().next();

            if(referenceResolver.suppress(lib1.lib))
                continue;

            // generate ClassFactory
            IndentingWriter o = pkg.createWriter(lib1,"ClassFactory.java");
            lib1.generateHeader(o);

            o.printJavadoc("Defines methods to create COM objects");
            o.println("public abstract class ClassFactory {");
            o.in();

            o.println("private ClassFactory() {} // instanciation is not allowed");
            o.println();

            for( LibBinder lib : pkg.typeLibs ) {
                int len = lib.lib.count();
                for( int i=0; i<len; i++ ) {
                    ICoClassDecl t = lib.lib.getType(i).queryInterface(ICoClassDecl.class);
                    if(t==null)     continue;
                    if(!t.isCreatable())    continue;

                    declareFactoryMethod(o, t);
                    t.dispose();
                }
            }

            o.out();
            o.println("}");
            o.close();
        }
    }
490962
private boolean maybeParseImpliedThisMethod( int iOffset, int iLineNum, int iColumn, LazyLightweightParserState state, String strFunction, int markBeforeTypeArgs, int iLocBeforeTypeArgs )
  {
    if( getTokenizerInstructor() != null || getScriptPart() != null && TemplateGenerator.GS_TEMPLATE_PARSED.equals( getScriptPart().getId() ) )
    {
      // templates can only access static members from its optional super class
      return false;
    }

    ISymbol thisSym = getSymbolTable().getThisSymbolFromStackOrMap();
    if( thisSym == null || getPropertyNameFromMethodNameIncludingSetter( strFunction ) == null )
    {
      return false;
    }

    backtrack( markBeforeTypeArgs, iLocBeforeTypeArgs );

    // Make a synthetic 'this' qualifier
    Identifier root = new Identifier();
    root.setSymbol( thisSym, getSymbolTable() );
    root.setSynthetic( true );
    root.setType( thisSym.getType() );
    pushExpression( root );
    setLocation( getTokenizer().getTokenStart(), iLineNum, iColumn, true, true );
    popExpression();

    // Try to parse 'Xxx()' as implicitly qualified 'this.Xxx()'
    parseMemberAccess( root, MemberAccessKind.NORMAL, iOffset, strFunction, state, false );
    return true;
  }
205358
public final void classBodyDeclaration() throws RecognitionException {
		int classBodyDeclaration_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 21) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:359:5: ( ';' | ( 'static' )? block | ( modifier )* memberDecl )
			int alt35=3;
			switch ( input.LA(1) ) {
			case 52:
				{
				alt35=1;
				}
				break;
			case 106:
				{
				int LA35_2 = input.LA(2);
				if ( (LA35_2==121) ) {
					alt35=2;
				}
				else if ( (LA35_2==ENUM||LA35_2==Identifier||LA35_2==53||LA35_2==58||LA35_2==63||LA35_2==65||LA35_2==67||(LA35_2 >= 71 && LA35_2 <= 72)||LA35_2==77||LA35_2==83||LA35_2==85||(LA35_2 >= 92 && LA35_2 <= 94)||LA35_2==96||(LA35_2 >= 100 && LA35_2 <= 102)||(LA35_2 >= 105 && LA35_2 <= 107)||LA35_2==110||LA35_2==114||(LA35_2 >= 118 && LA35_2 <= 119)) ) {
					alt35=3;
				}

				else {
					if (state.backtracking>0) {state.failed=true; return;}
					int nvaeMark = input.mark();
					try {
						input.consume();
						NoViableAltException nvae =
							new NoViableAltException("", 35, 2, input);
						throw nvae;
					} finally {
						input.rewind(nvaeMark);
					}
				}

				}
				break;
			case 121:
				{
				alt35=2;
				}
				break;
			case ENUM:
			case Identifier:
			case 53:
			case 58:
			case 63:
			case 65:
			case 67:
			case 71:
			case 72:
			case 77:
			case 83:
			case 85:
			case 92:
			case 93:
			case 94:
			case 96:
			case 100:
			case 101:
			case 102:
			case 105:
			case 107:
			case 110:
			case 114:
			case 118:
			case 119:
				{
				alt35=3;
				}
				break;
			default:
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 35, 0, input);
				throw nvae;
			}
			switch (alt35) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:359:7: ';'
					{
					match(input,52,FOLLOW_52_in_classBodyDeclaration671); if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:360:7: ( 'static' )? block
					{
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:360:7: ( 'static' )?
					int alt33=2;
					int LA33_0 = input.LA(1);
					if ( (LA33_0==106) ) {
						alt33=1;
					}
					switch (alt33) {
						case 1 :
							// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:360:7: 'static'
							{
							match(input,106,FOLLOW_106_in_classBodyDeclaration679); if (state.failed) return;
							}
							break;

					}

					pushFollow(FOLLOW_block_in_classBodyDeclaration682);
					block();
					state._fsp--;
					if (state.failed) return;
					}
					break;
				case 3 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:361:7: ( modifier )* memberDecl
					{
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:361:7: ( modifier )*
					loop34:
					while (true) {
						int alt34=2;
						int LA34_0 = input.LA(1);
						if ( (LA34_0==58) ) {
							int LA34_6 = input.LA(2);
							if ( (LA34_6==Identifier) ) {
								alt34=1;
							}

						}
						else if ( (LA34_0==63||LA34_0==83||LA34_0==96||(LA34_0 >= 100 && LA34_0 <= 102)||(LA34_0 >= 106 && LA34_0 <= 107)||LA34_0==110||LA34_0==114||LA34_0==119) ) {
							alt34=1;
						}

						switch (alt34) {
						case 1 :
							// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:361:7: modifier
							{
							pushFollow(FOLLOW_modifier_in_classBodyDeclaration690);
							modifier();
							state._fsp--;
							if (state.failed) return;
							}
							break;

						default :
							break loop34;
						}
					}

					pushFollow(FOLLOW_memberDecl_in_classBodyDeclaration693);
					memberDecl();
					state._fsp--;
					if (state.failed) return;
					}
					break;

			}
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 21, classBodyDeclaration_StartIndex); }

		}
	}
438933
Symbol loadClass(Env<AttrContext> env, Name name) {
        try {
            ClassSymbol c = reader.loadClass(name);
            return isAccessible(env, c) ? c : new AccessError(c);
        } catch (ClassReader.BadClassFile err) {
            throw err;
        } catch (CompletionFailure ex) {
            return typeNotFound;
        }
    }
383606
private static ImmutableList<ErrorProneToken> annotationTokens(
      Tree tree, VisitorState state, int annotationEnd) {
    int endPos;
    if (tree instanceof JCMethodDecl) {
      JCMethodDecl methodTree = (JCMethodDecl) tree;
      endPos =
          methodTree.getBody() == null
              ? state.getEndPosition(methodTree)
              : methodTree.getBody().getStartPosition();
    } else if (tree instanceof JCVariableDecl) {
      endPos = ((JCVariableDecl) tree).getType().getStartPosition();
    } else if (tree instanceof JCClassDecl) {
      JCClassDecl classTree = (JCClassDecl) tree;
      endPos =
          classTree.getMembers().isEmpty()
              ? state.getEndPosition(classTree)
              : classTree.getMembers().get(0).getStartPosition();
    } else {
      throw new AssertionError();
    }
    return ErrorProneTokens.getTokens(
        state.getSourceCode().subSequence(annotationEnd, endPos).toString(), state.context);
  }
851013
public final void typeName() throws RecognitionException {
		int typeName_StartIndex = input.index();

		try {
			if ( state.backtracking>0 && alreadyParsedRule(input, 49) ) { return; }

			// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:527:5: ( Identifier | packageOrTypeName '.' Identifier )
			int alt66=2;
			int LA66_0 = input.LA(1);
			if ( (LA66_0==Identifier) ) {
				int LA66_1 = input.LA(2);
				if ( (LA66_1==EOF) ) {
					alt66=1;
				}
				else if ( (LA66_1==47) ) {
					alt66=2;
				}

				else {
					if (state.backtracking>0) {state.failed=true; return;}
					int nvaeMark = input.mark();
					try {
						input.consume();
						NoViableAltException nvae =
							new NoViableAltException("", 66, 1, input);
						throw nvae;
					} finally {
						input.rewind(nvaeMark);
					}
				}

			}

			else {
				if (state.backtracking>0) {state.failed=true; return;}
				NoViableAltException nvae =
					new NoViableAltException("", 66, 0, input);
				throw nvae;
			}

			switch (alt66) {
				case 1 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:527:9: Identifier
					{
					match(input,Identifier,FOLLOW_Identifier_in_typeName1745); if (state.failed) return;
					}
					break;
				case 2 :
					// src/main/resources/org/drools/compiler/semantics/java/parser/Java.g:528:9: packageOrTypeName '.' Identifier
					{
					pushFollow(FOLLOW_packageOrTypeName_in_typeName1755);
					packageOrTypeName();
					state._fsp--;
					if (state.failed) return;
					match(input,47,FOLLOW_47_in_typeName1757); if (state.failed) return;
					match(input,Identifier,FOLLOW_Identifier_in_typeName1759); if (state.failed) return;
					}
					break;

			}
		}
		catch (RecognitionException re) {
			reportError(re);
			recover(input,re);
		}
		finally {
			// do for sure before leaving
			if ( state.backtracking>0 ) { memoize(input, 49, typeName_StartIndex); }

		}
	}
954834
private <S extends Parameterizable> S getParameterizable(String classNameWithParams, String pkg) throws VectorPrintException {
      S st = (S) getParser(new StringReader(classNameWithParams))
          .setSettings(settings).setPackageName(pkg)
          .parseParameterizable();
      StylerFactoryHelper.initStylingObject(st, writer, document, imageLoader, layerManager, settings, (ElementProducer) imageLoader, this, this);
      if (st instanceof ImportPdf) {
         impdf.add((ImportPdf) st);
      } else if (st instanceof BaseStyler) {
         for (ImportPdf ipdf : impdf) {
            ipdf.addStyler((BaseStyler) st);
         }
      }
      if (st instanceof SimpleColumns) {
         imcol.add((SimpleColumns) st);
      } else if (st instanceof BaseStyler) {
         for (SimpleColumns sc : imcol) {
            sc.addStyler((BaseStyler) st);
         }
      }
      if (st instanceof ImportTiff) {
         imtiff.add((ImportTiff) st);
      } else if (st instanceof BaseStyler) {
         for (ImportTiff ipt : imtiff) {
            ipt.addStyler((BaseStyler) st);
         }
      }
      return st;
   }
1177183
void compileClass(Source javaSource, Source javaClass,
                    String sourcePath, boolean isMake)
    throws ClassNotFoundException
  {
    try {
      JavaCompilerUtil compiler = JavaCompilerUtil.create(getClassLoader());
      compiler.setClassDir(_classDir);
      compiler.setSourceDir(_sourceDir);
      if (_encoding != null)
        compiler.setEncoding(_encoding);
      compiler.setArgs(_args);
      compiler.setCompileParent(! isMake);
      compiler.setSourceExtension(_sourceExt);
      if (_compiler != null)
        compiler.setCompiler(_compiler);

      //LineMap lineMap = new LineMap(javaFile.getNativePath());
      // The context path is obvious from the browser url
      //lineMap.add(name.replace('.', '/') + _sourceExt, 1, 1);

      // Force this into a relative path so different compilers will work
      String prefix = _sourceDir.getPath();
      String full = javaSource.getPath();

      String source;
      if (full.startsWith(prefix)) {
        source = full.substring(prefix.length());
        if (source.startsWith("/"))
          source = source.substring(1);
      }
      else
        source = javaSource.getPath();

      /*
      if (javaSource.canRead() && javaClass.exists())
        javaClass.remove();
      */
          
      compiler.compileIfModified(source, null);
    } catch (Exception e) {
      //getClassLoader().addDependency(new Depend(javaSource));

      log.log(Level.FINEST, e.toString(), e);

      // Compile errors are wrapped in a special ClassNotFound class
      // so the server can give a nice error message
      throw new CompileClassNotFound(e);
    }
  }
610054
private static boolean parseElementInternal(
      XmlPullParser parser,
      ArrayList<Type> context,
      Object destination,
      Type valueType,
      XmlNamespaceDictionary namespaceDictionary,
      CustomizeParser customizeParser)
      throws IOException, XmlPullParserException {
    // TODO(yanivi): method is too long; needs to be broken down into smaller methods and comment
    // better
    GenericXml genericXml = destination instanceof GenericXml ? (GenericXml) destination : null;
    @SuppressWarnings("unchecked")
    Map<String, Object> destinationMap =
        genericXml == null && destination instanceof Map<?, ?> ? Map.class.cast(destination) : null;

    // if there is a class, we want to put the data into, create the class Info for this
    ClassInfo classInfo =
        destinationMap != null || destination == null ? null : ClassInfo.of(destination.getClass());
    if (parser.getEventType() == XmlPullParser.START_DOCUMENT) {
      parser.next();
    }
    parseNamespacesForElement(parser, namespaceDictionary);
    // generic XML
    if (genericXml != null) {
      genericXml.namespaceDictionary = namespaceDictionary;
      String name = parser.getName();
      String namespace = parser.getNamespace();
      String alias = namespaceDictionary.getNamespaceAliasForUriErrorOnUnknown(namespace);
      genericXml.name = alias.length() == 0 ? name : alias + ":" + name;
    }
    // attributes
    if (destination != null) {
      int attributeCount = parser.getAttributeCount();
      for (int i = 0; i < attributeCount; i++) {
        // TODO(yanivi): can have repeating attribute values, e.g. "@a=value1 @a=value2"?
        String attributeName = parser.getAttributeName(i);
        String attributeNamespace = parser.getAttributeNamespace(i);
        String attributeAlias =
            attributeNamespace.length() == 0
                ? ""
                : namespaceDictionary.getNamespaceAliasForUriErrorOnUnknown(attributeNamespace);
        String fieldName = getFieldName(true, attributeAlias, attributeNamespace, attributeName);
        Field field = classInfo == null ? null : classInfo.getField(fieldName);
        parseAttributeOrTextContent(
            parser.getAttributeValue(i),
            field,
            valueType,
            context,
            destination,
            genericXml,
            destinationMap,
            fieldName);
      }
    }
    Field field;
    ArrayValueMap arrayValueMap = new ArrayValueMap(destination);
    boolean isStopped = false;
    // TODO(yanivi): support Void type as "ignore" element/attribute
    main:
    while (true) {
      int event = parser.next();
      switch (event) {
        case XmlPullParser.END_DOCUMENT:
          isStopped = true;
          break main;
        case XmlPullParser.END_TAG:
          isStopped =
              customizeParser != null
                  && customizeParser.stopAfterEndTag(parser.getNamespace(), parser.getName());
          break main;
        case XmlPullParser.TEXT:
          // parse text content
          if (destination != null) {
            field = classInfo == null ? null : classInfo.getField(TEXT_CONTENT);
            parseAttributeOrTextContent(
                parser.getText(),
                field,
                valueType,
                context,
                destination,
                genericXml,
                destinationMap,
                TEXT_CONTENT);
          }
          break;
        case XmlPullParser.START_TAG:
          if (customizeParser != null
              && customizeParser.stopBeforeStartTag(parser.getNamespace(), parser.getName())) {
            isStopped = true;
            break main;
          }
          if (destination == null) {
            parseTextContentForElement(parser, context, true, null);
          } else {
            // element
            parseNamespacesForElement(parser, namespaceDictionary);
            String namespace = parser.getNamespace();
            String alias = namespaceDictionary.getNamespaceAliasForUriErrorOnUnknown(namespace);

            //  get the "real" field name of the
            String fieldName = getFieldName(false, alias, namespace, parser.getName());

            // fetch the field from the classInfo
            field = classInfo == null ? null : classInfo.getField(fieldName);
            Type fieldType = field == null ? valueType : field.getGenericType();
            fieldType = Data.resolveWildcardTypeOrTypeVariable(context, fieldType);
            // field type is now class, parameterized type, or generic array type
            // resolve a parameterized type to a class
            Class<?> fieldClass = fieldType instanceof Class<?> ? (Class<?>) fieldType : null;
            if (fieldType instanceof ParameterizedType) {
              fieldClass = Types.getRawClass((ParameterizedType) fieldType);
            }
            boolean isArray = Types.isArray(fieldType);
            // text content
            boolean ignore = field == null && destinationMap == null && genericXml == null;
            // is the field an Enum
            boolean isEnum = fieldClass != null && fieldClass.isEnum();
            if (ignore || Data.isPrimitive(fieldType) || isEnum) {
              int level = 1;
              while (level != 0) {
                switch (parser.next()) {
                  case XmlPullParser.END_DOCUMENT:
                    isStopped = true;
                    break main;
                  case XmlPullParser.START_TAG:
                    level++;
                    break;
                  case XmlPullParser.END_TAG:
                    level--;
                    break;
                  case XmlPullParser.TEXT:
                    if (!ignore && level == 1) {
                      parseAttributeOrTextContent(
                          parser.getText(),
                          field,
                          valueType,
                          context,
                          destination,
                          genericXml,
                          destinationMap,
                          fieldName);
                    }
                    break;
                  default:
                    break;
                }
              }
            } else if (fieldType == null
                || fieldClass != null && Types.isAssignableToOrFrom(fieldClass, Map.class)) {
              // store the element as a map
              Map<String, Object> mapValue = Data.newMapInstance(fieldClass);
              int contextSize = context.size();
              if (fieldType != null) {
                context.add(fieldType);
              }
              Type subValueType =
                  fieldType != null && Map.class.isAssignableFrom(fieldClass)
                      ? Types.getMapValueParameter(fieldType)
                      : null;
              subValueType = Data.resolveWildcardTypeOrTypeVariable(context, subValueType);
              isStopped =
                  parseElementInternal(
                      parser,
                      context,
                      mapValue,
                      subValueType,
                      namespaceDictionary,
                      customizeParser);
              if (fieldType != null) {
                context.remove(contextSize);
              }
              if (destinationMap != null) {
                // map but not GenericXml: store as ArrayList of elements
                @SuppressWarnings("unchecked")
                Collection<Object> list = (Collection<Object>) destinationMap.get(fieldName);
                if (list == null) {
                  list = new ArrayList<Object>(1);
                  destinationMap.put(fieldName, list);
                }
                list.add(mapValue);
              } else if (field != null) {
                // not a map: store in field value
                FieldInfo fieldInfo = FieldInfo.of(field);
                if (fieldClass == Object.class) {
                  // field is an Object: store as ArrayList of element maps
                  @SuppressWarnings("unchecked")
                  Collection<Object> list = (Collection<Object>) fieldInfo.getValue(destination);
                  if (list == null) {
                    list = new ArrayList<Object>(1);
                    fieldInfo.setValue(destination, list);
                  }
                  list.add(mapValue);
                } else {
                  // field is a Map: store as a single element map
                  fieldInfo.setValue(destination, mapValue);
                }
              } else {
                // GenericXml: store as ArrayList of elements
                GenericXml atom = (GenericXml) destination;
                @SuppressWarnings("unchecked")
                Collection<Object> list = (Collection<Object>) atom.get(fieldName);
                if (list == null) {
                  list = new ArrayList<Object>(1);
                  atom.set(fieldName, list);
                }
                list.add(mapValue);
              }
            } else if (isArray || Types.isAssignableToOrFrom(fieldClass, Collection.class)) {
              // TODO(yanivi): some duplicate code here; isolate into reusable methods
              FieldInfo fieldInfo = FieldInfo.of(field);
              Object elementValue = null;
              Type subFieldType =
                  isArray
                      ? Types.getArrayComponentType(fieldType)
                      : Types.getIterableParameter(fieldType);
              Class<?> rawArrayComponentType =
                  Types.getRawArrayComponentType(context, subFieldType);
              subFieldType = Data.resolveWildcardTypeOrTypeVariable(context, subFieldType);
              Class<?> subFieldClass =
                  subFieldType instanceof Class<?> ? (Class<?>) subFieldType : null;
              if (subFieldType instanceof ParameterizedType) {
                subFieldClass = Types.getRawClass((ParameterizedType) subFieldType);
              }
              boolean isSubEnum = subFieldClass != null && subFieldClass.isEnum();
              if (Data.isPrimitive(subFieldType) || isSubEnum) {
                elementValue = parseTextContentForElement(parser, context, false, subFieldType);
              } else if (subFieldType == null
                  || subFieldClass != null
                      && Types.isAssignableToOrFrom(subFieldClass, Map.class)) {
                elementValue = Data.newMapInstance(subFieldClass);
                int contextSize = context.size();
                if (subFieldType != null) {
                  context.add(subFieldType);
                }
                Type subValueType =
                    subFieldType != null && Map.class.isAssignableFrom(subFieldClass)
                        ? Types.getMapValueParameter(subFieldType)
                        : null;
                subValueType = Data.resolveWildcardTypeOrTypeVariable(context, subValueType);
                isStopped =
                    parseElementInternal(
                        parser,
                        context,
                        elementValue,
                        subValueType,
                        namespaceDictionary,
                        customizeParser);
                if (subFieldType != null) {
                  context.remove(contextSize);
                }
              } else {
                elementValue = Types.newInstance(rawArrayComponentType);
                int contextSize = context.size();
                context.add(fieldType);
                isStopped =
                    parseElementInternal(
                        parser, context, elementValue, null, namespaceDictionary, customizeParser);
                context.remove(contextSize);
              }
              if (isArray) {
                // array field: add new element to array value map
                if (field == null) {
                  arrayValueMap.put(fieldName, rawArrayComponentType, elementValue);
                } else {
                  arrayValueMap.put(field, rawArrayComponentType, elementValue);
                }
              } else {
                // collection: add new element to collection
                @SuppressWarnings("unchecked")
                Collection<Object> collectionValue =
                    (Collection<Object>)
                        (field == null
                            ? destinationMap.get(fieldName)
                            : fieldInfo.getValue(destination));
                if (collectionValue == null) {
                  collectionValue = Data.newCollectionInstance(fieldType);
                  setValue(
                      collectionValue, field, destination, genericXml, destinationMap, fieldName);
                }
                collectionValue.add(elementValue);
              }
            } else {
              // not an array/iterable or a map, but we do have a field
              Object value = Types.newInstance(fieldClass);
              int contextSize = context.size();
              context.add(fieldType);
              isStopped =
                  parseElementInternal(
                      parser, context, value, null, namespaceDictionary, customizeParser);
              context.remove(contextSize);
              setValue(value, field, destination, genericXml, destinationMap, fieldName);
            }
          }
          if (isStopped || parser.getEventType() == XmlPullParser.END_DOCUMENT) {
            isStopped = true;
            break main;
          }
          break; // break Switch;
      } // end -- switch (event)
    } // end -- main: while (true)
    arrayValueMap.setValues();
    return isStopped;
  }
804377
@SuppressWarnings("unchecked")
    @VisibleForTesting
    Map<String, Class<? extends Service>> mapEventSources() throws IOException {

        /* Obtains all classpath's top level classes */
        ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
        Set<ClassPath.ClassInfo> classes = ClassPath.from(classLoader).getAllClasses();
        ClassLoaderRepository repository = new ClassLoaderRepository(classLoader);
        LOGGER.info("Scanning classpath for EventHandlers....");

        /* iterates over all classes, filter by HandlesEvent annotation and transforms stream to needed form */
        Map<String, Class<? extends Service>> collected = classes.parallelStream()
                /* loads class infos */
                .map(classInfo -> {
                    try {
                        /* sometimes exception occurs during class loading. Return empty/absent in this case */
                        return Optional.of(repository.loadClass(classInfo.getName()));
                    } catch (ClassNotFoundException e) {
                        LOGGER.trace("Class cannot be loaded: {}", classInfo.getName(), e);
                        return Optional.<JavaClass>empty();
                    }
                })
                /* filters classes which is present and marked with EventSource annotation */
                .filter(((Predicate<Optional<JavaClass>>) Optional::isPresent)
                        .and(javaClassOptional -> {
                            return Arrays.stream(javaClassOptional.get().getAnnotationEntries()).anyMatch(annotationEntry -> {
                                return Type.getType(annotationEntry.getAnnotationType()).toString().equals(EventSource.class.getCanonicalName());
                            });
                        })
                        .and(javaClassOptional -> {
                            try {
                                return Arrays.stream(javaClassOptional.get().getAllInterfaces()).anyMatch(iface -> {
                                    return iface.getClassName().equals(Service.class.getCanonicalName());
                                });
                            } catch (ClassNotFoundException e) {
                                LOGGER.trace("Class annotations cannot be loaded: {}", javaClassOptional.get().getClassName(), e);
                                return false;
                            }
                        }))
                /* transforms from Optional<JavaClass> to Class (obtaining values from Optionals) */
                .map(javaClassOptional -> {
                    try {
                        return (Class<? extends Service>) classLoader.loadClass(javaClassOptional.get().getClassName());
                    } catch (ClassNotFoundException e) {
                        LOGGER.trace("Class cannot be loaded: {}", javaClassOptional.get().getClassName(), e);
                        return null;
                    }
                })
                .filter(Objects::nonNull)
                .collect(Collectors.toMap(clazz -> clazz.getAnnotation(EventSource.class).value(), clazz -> clazz));

        LOGGER.info("Found {} event handlers", collected.size());
        return collected;
    }
592845
private boolean isImplConditHandlerClass(Class<?> implCls) {
        Class<?>[] classes = implCls.getInterfaces();
        if (classes == null) {
            return false;
        }

        // 循环判断其接口是否含有'IConditHandler'接口.
        for (Class<?> cls: classes) {
            if (IConditHandler.class.isAssignableFrom(cls)) {
                return true;
            }
        }
        return false;
    }
991326
function(hljs) {
  var ANNOTATION = {
    className: 'annotation', begin: '@[A-Za-z]+'
  };
  var STRING = {
    className: 'string',
    begin: 'u?r?"""', end: '"""',
    relevance: 10
  };
  var SYMBOL = {
    className: 'symbol',
    begin: '\'\\w[\\w\\d_]*(?!\')'
  };
  return {
    keywords:
      'type yield lazy override def with val var false true sealed abstract private trait ' +
      'object null if for while throw finally protected extends import final return else ' +
      'break new catch super class case package default try this match continue throws',
    contains: [
      {
        className: 'javadoc',
        begin: '/\\*\\*', end: '\\*/',
        contains: [{
          className: 'javadoctag',
          begin: '@[A-Za-z]+'
        }],
        relevance: 10
      },
      hljs.C_LINE_COMMENT_MODE, hljs.C_BLOCK_COMMENT_MODE,
      STRING, hljs.QUOTE_STRING_MODE,
      SYMBOL,
      {
        className: 'class',
        begin: '((case )?class |object |trait )', // beginKeywords won't work because a single "case" shouldn't start this mode
        end: '({|$)', excludeEnd: true,
        illegal: ':',
        keywords: 'case class trait object',
        contains: [
          {
            beginKeywords: 'extends with',
            relevance: 10
          },
          hljs.UNDERSCORE_TITLE_MODE,
          {
            className: 'params',
            begin: '\\(', end: '\\)',
            contains: [
              hljs.QUOTE_STRING_MODE, STRING,
              ANNOTATION
            ]
          }
        ]
      },
      hljs.C_NUMBER_MODE,
      ANNOTATION
    ]
  };
}