Try to find a binder for the provided parentObjectType and propertyName. If no
direct match found try to find binder for any superclass of the provided
objectType which also has the same propertyName.
199359
protected Binder findBinderByPropertyName(Class parentObjectType, String propertyName) {
        PropertyNameKey key = new PropertyNameKey(parentObjectType, propertyName);
        Binder binder = (Binder)propertyNameBinders.get(key);
        if (binder == null) {
            // if no direct match was found try to find a match in any super classes
            final Map potentialMatchingBinders = new HashMap();
            for (Iterator i = propertyNameBinders.entrySet().iterator(); i.hasNext();) {
                Map.Entry entry = (Map.Entry)i.next();
                if (((PropertyNameKey)entry.getKey()).getPropertyName().equals(propertyName)) {
                    potentialMatchingBinders.put(((PropertyNameKey)entry.getKey()).getParentObjectType(),
                            entry.getValue());
                }
            }
            binder = (Binder) ClassUtils.getValueFromMapForClass(parentObjectType, potentialMatchingBinders);
            if (binder != null) {
                // remember the lookup so it doesn't have to be discovered again
                registerBinderForPropertyName(parentObjectType, propertyName, binder);
            }
        }
        return binder;
    }
215884
private Object find(Class entityClass, Object key, EntityMetadata entityMetadata, MetamodelImpl metaModel,
            AbstractManagedType managedType)
    {
        List<String> relationNames = entityMetadata.getRelationNames();

        BasicDBObject query = new BasicDBObject();

        if (metaModel.isEmbeddable(entityMetadata.getIdAttribute().getBindableJavaType()))
        {
            MongoDBUtils.populateCompoundKey(query, entityMetadata, metaModel, key);
        }
        else
        {
            query.put("_id", MongoDBUtils.populateValue(key, key.getClass()));
        }

        // For secondary tables.
        List<String> secondaryTables = ((DefaultEntityAnnotationProcessor) managedType.getEntityAnnotation())
                .getSecondaryTablesName();
        secondaryTables.add(entityMetadata.getTableName());

        Object enhancedEntity = null;
        Map<String, Object> relationValue = null;
        // Here you need to fetch by sub managed type.

        EntityType entityType = metaModel.entity(entityMetadata.getEntityClazz());

        for (String tableName : secondaryTables)
        {
            DBCollection dbCollection = mongoDb.getCollection(tableName);
            KunderaCoreUtils.printQuery("Find document:" + query, showQuery);
            DBObject fetchedDocument = dbCollection.findOne(query);

            if (fetchedDocument != null)
            {
                List<AbstractManagedType> subManagedType = ((AbstractManagedType) entityType).getSubManagedType();

                EntityMetadata subEntityMetadata = null;
                if (!subManagedType.isEmpty())
                {
                    for (AbstractManagedType subEntity : subManagedType)
                    {
                        String discColumn = subEntity.getDiscriminatorColumn();
                        String disColValue = subEntity.getDiscriminatorValue();
                        Object value = fetchedDocument.get(discColumn);
                        if (value != null && value.toString().equals(disColValue))
                        {
                            subEntityMetadata = KunderaMetadataManager.getEntityMetadata(kunderaMetadata,
                                    subEntity.getJavaType());
                            break;
                        }
                    }

                    enhancedEntity = instantiateEntity(subEntityMetadata.getEntityClazz(), enhancedEntity);
                    relationValue = handler.getEntityFromDocument(subEntityMetadata.getEntityClazz(), enhancedEntity,
                            subEntityMetadata, fetchedDocument, subEntityMetadata.getRelationNames(), relationValue,
                            kunderaMetadata);
                }
                else
                {
                    enhancedEntity = instantiateEntity(entityClass, enhancedEntity);
                    relationValue = handler.getEntityFromDocument(entityMetadata.getEntityClazz(), enhancedEntity,
                            entityMetadata, fetchedDocument, relationNames, relationValue, kunderaMetadata);
                }

            }
        }

        if (relationValue != null && !relationValue.isEmpty())
        {
            EnhanceEntity entity = new EnhanceEntity(enhancedEntity, PropertyAccessorHelper.getId(enhancedEntity,
                    entityMetadata), relationValue);
            return entity;
        }
        else
        {
            return enhancedEntity;
        }
    }
536363
private static String getSubType(Class type, String propertyName) {
		@SuppressWarnings("unchecked")
		Class normalizedType = SimonTypeFactory.normalizeType(type);
		if (normalizedType == null) {
			return null;
		} else {
			return subTypeProperties.getProperty(normalizedType.getName() + "." + propertyName);
		}
	}
214546
public final ObjectType getTopMostDefiningType(String propertyName) {
    checkState(isConstructor() || isInterface());
    checkArgument(getInstanceType().hasProperty(propertyName));
    FunctionType ctor = this;

    if (isInterface()) {
      return getInstanceType().getTopDefiningInterface(propertyName);
    }

    ObjectType topInstanceType = null;
    do {
      topInstanceType = ctor.getInstanceType();
      ctor = ctor.getSuperClassConstructor();
    } while (ctor != null && ctor.getPrototype().hasProperty(propertyName));

    return topInstanceType;
  }
339103
@Override
  public void checkIllegalBinding(Binding binding, Scope scope) {
    Class<?> clazz;
    switch (binding.getMode()) {
      case SIMPLE:
        clazz = binding.getKey();
        break;
      case CLASS:
        clazz = binding.getImplementationClass();
        break;
      case PROVIDER_CLASS:
        clazz = binding.getProviderClass();
        break;
      default:
        return;
    }

    for (Annotation annotation : clazz.getAnnotations()) {
      Class<? extends Annotation> annotationType = annotation.annotationType();
      if (annotationType.isAnnotationPresent(javax.inject.Scope.class)) {
        if (!scope.isBoundToScopeAnnotation(annotationType)) {
          throw new IllegalBindingException(format("Class %s cannot be bound."
                  + " It has a scope annotation: %s that is not supported by current scope: %s",
              clazz.getName(), annotationType.getName(), scope.getName()));
        }
      }
    }
  }
520361
function getParent(type, id, parentType, root) {
		return _client.retrieve({
			type: type,
			id: id,
			properties: ['parent']
		})
		.then(function(obj) {
			
			if (obj.length > 0) {
				
				obj  = _.first(obj);
				type = _.get(obj, 'parent.type');
				id   = _.get(obj, 'parent.id');
				
				// if there is no parent type or id, the parent could not be found, throw an error
				if (!type || !id) {
					throw {
						errorCode: 404,
						message: 'could not find parent type'
					};
				}
				
				// if the parent is a match
				if (type === parentType) {
					
					// if a root search, keep looking for parent objects of the same type
					if (root === true) {
						return _client.retrieve({
							type: type,
							id: id,
							properties: ['parent']
						})
						.then(function(parent) {
							if (_.get(parent, 'parent.type') === parentType) {
								return getParent(type, id, parentType, root);
							}
							return {
								id: id,
								type: parentType
							};
						});
					}
					return {
						id: id,
						type: parentType
					};
				}
				
				return getParent(type, id, parentType, root);
			}
			
			throw {
				errorCode: 404,
				message: 'Object not found'
			};
		});
	}
93563
@NonNull
    public <E extends T> MapperBuilder<T> bind(@NonNull Class<E> itemClass,
                                               @NonNull Binder<? super E, ?> binder) {
        //noinspection unchecked
        return bind(itemClass, 0, binder, ALWAYS);
    }
701369
@SuppressWarnings("unchecked")
	public final Object bind(ConfigurationPropertyName name, Bindable<?> target,
			AggregateElementBinder elementBinder) {
		Object result = bindAggregate(name, target, elementBinder);
		Supplier<?> value = target.getValue();
		if (result == null || value == null) {
			return result;
		}
		return merge((Supplier<T>) value, (T) result);
	}
431032
public static boolean hasProperty(Object obj, String name) {
		if (obj == null)
			throw new NullPointerException("Object cannot be null");
		if (name == null)
			throw new NullPointerException("Property name cannot be null");

		Class<?> objClass = obj.getClass();

		// Search in fields
		for (Field field : objClass.getFields()) {
			if (matchField(field, name))
				return true;
		}

		// Search in properties
		name = "get" + name;
		for (Method method : objClass.getMethods()) {
			if (matchPropertyGetter(method, name))
				return true;
		}

		return false;
	}
71470
function bindDecorators (objectTemplate) {

    // TODO: In what situation would objectTemplate be null and why is it acceptable just to use this as a replacement?
    objectTemplate = objectTemplate || this;

    this.Amorphic = objectTemplate;
    this.amorphicStatic = objectTemplate;

    /**
     * Purpose unknown
     *
     * @param {unknown} target unknown
     * @param {unknown} props unknown
     *
     * @returns {unknown} unknown.
     */
    this.supertypeClass = function supertypeClass(target, props) {
        if (objectTemplate.supertypeClass) {
            return objectTemplate.supertypeClass(target, props, objectTemplate);
        }
        else {
            return SupertypeDefinition.supertypeClass(target, props, objectTemplate);
        }
    };

    /**
     * Purpose unknown
     *
     * @returns {unknown} unknown.
     */
    this.Supertype = function Supertype() {
        if (objectTemplate.Supertype) {
            return objectTemplate.Supertype.call(this, objectTemplate);
        }
        else {
            return SupertypeDefinition.Supertype.call(this, objectTemplate);
        }
    };
    this.Supertype.prototype = SupertypeDefinition.Supertype.prototype;

    /**
     *  Purpose unknown
     *
     * @param {unknown} props unknown
     *
     * @returns {unknown} unknown.
     */
    this.property = function property(props) {
        if (objectTemplate.property) {
            return objectTemplate.property(props, objectTemplate);
        }
        else {
            return SupertypeDefinition.property(props, objectTemplate);
        }
    };

    /**
     * Purpose unknown
     *
     * @param {unknown} defineProperty unknown
     *
     * @returns {unknown} unknown.
     */
    this.remote = function remote(defineProperty) {
        if (objectTemplate.remote) {
            return objectTemplate.remote(defineProperty, objectTemplate);
        }
        else {
            return SupertypeDefinition.remote(defineProperty, objectTemplate);
        }
    };

    /**
     * Purpose unknown
     *
     * @returns {unknown} unknown.
     */
    this.Amorphic.create = function create() {
        objectTemplate.connect = unitTestConfig.startup;

        return objectTemplate;
    };

    this.Amorphic.getInstance = function getInstance() {
        return objectTemplate;
    };
}
495095
private TypeSpec getBinderWrapper() {
        TypeSpec.Builder staticBinderWrapperClassBuilder = TypeSpec
                .classBuilder("BinderWrapper")
                .addModifiers(Modifier.PRIVATE)
                .addModifiers(Modifier.STATIC)
                .addField(ClassName.get("android.os", "IBinder"), "binder", Modifier.PRIVATE)
                .addMethod(MethodSpec.constructorBuilder()
                        .addParameter(ClassName.get("android.os", "IBinder"), "binder")
                        .addStatement("this.binder = binder")
                        .build())
                .addMethod(MethodSpec.methodBuilder("asBinder")
                        .addModifiers(Modifier.PUBLIC)
                        .addAnnotation(Override.class)
                        .returns(ClassName.get("android.os", "IBinder"))
                        .addStatement("return binder")
                        .build())
                .addSuperinterface(ClassName.get("android.os", "IInterface"));

        return staticBinderWrapperClassBuilder.build();
    }
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;
        }
    }
1110544
private JSType getPropertyTypeIfDeclared(@Nullable ObjectType objectType, String propertyName) {
    if (objectType != null
        && objectType.hasProperty(propertyName)
        && !objectType.isPropertyTypeInferred(propertyName)) {
      return objectType.getPropertyType(propertyName);
    }
    return getNativeType(UNKNOWN_TYPE);
  }
408609
function getPropertiesAndBindings( root, libs, com, indent ) {
  // Attributes can have post initialization, especially for data bindings.
  var postInit = {};
  var hasPostInit = false;
  var key,
      val,
      values;
  var bindings;
  var slots;
  for ( key in root.attribs ) {
    if ( key.charAt( 0 ) == '$' ) {
      // All the attributes that start with a '$' are used as args attributes.
      val = root.attribs[key];
      com.prop[key.substr( 1 )] = JSON.stringify( val );
    }
    else if ( key.substr( 0, 5 ) == 'intl:' ) {
      // Internationalization.
      val = root.attribs[key];
      com.prop[key.substr( 5 )] = "APP._(" + JSON.stringify( val ) + ")";
    }
    else if ( key.substr( 0, 5 ) == 'bind:' ) {
      // Syntaxe :
      // <bind> := <bind-item> <bind-next>*
      // <bind-next> := "," <bind-item>
      // <bind-item> := <widget-name> <attribute>? <value>?
      // <widget-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/
      // <attribute> := ":" <attrib-name>
      // <attrib-name> := /[$a-zA-Z_-][$0-9a-zA-Z_-]+/
      // <value> := "=" <data>
      // <data> := "true" | "false" | "null" | <number> | <string>
      //
      // @example
      // <wdg:checkbox bind:value="btn1:action" />
      // <wdg:checkbox bind:value="btn1:action, btn2, action=false" />
      if ( typeof postInit[key.substr( 5 )] === 'undefined' ) {
        postInit[key.substr( 5 )] = {};
      }
      postInit[key.substr( 5 )].B = parseBinding(root.attribs[key]);
      hasPostInit = true;
    }
    else if ( key.substr( 0, 5 ) == 'slot:' ) {
      // @example
      // <wdg:button slot:action="removeOrder" />
      // <wdg:button slot:action="removeOrder, changePage" />
      // <wdg:button slot:action="my-module:my-function" />
      values = root.attribs[key].split( "," );
      key = key.substr( 5 );
      if ( typeof postInit[key] === 'undefined' ) {
        postInit[key] = {};
      }
      slots = [ ];
      values.forEach( function( val ) {
        // Before the colon (:) there is the module name. After, there
        // is the function  name. If there is no colon,  `APP` is used
        // as module.
        val = val.split( ':' );
        if ( val.length < 2 ) {
          slots.push(val[0].trim( ));
        } else {
          slots.push(val.map( String.trim ));
          libs.require(val[0]);
        }
      });
      postInit[key].S = slots;
      hasPostInit = true;
    }
    else {
      com.attr[key] = root.attribs[key];
    }
  }

  if ( hasPostInit ) {
    libs.addPostInitJS( "        W.bind('" + com.attr.id + "'," + JSON.stringify( postInit ) + ");" );
  }
}
1262572
private static Class<?> getBoundGinjector(GinjectorBindings bindings) {

    if (bindings.getGinjectorInterface() == null) {
      return null;
    }

    TypeLiteral<?> ginjectorInterface = bindings.getGinjectorInterface();
    Key<?> ginjectorKey = Key.get(ginjectorInterface);

    if (!bindings.isBound(ginjectorKey)) {
      return null;
    }

    if (!(bindings.getBinding(ginjectorKey) instanceof GinjectorBinding)) {
      return null;
    }

    return ginjectorInterface.getRawType();
  }
406063
private boolean findBinding(Injector injector, Class<?> type) {
        boolean found = false;
        for (Key<?> key : injector.getBindings().keySet()) {
            if (key.getTypeLiteral().getRawType().equals(type)) {
                found = true;
                break;
            }
        }
        if (!found && injector.getParent() != null) {
            return findBinding(injector.getParent(), type);
        }

        return found;
    }
912509
public void bind() throws Throwable
   {
      if (name == null)
         throw new IllegalArgumentException("Name is null");

      if (obj == null)
         throw new IllegalArgumentException("Obj is null");

      if (trace)
         log.trace("Binding " + obj.getClass().getName() + " under " + name);

      Properties properties = new Properties();
      properties.setProperty(Context.PROVIDER_URL, jndiProtocol + "://" + jndiHost + ":" + jndiPort);
      Context context = new InitialContext(properties);

      try
      {
         String className = obj.getClass().getName();
         Reference ref = new Reference(className,
                                       new StringRefAddr("class", className),
                                       JndiBinder.class.getName(),
                                       null);
         ref.add(new StringRefAddr("name", name));

         objs.put(name, obj);

         Util.bind(context, name, ref);

         if (log.isDebugEnabled())
            log.debug("Bound " + obj.getClass().getName() + " under " + name);
      }
      finally
      {
         if (context != null)
         {
            try
            {
               context.close();
            }
            catch (NamingException ne)
            {
               // Ignore
            }
         }
      }
   }