Returns the root {@link org.apache.ojb.broker.metadata.ClassDescriptor} of the inheriatance
hierachy of the given descriptor or the descriptor itself if no inheriatance on multiple table is
used.
975002
private static ClassDescriptor findInheritanceRoot(ClassDescriptor cld)
    {
        ClassDescriptor result = cld;
        if(cld.getSuperClassDescriptor() != null)
        {
            result = findInheritanceRoot(cld.getSuperClassDescriptor());
        }
        return result;
    }
1309880
public static PojoDescriptorBuilderFactory getInstance() {

    PojoDescriptorBuilderFactory instance = AbstractPojoDescriptorBuilderFactory.getInstance();
    if (instance == null) {
      synchronized (PojoDescriptorBuilderFactoryImpl.class) {
        if (instance == null) {
          PojoDescriptorBuilderFactoryImpl impl = new PojoDescriptorBuilderFactoryImpl();
          instance = impl;
          setInstance(impl);
          impl.initialize();
        }
      }
    }
    return instance;
  }
1178008
protected final Object getIdentifier(Object value, SessionFactoryImplementor sessionFactory) throws HibernateException {
		if ( value == null ) {
			return null;
		}

		final EntityPersister persister = sessionFactory.getMetamodel().entityPersister( delegate.getAssociatedEntityName() );
		final String uniqueKeyPropertyName = delegate.getRHSUniqueKeyPropertyName();

		if ( StringHelper.isEmpty( uniqueKeyPropertyName ) ) {
			return persister.getIdentifier( value, null );
		}
		else {
			Object propertyValue = persister.getPropertyValue( value, uniqueKeyPropertyName );
			// We now have the value of the property-ref we reference.  However,
			// we need to dig a little deeper, as that property might also be
			// an entity type, in which case we need to resolve its identifier
			Type type = persister.getPropertyType( uniqueKeyPropertyName );
			GridType gridType = typeTranslator.getType( type );
			if ( gridType.isEntityType() ) {
				propertyValue = getIdentifier( propertyValue, sessionFactory );
			}

			return propertyValue;
		}
	}
558530
public function getFirstDescendant($class_name)
    {
        if (!class_exists($class_name) && !interface_exists($class_name)) {
            return null;
        }

        $out = null;

        foreach ($this->columns as $column) {
            if ($column instanceof $class_name) {
                $out = $column;
                break;
            }

            if ($column instanceof SwatUIParent) {
                $out = $column->getFirstDescendant($class_name);
                if ($out !== null) {
                    break;
                }
            }
        }

        if ($out === null) {
            foreach ($this->spanning_columns as $column) {
                if ($column instanceof $class_name) {
                    $out = $column;
                    break;
                }

                if ($column instanceof SwatUIParent) {
                    $out = $column->getFirstDescendant($class_name);
                    if ($out !== null) {
                        break;
                    }
                }
            }
        }

        if ($out === null) {
            foreach ($this->groups as $group) {
                if ($group instanceof $class_name) {
                    $out = $group;
                    break;
                }

                if ($group instanceof SwatUIParent) {
                    $out = $group->getFirstDescendant($class_name);
                    if ($out !== null) {
                        break;
                    }
                }
            }
        }

        if ($out === null) {
            foreach ($this->extra_rows as $row) {
                if ($row instanceof $class_name) {
                    $out = $row;
                    break;
                }

                if ($row instanceof SwatUIParent) {
                    $out = $row->getFirstDescendant($class_name);
                    if ($out !== null) {
                        break;
                    }
                }
            }
        }

        return $out;
    }
88034
public Class<?> getClass(Object example) {
    if (example instanceof HibernateProxy) {
      HibernateProxy proxy = (HibernateProxy) example;
      LazyInitializer initializer = proxy.getHibernateLazyInitializer();
      SessionImplementor implementor = initializer.getSession();

      if (initializer.isUninitialized()) {
        try {
          // getImplementation is going to want to talk to a session
          if (implementor.isClosed()) {
            // Give up and return example.getClass();
            return example.getClass();
          }
        } catch (NoSuchMethodError ex) {
          // We must be using Hibernate 3.0/3.1 which doesn't have
          // this method
        }
      }

      return initializer.getImplementation().getClass();
    } else {
      return example.getClass();
    }
  }
668390
public static long getMaxId(PersistenceBroker brokerForClass, Class topLevel, FieldDescriptor original) throws PersistenceBrokerException
    {
        long max = 0;
        long tmp;
        ClassDescriptor cld = brokerForClass.getClassDescriptor(topLevel);

        // if class is not an interface / not abstract we have to search its directly mapped table
        if (!cld.isInterface() && !cld.isAbstract())
        {
            tmp = getMaxIdForClass(brokerForClass, cld, original);
            if (tmp > max)
            {
                max = tmp;
            }
        }
        // if class is an extent we have to search through its subclasses
        if (cld.isExtent())
        {
            Vector extentClasses = cld.getExtentClasses();
            for (int i = 0; i < extentClasses.size(); i++)
            {
                Class extentClass = (Class) extentClasses.get(i);
                if (cld.getClassOfObject().equals(extentClass))
                {
                    throw new PersistenceBrokerException("Circular extent in " + extentClass +
                            ", please check the repository");
                }
                else
                {
                    // fix by Mark Rowell
                    // Call recursive
                    tmp = getMaxId(brokerForClass, extentClass, original);
                }
                if (tmp > max)
                {
                    max = tmp;
                }
            }
        }
        return max;
    }
476574
public function getInstance(string $class, $element_id)
    {
        if (!is_a($class, Hierarchy::class, true))
            throw new TypeError("Not a subclass of Hierarchy: $class");

        if (is_object($element_id) && get_class($element_id) === $class)
            return $element_id;

        if (!is_scalar($element_id))
            throw new TypeError("Element-ID must be a scalar");

        if (!$this->hasInstance($class, $element_id))
        {
            $root = $class::getRootName();
            if ($element_id === $root)
                $this->hierarchy[$class][$root] = new $class($this, $root);
            else
                throw new Exception("Element-ID '{$element_id}' is unknown for {$class}");
        }

        return $this->hierarchy[$class][$element_id];
    }
333855
function getFurthestAncestor(node) {
        var root = node;
        while (root.parentNode != null) {
            root = root.parentNode;
        }
        return root;
    }
1071272
public static Predicate<Class<?>> classIsDescendantOf(Class<?> ancestor) {
        return candidate -> candidate != null && candidate != ancestor && ancestor
                .isAssignableFrom(candidate);
    }
513044
private static ClassHierarchy loadClassHierarchy() {
    // TODO[JIRA REEF-400] The file should be created by AvroClassHierarchySerializer
    try (final InputStream chin = new FileInputStream(HelloCLR.CLASS_HIERARCHY_FILENAME)) {
      // TODO[JIRA REEF-400] Use AvroClassHierarchySerializer instead
      final ClassHierarchyProto.Node root = ClassHierarchyProto.Node.parseFrom(chin); // A
      final ClassHierarchy ch = new ProtocolBufferClassHierarchy(root);
      return ch;
    } catch (final IOException e) {
      final String message = "Unable to load class hierarchy.";
      LOG.log(Level.SEVERE, message, e);
      throw new RuntimeException(message, e);
    }
  }
667263
private static String firstFoundTableName(PersistenceBroker brokerForClass, ClassDescriptor cld)
    {
        String name = null;
        if (!cld.isInterface() && cld.getFullTableName() != null)
        {
            return cld.getFullTableName();
        }
        if (cld.isExtent())
        {
            Collection extentClasses = cld.getExtentClasses();
            for (Iterator iterator = extentClasses.iterator(); iterator.hasNext();)
            {
                name = firstFoundTableName(brokerForClass, brokerForClass.getClassDescriptor((Class) iterator.next()));
                // System.out.println("## " + cld.getClassNameOfObject()+" - name: "+name);
                if (name != null) break;
            }
        }
        return name;
    }
1054735
public static Iterable<Descriptor> listLegacyInstances() {
        return new Iterable<Descriptor>() {
            public Iterator<Descriptor> iterator() {
                return new AdaptedIterator<ExtensionComponent<Descriptor>,Descriptor>(
                    new FlattenIterator<ExtensionComponent<Descriptor>,CopyOnWriteArrayList<ExtensionComponent<Descriptor>>>(legacyDescriptors.values()) {
                        protected Iterator<ExtensionComponent<Descriptor>> expand(CopyOnWriteArrayList<ExtensionComponent<Descriptor>> v) {
                            return v.iterator();
                        }
                    }) {

                    protected Descriptor adapt(ExtensionComponent<Descriptor> item) {
                        return item.getInstance();
                    }
                };
            }
        };
    }
32502
public FieldDescriptor[] getFieldDescriptorNonPk(boolean withInherited)
    {
        if(withInherited && getSuperClassDescriptor() != null)
        {
            FieldDescriptor[] flds = getNonPkFields();
            FieldDescriptor[] superFlds = getSuperClassDescriptor().getFieldDescriptorNonPk(true);
            FieldDescriptor[] result = new FieldDescriptor[flds.length + superFlds.length];
            System.arraycopy(flds, 0, result, 0, flds.length);
            System.arraycopy(superFlds, 0, result, flds.length, superFlds.length);
            return result;
        }
        else
        {
            return getNonPkFields();
        }
    }
759436
private static MethodRef getDefaultInstanceMethod(Descriptor descriptor) {
    TypeInfo message = messageRuntimeType(descriptor);
    return MethodRef.createStaticMethod(
            message, new Method("getDefaultInstance", message.type(), NO_METHOD_ARGS))
        .asNonNullable();
  }
819334
public static Predicate<Class<?>> classIsAssignableFrom(Class<?> ancestor) {
        return candidate -> candidate != null && ancestor.isAssignableFrom(candidate);
    }
517951
public static JavaClassIgnoreResolver singletonInstance()
    {
        if (defaultInstance == null)
        {
            TrieStructureTypeRelation<String,String> relation = new TrieStructureTypeRelation<String,String>() {

                @Override public String getStringToSearchFromSearchType(String search)
                {
                    return search;
                }

                @Override public String getStringPrefixToSaveSaveType(String save)
                {
                    /**
                     * At least for now javaclass-ignore does not contain anything except the prefix
                     */
                    return save;
                }

                @Override public boolean checkIfMatchFound(String saved, String searched)
                {
                    return searched.startsWith(saved);
                }
            };
            defaultInstance = new JavaClassIgnoreResolver(relation);
        }
        return defaultInstance;
    }
328865
public function getFirstDescendant($class_name)
    {
        if (!class_exists($class_name) && !interface_exists($class_name)) {
            return null;
        }

        $out = null;

        foreach ($this->fields as $field) {
            if ($field instanceof $class_name) {
                $out = $field;
                break;
            }

            if ($field instanceof SwatUIParent) {
                $out = $field->getFirstDescendant($class_name);
                if ($out !== null) {
                    break;
                }
            }
        }

        return $out;
    }