/*
(non-Javadoc)

@see org.jboss.common.beans.property.finder.PropertyEditorFinder#find(java.lang.Class)
160996
@SuppressWarnings("unchecked")
    @Override
    public PropertyEditor find(Class<?> type) {
        if(type == null){
            return null;
        }
        Class<? extends PropertyEditor> editorClass = this.register.get(type);
        if (editorClass != null) {
            try {
                return editorClass.newInstance();
            } catch (Exception e) {
                 //e.printStackTrace();
            }
        }

        final boolean isArray = type.isArray();
        String editorName = BeanUtils.stripPackage(type);
        if (isArray) {
            editorName += EDITOR_ARRAY;
        } else {
            editorName += EDITOR;
        }
        String searchName = null;
        try {
            searchName = BeanUtils.stripClass(type) + "." + editorName;
            editorClass = (Class<? extends PropertyEditor>) BeanUtils.findClass(searchName);
            return editorClass.newInstance();
        } catch (Exception e) {
            //catching, to be compliant with JDK PEM
            if(logger.isLoggable(Level.FINEST)){
                logger.log(Level.FINEST,"Failed to instantiate property editor class  '"+searchName+"'.",e);
            }
        }

        for (String pkg : this.packages) {
            try {
                searchName = pkg + "." + editorName;
                editorClass = (Class<? extends PropertyEditor>) BeanUtils.findClass(searchName);
                return editorClass.newInstance();
            } catch (Exception e) {
                //catching, to be compliant with JDK PEM
                if(logger.isLoggable(Level.FINEST)){
                    logger.log(Level.FINEST,"Failed to instantiate property editor class  '"+searchName+"'.",e);
                }
            }
        }

        if (isArray) {
            Class<?> cellType = type.getComponentType();
            if (find(cellType) != null) {
                return new GenericArrayPropertyEditor(type);
            }
            return null;
        }  else if(type.isPrimitive()){
            return find(BeanUtils.getWrapperTypeFor(type));
        }

        return null;
    }
257353
@Override
    public List find(Class entityClass, List<String> relationNames, boolean isWrapReq, EntityMetadata metadata,
        Object... rowIds) {
        return findAll(entityClass, null, rowIds);
    }
363447
private static @CheckForNull <T extends Descriptor> T findByClassName(Collection<? extends T> list, String className) {
        for (T d : list) {
            if(d.getClass().getName().equals(className))
                return d;
        }
        return null;
    }
765414
public static Class<?> classFind(String name) {
        try {
            return Class.forName(name);
        } catch (ClassNotFoundException e) {
            return findType(name).type;
        }
    }
207708
@Override
    public final Object find(Class entityClass, Object rowId)
    {
        return super.find(entityClass, rowId);
    }
532185
@Override
    public JavaClass findClass(String className) {
        @SlashedClassName
        String slashedClassName = ClassName.toSlashedClassName(className);
        ClassDescriptor classDescriptor = DescriptorFactory.instance().getClassDescriptor(slashedClassName);
        return Global.getAnalysisCache().probeClassAnalysis(JavaClass.class, classDescriptor);
    }
19892
public PropertyNameProcessor findJavaPropertyNameProcessor( Class beanClass ) {
      if( !javaPropertyNameProcessorMap.isEmpty() ) {
         Object key = javaPropertyNameProcessorMatcher.getMatch( beanClass, javaPropertyNameProcessorMap.keySet() );
         return (PropertyNameProcessor) javaPropertyNameProcessorMap.get( key );

      }
      return null;
   }
511627
private static <T extends Bean> Constructor<T> findConstructor(Class<T> beanType, List<Class<?>> propertyTypes) {
        Class<?>[] types = propertyTypes.toArray(new Class<?>[propertyTypes.size()]);
        try {
            Constructor<T> con = beanType.getDeclaredConstructor(types);
            return con;
            
        } catch (NoSuchMethodException ex) {
            // try a more lenient search
            // this handles cases where field is a concrete class and constructor is an interface
            @SuppressWarnings("unchecked")
            Constructor<T>[] cons = (Constructor<T>[]) beanType.getDeclaredConstructors();
            Constructor<T> match = null;
            for (int i = 0; i < cons.length; i++) {
                Constructor<T> con = cons[i];
                Class<?>[] conTypes = con.getParameterTypes();
                if (conTypes.length == types.length) {
                    for (int j = 0; j < types.length; j++) {
                        if (!conTypes[j].isAssignableFrom(types[j])) {
                            break;
                        }
                    }
                    if (match != null) {
                        throw new UnsupportedOperationException("Unable to find constructor: More than one matches");
                    }
                    match = con;
                }
            }
            if (match == null) {
                String msg = "Unable to find constructor: " + beanType.getSimpleName() + "(";
                for (Class<?> type : types) {
                    msg += Objects.toString(type.getName(), "<null>");
                }
                msg += ")";
                throw new UnsupportedOperationException(msg, ex);
            }
            return match;
        }
    }
534740
@Override
    public Object find(Class entityClass, Object key)
    {
        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);

        MetamodelImpl metaModel = (MetamodelImpl) kunderaMetadata.getApplicationMetadata().getMetamodel(
                entityMetadata.getPersistenceUnit());

        AbstractManagedType managedType = (AbstractManagedType) metaModel.entity(entityMetadata.getEntityClazz());

        return managedType.hasLobAttribute() ? findGFSEntity(entityMetadata, entityClass, key) : find(entityClass, key,
                entityMetadata, metaModel, managedType);
    }
1331605
@ShellMethod(key = "find", value = "Look up properties associated with a CAS group/module.")
    public void find(
        @ShellOption(value = {"name"},
            help = "Property name regex pattern",
            defaultValue = ".+") final String name,
        @ShellOption(value = {"strict-match"},
            help = "Whether pattern should be done in strict-mode which means "
                + "the matching engine tries to match the entire region for the query.") final boolean strict,
        @ShellOption(value = {"summary"},
            help = "Whether results should be presented in summarized mode") final boolean summary) {

        val results = find(strict, RegexUtils.createPattern(name));

        if (results.isEmpty()) {
            LOGGER.info("Could not find any results matching the criteria");
            return;
        }

        results.forEach((k, v) -> {
            if (summary) {
                LOGGER.info("{}={}", k, v.getDefaultValue());
                val value = StringUtils.normalizeSpace(v.getShortDescription());
                if (StringUtils.isNotBlank(value)) {
                    LOGGER.info("{}", value);
                }
            } else {
                LOGGER.info("Property: {}", k);
                LOGGER.info("Group: {}", StringUtils.substringBeforeLast(k, "."));
                LOGGER.info("Default Value: {}", ObjectUtils.defaultIfNull(v.getDefaultValue(), "[blank]"));
                LOGGER.info("Type: {}", v.getType());
                LOGGER.info("Summary: {}", StringUtils.normalizeSpace(v.getShortDescription()));
                LOGGER.info("Description: {}", StringUtils.normalizeSpace(v.getDescription()));
                LOGGER.info("Deprecated: {}", BooleanUtils.toStringYesNo(v.isDeprecated()));
            }
            LOGGER.info("-".repeat(SEP_LINE_LENGTH));
        });
    }
905211
public PropertyNameProcessor findJsonPropertyNameProcessor( Class beanClass ) {
      if( !jsonPropertyNameProcessorMap.isEmpty() ) {
         Object key = jsonPropertyNameProcessorMatcher.getMatch( beanClass, jsonPropertyNameProcessorMap.keySet() );
         return (PropertyNameProcessor) jsonPropertyNameProcessorMap.get( key );

      }
      return null;
   }
1305819
private Object find(Class entityClass, Object key, List<String> columnsToSelect)
    {
        EntityMetadata entityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata, entityClass);
        MetamodelImpl metamodel = (MetamodelImpl) KunderaMetadataManager.getMetamodel(kunderaMetadata,
                entityMetadata.getPersistenceUnit());

        String idColumnName = ((AbstractAttribute) entityMetadata.getIdAttribute()).getJPAColumnName();
        Table schemaTable = tableAPI.getTable(entityMetadata.getTableName());

        PrimaryKey rowKey = schemaTable.createPrimaryKey();
        if (metamodel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType()))
        {
            readEmbeddable(key, columnsToSelect, entityMetadata, metamodel, schemaTable, rowKey,
                    entityMetadata.getIdAttribute());
        }
        else
        {
            if (eligibleToFetch(columnsToSelect, idColumnName))
            {
                NoSqlDBUtils.add(schemaTable.getField(idColumnName), rowKey, key, idColumnName);
            }
        }
        KunderaCoreUtils.printQuery("Fetch data from " + entityMetadata.getTableName() + " for PK " + key, showQuery);
        if (log.isDebugEnabled())
        {
            log.debug("Fetching data from " + entityMetadata.getTableName() + " for PK " + key);
        }

        // Object entity = null;
        List entities = new ArrayList();
        Map<String, Object> relationMap = initialize(entityMetadata);

        try
        {
            Iterator<Row> rowsIter = tableAPI.tableIterator(rowKey, null, null);
            // iterator and build entity
            entities = scrollAndPopulate(key, entityMetadata, metamodel, schemaTable, rowsIter, relationMap,
                    columnsToSelect);
        }
        catch (Exception e)
        {
            log.error("Error while finding data for Key " + key + ", Caused By :" + e + ".");
            throw new PersistenceException(e);
        }

        return entities.isEmpty() ? null : entities.get(0);
    }
752363
public Class findClass(String name) throws ClassNotFoundException {

        if (log.isDebugEnabled())
            log.debug("    findClass(" + name + ")");

        // Cannot load anything from local repositories if class loader is stopped
        if (!started) {
            throw new ClassNotFoundException(name);
        }

        // (1) Permission to define this class when using a SecurityManager
        if (securityManager != null) {
            int i = name.lastIndexOf('.');
            if (i >= 0) {
                try {
                    if (log.isTraceEnabled())
                        log.trace("      securityManager.checkPackageDefinition");
                    securityManager.checkPackageDefinition(name.substring(0,i));
                } catch (Exception se) {
                    if (log.isTraceEnabled())
                        log.trace("      -->Exception-->ClassNotFoundException", se);
                    throw new ClassNotFoundException(name, se);
                }
            }
        }

        // Ask our superclass to locate this class, if possible
        // (throws ClassNotFoundException if it is not found)
        Class clazz = null;
        try {
            if (log.isTraceEnabled())
                log.trace("      findClassInternal(" + name + ")");
            try {
                clazz = findClassInternal(name);
            } catch(ClassNotFoundException cnfe) {
                if (!hasExternalRepositories) {
                    throw cnfe;
                }
            } catch(AccessControlException ace) {
                throw new ClassNotFoundException(name, ace);
            } catch (RuntimeException e) {
                if (log.isTraceEnabled())
                    log.trace("      -->RuntimeException Rethrown", e);
                throw e;
            }
            if ((clazz == null) && hasExternalRepositories) {
                try {
                    clazz = super.findClass(name);
                } catch(AccessControlException ace) {
                    throw new ClassNotFoundException(name, ace);
                } catch (RuntimeException e) {
                    if (log.isTraceEnabled())
                        log.trace("      -->RuntimeException Rethrown", e);
                    throw e;
                }
            }
            if (clazz == null) {
                if (log.isDebugEnabled())
                    log.debug("    --> Returning ClassNotFoundException");
                throw new ClassNotFoundException(name);
            }
        } catch (ClassNotFoundException e) {
            if (log.isTraceEnabled())
                log.trace("    --> Passing on ClassNotFoundException");
            throw e;
        }

        // Return the class we have located
        if (log.isTraceEnabled())
            log.debug("      Returning class " + clazz);
        if (log.isTraceEnabled())
            log.debug("      Loaded by " + clazz.getClassLoader());
        return (clazz);

    }
408994
@Override
    protected Class<?> findClass(final String name) throws ClassNotFoundException
    {
        try {
            return AccessController.doPrivileged(new PrivilegedExceptionAction<Class<?>>()
            {
                @Override
                public Class<?> run() throws ClassNotFoundException
                {
                    String path = name.replace('.', '/').concat(".class");
                    ResourceHandle h = URIClassLoader.this.finder.getResource(path);
                    if (h != null) {
                        try {
                            return defineClass(name, h);
                        } catch (IOException e) {
                            throw new ClassNotFoundException(name, e);
                        }
                    } else {
                        throw new ClassNotFoundException(name);
                    }
                }
            }, this.acc);
        } catch (java.security.PrivilegedActionException pae) {
            throw (ClassNotFoundException) pae.getException();
        }
    }
1312283
public <ResultT> CoreRemoteFindIterable<ResultT> find(final Class<ResultT> resultClass) {
    return find(new BsonDocument(), resultClass);
  }
534322
@Override
  public <T> T findById(Object id, Class<T> entityClass) {
    return findById(id, Util.determineCollectionName(entityClass));
  }
507373
@Override
    public Class<?> findClass(String name) throws ClassNotFoundException {
        Class clazz = byteCodesClass.get(name);
        if (clazz == null) {
            return super.loadClass(name, false);
        }
        return clazz;
    }