Add a list of references to a property on this bean.

A reference identify other beans based on schema and instance id.

@param propertyName name of the property as defined by the bean's schema.
@param refs the reference as defined by the bean's schema.
517306
public void addReference(final String propertyName, final Collection<BeanId> refs) {
        Preconditions.checkNotNull(refs);
        Preconditions.checkNotNull(propertyName);
        checkCircularReference(refs.toArray(new BeanId[refs.size()]));
        List<BeanId> list = references.get(propertyName);
        if (list == null) {
            list = new ArrayList<>();
            list.addAll(refs);
            references.put(propertyName, list);
        } else {
            list.addAll(refs);
        }
    }
626298
@Override
	public void setReferences(IReferences references) {

		List<Object> loggers = references.getOptional(new Descriptor(null, "logger", null, null, null));
		for (Object logger : loggers) {
			if (logger instanceof ILogger && logger != this)
				_loggers.add((ILogger) logger);
		}
	}
425390
public boolean addRef(Object object)
        throws IOException
    {
        if (_refs == null)
            _refs = new IdentityHashMap();

        Integer ref = (Integer) _refs.get(object);

        if (ref != null) {
            int value = ref.intValue();

            writeRef(value);
            return true;
        }
        else {
            _refs.put(object, new Integer(_refs.size()));

            return false;
        }
    }
32909
private void addProperties(final PropertyDescriptor[] _properties) throws ColumnBuilderException, ClassNotFoundException {
        for (final PropertyDescriptor property : _properties) {
            if (isValidProperty(property)) {
                addColumn(getColumnTitle(property), property.getName(), property.getPropertyType().getName(), getColumnWidth(property));
            }
        }
        setUseFullPageWidth(true);
    }
330804
public String logicalCollectionColumnName(String columnName, String propertyName, String referencedColumn) {
		return isNullOrEmpty( columnName ) ?
				columnName :
				unqualify( propertyName ) + "_" + referencedColumn;
	}
521821
public void addProperty(String propertyName, Object value)
    {
        if (propertyName != null)
        {
            propertyNames.add(propertyName);
            if (value == null)
            {
                properties.remove(propertyName);
            }
            else
            {
                properties.put(propertyName, value);
            }
        }
    }
728291
@Override
    void findReferencedClassNames(final Set<String> referencedClassNames) {
        if (enumValue != null) {
            enumValue.findReferencedClassNames(referencedClassNames);
        } else if (classRef != null) {
            referencedClassNames.add(classRef.getClassName());
        } else if (annotationInfo != null) {
            annotationInfo.findReferencedClassNames(referencedClassNames);
        } else if (objectArrayValue != null) {
            for (final ObjectTypedValueWrapper item : objectArrayValue) {
                item.findReferencedClassNames(referencedClassNames);
            }
        }
    }
346738
public void addRefs(Multimap<BeanId, JpaRef> queryRefs) {
        refs.putAll(queryRefs);
        for (BeanId id : refs.keySet()) {
            putIfAbsent(id);
            for (JpaRef ref : refs.get(id)) {
                putIfAbsent(ref.getTarget());
            }
        }
    }
192727
public static PropertyDescriptor getPropertyDescriptor(Object bean, String propertyName)
	{
		BeanInfo beanInfo = getBeanInfo(bean);
		
		PropertyDescriptor propertyDescriptor = getFeatureDescriptor(propertyName, beanInfo.getPropertyDescriptors());

		checkArgument(propertyDescriptor != null, "No such property '%s' on bean: %s", propertyName, bean);
		
		return propertyDescriptor;
	}
597760
public Collection<Object> getObjectReferenceList(String field, String schemaName) {
        List<String> instanceIds = references.get(field);
        if(instanceIds == null || instanceIds.size() == 0) {
            return null;
        }
        List<Object> objects = new ArrayList<>();
        for (String instanceId : instanceIds) {
            BeanId id = BeanId.create(instanceId, schemaName);
            Object instance = instances.get(id);
            if(instance != null) {
                objects.add(instance);
            } else {
                instance = cache.get(id);
                instances.put(id, instance);
                objects.add(instance);
            }
        }
        return objects;
    }
283449
public void clear(final String propertyName) {
        Preconditions.checkNotNull(propertyName);
        if (properties.containsKey(propertyName)) {
            properties.put(propertyName, null);
        } else if (references.containsKey(propertyName)) {
            references.put(propertyName, null);
        }
    }
392747
@Reference(service=SessionHelper.class, name="sessionHelper")
    protected void setSessionHelper(ServiceReference<SessionHelper> ref) {
        sessionHelperSRRef.setReference(ref);
    }
211673
public void remove(final String propertyName) {
        Preconditions.checkNotNull(propertyName);
        if (properties.containsKey(propertyName)) {
            properties.remove(propertyName);
        } else if (references.containsKey(propertyName)) {
            references.remove(propertyName);
        }
    }
172069
public static boolean isReferenceProperty(final Node node, final String propertyName) throws RepositoryException {
        final Optional<PropertyDefinition> propertyDefinition = getDefinitionForPropertyName(node, propertyName);

        return propertyDefinition.isPresent() &&
                (propertyDefinition.get().getRequiredType() == REFERENCE
                        || propertyDefinition.get().getRequiredType() == WEAKREFERENCE);
    }
83518
private void checkReferenceForeignkeys(ModelDef modelDef, ReferenceDescriptorDef refDef) throws ConstraintException
    {
        String foreignkey = refDef.getProperty(PropertyHelper.OJB_PROPERTY_FOREIGNKEY);

        if ((foreignkey == null) || (foreignkey.length() == 0))
        {
            throw new ConstraintException("The reference "+refDef.getName()+" in class "+refDef.getOwner().getName()+" has no foreignkeys");
        }

        // we know that the class is present because the reference constraints have been checked already
        ClassDescriptorDef ownerClass = (ClassDescriptorDef)refDef.getOwner();
        ArrayList          keyFields;
        FieldDescriptorDef keyField;
        
        try
        {
            keyFields = ownerClass.getFields(foreignkey);
        }
        catch (NoSuchFieldException ex)
        {
            throw new ConstraintException("The reference "+refDef.getName()+" in class "+refDef.getOwner().getName()+" specifies a foreignkey "+ex.getMessage()+" that is not a persistent field in its owner class "+ownerClass.getName());
        }
        for (int idx = 0; idx < keyFields.size(); idx++)
        {
            keyField = (FieldDescriptorDef)keyFields.get(idx);
            if (keyField.getBooleanProperty(PropertyHelper.OJB_PROPERTY_IGNORE, false))
            {
                throw new ConstraintException("The reference "+refDef.getName()+" in class "+ownerClass.getName()+" uses the field "+keyField.getName()+" as foreignkey although this field is ignored in this class");
            }
        }
            
        // for the referenced class and any subtype that is instantiable (i.e. not an interface or abstract class)
        // there must be the same number of primary keys and the jdbc types of the primary keys must
        // match the jdbc types of the foreignkeys (in the correct order)
        String             targetClassName = refDef.getProperty(PropertyHelper.OJB_PROPERTY_CLASS_REF);
        ArrayList          queue           = new ArrayList();
        ClassDescriptorDef referencedClass;
        ArrayList          primFields;
        FieldDescriptorDef primField;
        String             primType;
        String             keyType;
        
        queue.add(modelDef.getClass(targetClassName));

        while (!queue.isEmpty())
        {
            referencedClass = (ClassDescriptorDef)queue.get(0);
            queue.remove(0);

            for (Iterator it = referencedClass.getExtentClasses(); it.hasNext();)
            {
                queue.add(it.next());
            }
            if (!referencedClass.getBooleanProperty(PropertyHelper.OJB_PROPERTY_GENERATE_REPOSITORY_INFO, true))
            {
                continue;
            }
            primFields = referencedClass.getPrimaryKeys();
            if (primFields.size() != keyFields.size())
            {
                throw new ConstraintException("The number of foreignkeys ("+keyFields.size()+") of the reference "+refDef.getName()+" in class "+refDef.getOwner().getName()+" doesn't match the number of primarykeys ("+primFields.size()+") of the referenced class (or its subclass) "+referencedClass.getName());
            }
            for (int idx = 0; idx < primFields.size(); idx++)
            {
                keyField  = (FieldDescriptorDef)keyFields.get(idx);
                primField = (FieldDescriptorDef)primFields.get(idx);
                primType  = primField.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE);
                keyType   = keyField.getProperty(PropertyHelper.OJB_PROPERTY_JDBC_TYPE);
                if (!primType.equals(keyType))
                {
                    throw new ConstraintException("The jdbc-type of foreignkey "+keyField.getName()+" of the reference "+refDef.getName()+" in class "+refDef.getOwner().getName()+" doesn't match the jdbc-type of the corresponding primarykey "+primField.getName()+" of the referenced class (or its subclass) "+referencedClass.getName());
                }
            }
        }
    }
311010
private void initAttributesAndElements(String... propertyNames)
        {
        for (String propertyName : propertyNames)
            {
            Property property = new Property(propertyName);
            if (property.isAttribute())
                {
                m_attributes.add(property);
                }
            else
                {
                m_elements.add(property);
                }
            }
        }
157405
public List<BeanId> getReferences() {
        if (references == null) {
            return new ArrayList<>();
        }
        ArrayList<BeanId> result = new ArrayList<>();
        for (List<BeanId> b : references.values()) {
            if (b != null) {
                result.addAll(b);
            }

        }
        return result;
    }