All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.persistence.internal.jaxb.ObjectGraphImpl Maven / Gradle / Ivy

There is a newer version: 5.0.0-B02
Show newest version
package org.eclipse.persistence.internal.jaxb;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.eclipse.persistence.core.queries.CoreAttributeGroup;
import org.eclipse.persistence.jaxb.AttributeNode;
import org.eclipse.persistence.jaxb.ObjectGraph;
import org.eclipse.persistence.jaxb.Subgraph;

public class ObjectGraphImpl extends AttributeNodeImpl implements ObjectGraph, Subgraph {

    private CoreAttributeGroup attributeGroup;
    private Map attributeNodes;
    
    
    public ObjectGraphImpl(CoreAttributeGroup group) {
        super();
        this.attributeGroup = group;
        this.attributeNodes = new HashMap();
    }
    public Class getClassType() {
        return attributeGroup.getType();
    }

    public String getName() {
        return attributeGroup.getName();
    }

    public void addAttributeNodes(String... attributeName) {
        for(String attribute:attributeName) {
            AttributeNodeImpl impl = new AttributeNodeImpl(attribute);
            this.attributeNodes.put(attribute, impl);
            attributeGroup.addAttribute(attribute);
        }
    }

    public Subgraph addSubgraph(String attribute) {
        CoreAttributeGroup group = new CoreAttributeGroup();
        if(attributeGroup.getItem(attribute) == null) {
            AttributeNodeImpl impl = new AttributeNodeImpl(attribute);
            this.attributeNodes.put(attribute,  impl);
        }
        this.attributeGroup.addAttribute(attribute, group);
        
        return new ObjectGraphImpl(group);
    }

    public Subgraph addSubgraph(String attribute, Class type) {
        CoreAttributeGroup group = new CoreAttributeGroup(null, type, true);
        if(attributeGroup.getItem(attribute) == null) {
            AttributeNodeImpl impl = new AttributeNodeImpl(attribute);
            this.attributeNodes.put(attribute,  impl);
        }
        this.attributeGroup.addAttribute(attribute, group);
        
        return new ObjectGraphImpl(group);
    }

    public List getAttributeNodes() {
        ArrayList nodes = new ArrayList();
        for(AttributeNode next:this.attributeNodes.values()) {
            nodes.add(next);
        }
        return nodes;
    }
    
    public CoreAttributeGroup getAttributeGroup() {
        return this.attributeGroup;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy