Given a association attribute in an Entity find the Entity the attribute is referencing.

@param attribute association attribute
@return Optional Entity type being referenced.
169376
Optional<EntityDescriptor> referencingEntity(AttributeDescriptor attribute) {
        if (!Names.isEmpty(attribute.referencedTable())) {
            // match by table name
            return entities.values().stream()
                .filter(entity -> entity.tableName().equalsIgnoreCase(attribute.referencedTable()))
                .findFirst();

        } else if (!Names.isEmpty(attribute.referencedType())) {
            // match by type name
            Optional<TypeKind> primitiveType = Stream.of(TypeKind.values())
                .filter(TypeKind::isPrimitive)
                .filter(kind -> kind.toString().toLowerCase().equals(attribute.referencedType()))
                .findFirst();
            if (!primitiveType.isPresent()) {
                QualifiedName referencedType = new QualifiedName(attribute.referencedType());
                return entityByName(referencedType);
            } // else attribute is basic foreign key and not referring to an entity
        } else {
            TypeMirror referencedType = attribute.typeMirror();
            if (attribute.isIterable()) {
                referencedType = collectionElementType(referencedType);
            }
            TypeElement referencedElement = (TypeElement) types.asElement(referencedType);
            if (referencedElement != null) {
                String referencedName = referencedElement.getSimpleName().toString();
                return entities.values().stream()
                        .filter(entity -> match(entity, referencedName))
                        .findFirst();
            }
        }
        return Optional.empty();
    }
332429
public Object getAttribute(Object object, String attribute) {
        return delegate.getAttribute(object, attribute);
    }
397790
public NameOpValue getParam(String attribute) {
	if (_relations == null || attribute == null) return null;
	return (NameOpValue)_relations.get(canonicalize(attribute));
    }
493468
static PersistentAttributeType getPersistentAttributeType(Field member)
    {
        PersistentAttributeType attributeType = PersistentAttributeType.BASIC;
        if (member.isAnnotationPresent(ElementCollection.class))
        {
            attributeType = PersistentAttributeType.ELEMENT_COLLECTION;
        }
        else if (member.isAnnotationPresent(OneToMany.class))
        {
            attributeType = PersistentAttributeType.ONE_TO_MANY;
        }
        else if (member.isAnnotationPresent(ManyToMany.class))
        {
            attributeType = PersistentAttributeType.MANY_TO_MANY;
        }
        else if (member.isAnnotationPresent(ManyToOne.class))
        {
            attributeType = PersistentAttributeType.MANY_TO_ONE;
        }
        else if (member.isAnnotationPresent(OneToOne.class))
        {
            attributeType = PersistentAttributeType.ONE_TO_ONE;
        }
        else if (member.isAnnotationPresent(Embedded.class))
        {
            attributeType = PersistentAttributeType.EMBEDDED;
        }

        return attributeType;

    }
358424
public EntityType getRefEntity() {
    if (!hasRefEntity()) {
      throw new UnsupportedOperationException(
          String.format("getRefEntity not supported for attribute type '%s'", getDataType()));
    }
    return getEntity(REF_ENTITY_TYPE, EntityType.class);
  }
74824
@SuppressWarnings("unchecked")
    public static <T> Optional<T> getAnnotationAttribute(final Annotation anno, final String attrName, final Class<T> attrType) {
        
        try {
            final Method method = anno.annotationType().getMethod(attrName);
            method.setAccessible(true);
            if(!attrType.equals(method.getReturnType())) {
                return Optional.empty();
            }
            
            final Object value = method.invoke(anno);
            return Optional.of((T)value);
            
        } catch (Exception e) {
            return Optional.empty();
        }
        
    }
730288
boolean hasAttribute(String attribute) {
        if(columnMetadata != null){
            if(columnMetadata.containsKey(attribute)){
                return true;
            }else if(attribute.startsWith("\"") && attribute.endsWith("\"")){
                return columnMetadata.containsKey(attribute.substring(1, attribute.length() - 1));
            }
        }
        return false;
    }
566490
public function getAttribute($attribute)
    {
        if (!isset($this->attributes[$attribute])) {
            throw new EntityException(EntityException::ATTRIBUTE_NOT_FOUND, [
                $attribute,
                get_class($this)
            ]);
        }

        return $this->attributes[$attribute];
    }
869142
public Bindings getBindings(String attribute) {
	if (_bindings == null || attribute == null) return null;
	return (Bindings)_bindings.get(canonicalize(attribute));
    }
801787
private String getValue(String attribute)
    {
        Check.notNull(attribute);

        if (root.hasAttribute(attribute))
        {
            return root.getAttribute(attribute);
        }
        throw new LionEngineException(ERROR_ATTRIBUTE + attribute);
    }
613290
protected void checkAttribute(String attribute) {
        if (!hasAttribute(attribute)) {
            String sb = "Attribute: '" + attribute + "' is not defined in model: '" + getModelClass() + ". "
                    + "Available attributes: " +getAttributeNames();
            throw new IllegalArgumentException(sb);
        }
    }
583313
private boolean hasAttributeThatReferences(EntityType candidate, String entityTypeId) {
    Iterable<Attribute> attributes = candidate.getOwnAtomicAttributes();
    return stream(attributes)
        .filter(Attribute::hasRefEntity)
        .map(attribute -> attribute.getRefEntity().getId())
        .anyMatch(entityTypeId::equals);
  }
1158403
public Attribute getAttribute(String attrName) {
    Attribute attr = getCachedOwnAttrs().get(attrName);
    if (attr == null) {
      // look up attribute in parent entity
      EntityType extendsEntityType = getExtends();
      if (extendsEntityType != null) {
        attr = extendsEntityType.getAttribute(attrName);
      }
    }
    return attr;
  }
197900
public boolean validate(Entity entity, String attribute) throws APIException, ConnectionException, OidException {
        Asset asset = v1Instance.getAsset(entity.getInstanceKey()) != null ? v1Instance.getAsset(entity.getInstanceKey()) : v1Instance.getAsset(entity.getID());
        IAttributeDefinition attributeDefinition = asset.getAssetType().getAttributeDefinition(attribute);
        return validator.validate(asset, attributeDefinition);
    }
44658
public static Optional<Attribute> getValue(Attribute.Compound attribute, String name) {
    return attribute.getElementValues().entrySet().stream()
        .filter(e -> e.getKey().getSimpleName().contentEquals(name))
        .map(Map.Entry::getValue)
        .findFirst();
  }
709838
public boolean getAttributeAsBoolean(AnnotationAttributeType attribute) {
		String temp = attributes.get(attribute.getValue());

		return Boolean.parseBoolean(temp);
	}
238686
public Attribute<?> getAttribute(String attributeName) {
    for (Attribute<?> attribute : getAllAttributes()) {
      if (attribute.getAttributeName().equals(attributeName)) {
        return attribute;
      }
    }
    return null;
  }