/*
ClassDescriptor
553596
private void processClassDescriptorCollection(final Object classDescriptorCollection) {
        if (classDescriptorCollection == null || !isCastable("java.util.Collection", classDescriptorCollection.getClass())) {
            return;
        }

        final Collection<?> c = (Collection<?>) classDescriptorCollection;
        for (Object descriptor : c) {
            processClassDescriptorObject(descriptor);
        }
    }
1243159
public static Descriptor getDescriptor(Class<?> cls) throws IOException {

        String idl = ProtobufIDLGenerator.getIDL(cls);
        ProtoFile file = ProtoSchemaParser.parse(ProtobufIDLProxy.DEFAULT_FILE_NAME, idl);

        FileDescriptorProtoPOJO fileDescriptorProto = new FileDescriptorProtoPOJO();

        fileDescriptorProto.name = ProtobufIDLProxy.DEFAULT_FILE_NAME;
        fileDescriptorProto.pkg = file.getPackageName();
        fileDescriptorProto.dependencies = file.getDependencies();
        fileDescriptorProto.publicDependency = convertList(file.getPublicDependencies());
        fileDescriptorProto.weakDependency = null; // XXX

        fileDescriptorProto.messageTypes = new ArrayList<DescriptorProtoPOJO>();
        fileDescriptorProto.enumTypes = new ArrayList<EnumDescriptorProtoPOJO>();
        fileDescriptorProto.services = new ArrayList<ServiceDescriptorProtoPOJO>();

        Set<String> messageSet = new HashSet<String>();
        Set<String> enumSet = new HashSet<String>();

        List<com.squareup.protoparser.Type> typeElements = file.getTypes();
        if (typeElements != null) {

            for (com.squareup.protoparser.Type typeElement : typeElements) {
                if (typeElement instanceof MessageType) {
                    messageSet.add(typeElement.getName());
                } else if (typeElement instanceof EnumType) {
                    enumSet.add(typeElement.getName());
                }

            }

            for (com.squareup.protoparser.Type typeElement : typeElements) {

                if (typeElement instanceof MessageType) {
                    fileDescriptorProto.messageTypes.add(
                            getDescritorProtoPOJO(fileDescriptorProto, (MessageType) typeElement, messageSet, enumSet));
                } else if (typeElement instanceof EnumType) {
                    fileDescriptorProto.enumTypes.add(
                            getDescritorProtoPOJO(fileDescriptorProto, (EnumType) typeElement, messageSet, enumSet));
                }

            }
        }

        FileDescriptorProto fileproto;
        try {
            Codec<FileDescriptorProtoPOJO> descriptorCodec = ProtobufProxy.create(FileDescriptorProtoPOJO.class,
                    ProtobufProxy.isCacheEnabled(), ProtobufProxy.OUTPUT_PATH.get());
            byte[] bs = descriptorCodec.encode(fileDescriptorProto);
            fileproto = FileDescriptorProto.parseFrom(bs);
        } catch (InvalidProtocolBufferException e) {
            throw new IOException("Failed to parse protocol buffer descriptor for generated code.", e);
        }

        FileDescriptor fileDescriptor;
        try {
            fileDescriptor =
                    FileDescriptor.buildFrom(fileproto, new com.google.protobuf.Descriptors.FileDescriptor[] {});
        } catch (DescriptorValidationException e) {
            throw new IOException(e.getMessage(), e);
        }

        return fileDescriptor.getMessageTypes().get(0);
    }
572422
private ClassDescriptor getNullnessAnnotationClassDescriptor(NullnessAnnotation n) {
        if (n == NullnessAnnotation.CHECK_FOR_NULL) {
            return JSR305NullnessAnnotations.CHECK_FOR_NULL;
        } else if (n == NullnessAnnotation.NONNULL) {
            return JSR305NullnessAnnotations.NONNULL;
        } else if (n == NullnessAnnotation.NULLABLE) {
            return JSR305NullnessAnnotations.NULLABLE;
        } else if (n == NullnessAnnotation.UNKNOWN_NULLNESS) {
            return JSR305NullnessAnnotations.NULLABLE;
        } else {
            throw new IllegalArgumentException("Unknown NullnessAnnotation: " + n);
        }
    }
1187939
public static String getDescriptor(final Class<?> c) {
		StringBuilder sb = new StringBuilder();
        getDescriptor(sb, c);
        return sb.toString();
    }
130505
private ClassDefinition extractClassDefinition(
      Node targetName, Node callNode) {

    JSDocInfo classInfo = NodeUtil.getBestJSDocInfo(targetName);

    // name = goog.defineClass(superClass, {...}, [modifier, ...])
    Node superClass = NodeUtil.getArgumentForCallOrNew(callNode, 0);
    if (superClass == null
        || (!superClass.isNull()
            && !superClass.isQualifiedName()
            && !NodeUtil.isCallTo(superClass, "goog.module.get"))) {
      compiler.report(JSError.make(callNode, GOOG_CLASS_SUPER_CLASS_NOT_VALID));
      return null;
    }

    if (NodeUtil.isNullOrUndefined(superClass)
        || superClass.matchesQualifiedName("Object")) {
      superClass = null;
    }

    Node description = NodeUtil.getArgumentForCallOrNew(callNode, 1);
    if (!validateObjLit(description, callNode)) {
      // Errors will be reported in the validate method. Keeping here clean
      return null;
    }

    int paramCount = callNode.getChildCount() - 1;
    if (paramCount > 2) {
      compiler.report(JSError.make(callNode, GOOG_CLASS_UNEXPECTED_PARAMS));
      return null;
    }

    Node constructor = extractProperty(description, "constructor");
    if (classInfo != null && classInfo.isInterface()) {
      if (constructor != null) {
        compiler.report(JSError.make(description, GOOG_CLASS_CONSTRUCTOR_ON_INTERFACE));
        return null;
      }
    } else if (constructor == null) {
      // report missing constructor
      compiler.report(JSError.make(description, GOOG_CLASS_CONSTRUCTOR_MISSING));
      return null;
    } else {
      if (!constructor.isFunction()) {
        compiler.report(JSError.make(constructor, GOOG_CLASS_CONSTRUCTOR_NOT_VALID));
      }
    }

    if (constructor == null) {
      constructor = IR.function(
          IR.name("").srcref(callNode),
          IR.paramList().srcref(callNode),
          IR.block().srcref(callNode));
      constructor.srcref(callNode);
      compiler.reportChangeToChangeScope(constructor);
    }

    JSDocInfo info = NodeUtil.getBestJSDocInfo(constructor);

    Node classModifier = null;
    Node statics = null;
    Node staticsProp = extractProperty(description, "statics");
    if (staticsProp != null) {
      if (staticsProp.isObjectLit()){
        if (!validateObjLit(staticsProp, staticsProp.getParent())) {
          // Errors will be reported in the validate method. Keeping here clean
          return null;
        }
        statics = staticsProp;
      } else if (staticsProp.isFunction()) {
        classModifier = staticsProp;
      } else {
        compiler.report(
            JSError.make(staticsProp, GOOG_CLASS_STATICS_NOT_VALID));
        return null;
      }
    }

    if (statics == null) {
      statics = IR.objectlit();
    }

    // Ok, now rip apart the definition into its component pieces.
    // Remove the "special" property key nodes.
    maybeDetach(constructor.getParent());
    maybeDetach(statics.getParent());
    if (classModifier != null) {
      maybeDetach(classModifier.getParent());
    }
    ClassDefinition def = new ClassDefinition(
        targetName,
        classInfo,
        maybeDetach(superClass),
        new MemberDefinition(info, null, maybeDetach(constructor)),
        objectLitToList(maybeDetach(statics)),
        objectLitToList(description),
        maybeDetach(classModifier));
    return def;
  }
1099865
function Descriptor(attributes) {

    var instance = this,

        cur = 'descriptor: attributes argument: ',

        err = function (msg) {
            throw new TypeError(cur + msg);
        },
        getType = function (value) {
            if (typeof value === 'string')
                return value;
            if (Array.isArray(value))
                return getTypeArray(value);
            if (typeof value === 'function') {
                if (Type[value]) return Type[value];
                else {
                    instance.isClassType = true;
                    instance.className = value.name && value.name !== 'ClassWrapper' ? value.name : 'required class';
                    return value;
                }
            }
            if (value instanceof Schema) {
                instance.isSchemaType = true;
                return value;
            }
            return false;
        },

        getTypeArray = function (typeArray) {
            if (typeArray.length !== 1)
                err('type array must contain exactly one element specifying type');
            var type = typeArray[0];
            if (Array.isArray(type))
                err('nested type arrays are not supported');
            type = getType(typeArray[0]);
            if (type) {
                instance.isTypeArray = true;
                return type;
            }
            err('invalid type');
        };

    getType = getType.bind(this);
    getTypeArray = getTypeArray.bind(this);

    if (typeof attributes !== 'object') err('missing or invalid');

    if (attributes.name === undefined)
        return err('missing required attribute: name');

    // ensure name is first attribute
    instance.name = attributes.name;
    for (var attr in attributes) {
        if (attributes.hasOwnProperty(attr)) {
            instance[attr] = attributes[attr];
        }
    }
    if (instance.type) {
        instance.type = getType(instance.type);
        if (!instance.type) err('invalid type');
    }

    return instance;
}
20664
public static TypeDesc forDescriptor(final String desc) throws IllegalArgumentException {
        TypeDesc type = cDescriptorsToInstances.get(desc);
        if (type != null) {
            return type;
        }

        // TODO: Support generics in descriptor.

        String rootDesc = desc;
        int cursor = 0;
        int dim = 0;
        try {
            char c;
            while ((c = rootDesc.charAt(cursor++)) == '[') {
                dim++;
            }

            switch (c) {
            case 'V':
                type = VOID;
                break;
            case 'Z':
                type = BOOLEAN;
                break;
            case 'C':
                type = CHAR;
                break;
            case 'B':
                type = BYTE;
                break;
            case 'S':
                type = SHORT;
                break;
            case 'I':
                type = INT;
                break;
            case 'J':
                type = LONG;
                break;
            case 'F':
                type = FLOAT;
                break;
            case 'D':
                type = DOUBLE;
                break;
            case 'L':
                if (dim > 0) {
                    rootDesc = rootDesc.substring(dim);
                    cursor = 1;
                }
                StringBuffer name = new StringBuffer(rootDesc.length() - 2);
                while ((c = rootDesc.charAt(cursor++)) != ';') {
                    if (c == '/') {
                        c = '.';
                    }
                    name.append(c);
                }
                type = intern(new ObjectType(rootDesc, name.toString()));
                break;
            default:
                throw invalidDescriptor(desc);
            }
        } catch (NullPointerException e) {
            throw invalidDescriptor(desc);
        } catch (IndexOutOfBoundsException e) {
            throw invalidDescriptor(desc);
        }

        if (cursor != rootDesc.length()) {
            throw invalidDescriptor(desc);
        }

        while (--dim >= 0) {
            type = type.toArrayType();
        }

        cDescriptorsToInstances.put(desc, type);
        return type;
    }
881364
public void setDescriptor(String descriptor)
  {
    _descriptor = descriptor;

    if (_jClass != null)
      _jClass.getConstantPool().addUTF8(descriptor);
  }
14498
static private Class findClassFor(String s) throws ClassNotFoundException
	{ 
		int endClassIndex = s.indexOf('[');
		if (endClassIndex>=0) s = s.substring(0,endClassIndex);
		try {
			return Class.forName(s);
		} catch (ClassNotFoundException e) {
			return Class.forName("com.wcohen.ss."+s);
		}
	}
987357
private static boolean descriptorToBeIgnoredByJackson(Class<?> clazz, PropertyDescriptor descriptor) {

		Field descriptorField = ReflectionUtils.findField(clazz, descriptor.getName());

		return descriptorField == null //
				? false //
				: toBeIgnoredByJackson(AnnotationUtils.getAnnotations(descriptorField));
	}
1326631
private static String getTypeDescription(ClassNode c, boolean end) {
        ClassNode d = c;
        if (ClassHelper.isPrimitiveType(d.redirect())) {
            d = d.redirect();
        }

        String desc = TypeUtil.getDescriptionByType(d);

        if (!end && desc.endsWith(";")) {
            desc = desc.substring(0, desc.length() - 1);
        }

        return desc;
    }
129135
protected void generateServiceDescriptor(String className, GeneratedFile generatedFile) throws IOException {
        CharSequence contents = generatedFile.getTextContent();
        if (contents != null) {
            String[] entries = contents.toString().split("\\n");
            if (!Arrays.asList(entries).contains(className)) {
                try (BufferedWriter w = new BufferedWriter(generatedFile.openWriter())) {
                    w.newLine();
                    w.write(className);
                }
            }
        } else {
            try (BufferedWriter w = new BufferedWriter(generatedFile.openWriter())) {
                w.write(className);
            }
        }
    }
776648
public static @CheckForNull <T extends Descriptor> T findByDescribableClassName(Collection<? extends T> list, String className) {
        for (T d : list) {
            if(d.clazz.getName().equals(className))
                return d;
        }
        return null;
    }
291979
private void findPluginsForDescriptor(final CommandLinePluginDescriptor<?> pluginDescriptor)
    {
        final ClassFinder classFinder = new ClassFinder();
        pluginDescriptor.getPackageNames().forEach(
                pkg -> classFinder.find(pkg, pluginDescriptor.getPluginBaseClass()));
        final Set<Class<?>> pluginClasses = classFinder.getClasses();

        for (Class<?> c : pluginClasses) {
            if (pluginDescriptor.includePluginClass(c)) {
                try {
                    final Object plugin = pluginDescriptor.createInstanceForPlugin(c);
                    createArgumentDefinitions(plugin, pluginDescriptor);
                } catch (InstantiationException | IllegalAccessException e) {
                    throw new CommandLineException.CommandLineParserInternalException("Problem making an instance of plugin " + c +
                            " Do check that the class has a non-arg constructor", e);
                }
            }
        }
    }
280639
function isStage1ClassDescriptor(possibleDesc) {
  let [target] = possibleDesc;

  return (
    possibleDesc.length === 1 &&
    typeof target === 'function' &&
    'prototype' in target &&
    !target.__isComputedDecorator
  );
}
359536
protected ClassDescriptor selectClassDescriptor(Map row) throws PersistenceBrokerException
    {
        ClassDescriptor result = m_cld;
        Class ojbConcreteClass = (Class) row.get(OJB_CONCRETE_CLASS_KEY);
        if(ojbConcreteClass != null)
        {
            result = m_cld.getRepository().getDescriptorFor(ojbConcreteClass);
            // if we can't find class-descriptor for concrete class, something wrong with mapping
            if (result == null)
            {
                throw new PersistenceBrokerException("Can't find class-descriptor for ojbConcreteClass '"
                        + ojbConcreteClass + "', the main class was " + m_cld.getClassNameOfObject());
            }
        }
        return result;
    }
548437
private ClassDescriptor getRealClassDescriptor(ClassDescriptor aCld, Object anObj)
    {
        ClassDescriptor result;

        if(aCld.getClassOfObject() == ProxyHelper.getRealClass(anObj))
        {
            result = aCld;
        }
        else
        {
            result = aCld.getRepository().getDescriptorFor(anObj.getClass());
        }

        return result;
    }