@Override public EPackage getReal() { return ePackage.get(); }
@Nonnull @Override public BasicNamespace setReal(EPackage ePackage) { checkNotNull(ePackage, "ePackage"); this.ePackage.update(ePackage); return this; }
/** * Constructs a new {@code ContentsList}. * * @param owner the owner of this list * @param features the containment features that are handled by this list * @param resolve {@code true} if proxied {@link EObject objects} has to be resolved */ protected ContentsList(PersistentEObject owner, List<EStructuralFeature> features, boolean resolve) { this.owner = owner; this.features = features; this.resolve = resolve; this.nonResolvingList = LazyReference.soft(() -> resolve ? new ContentsList<>(owner, features, false) : this); }
/** * Removes the containing edge. */ public void removeContainingEdge() { getContainingEdge().ifPresent(ContainingEdge::remove); lazyContainingEdge.update(null); }
/** * Constructs a new {@code ClassBean} with the given {@code name} and {@code uri}, which are used as a simple * representation of a an {@link org.eclipse.emf.ecore.EClass}. * * @param name the name of the {@link org.eclipse.emf.ecore.EClass} * @param uri the literal representation of the {@link org.eclipse.emf.common.util.URI} of the {@link * org.eclipse.emf.ecore.EClass} */ protected ClassBean(String name, String uri) { this.name = checkNotNull(name, "name"); this.uri = checkNotNull(uri, "uri"); lazyClass = LazyReference.soft(() -> { EPackage p = EPackage.Registry.INSTANCE.getEPackage(uri); checkNotNull(p, "Unable to find EPackage associated with URI: %s. " + "Make sure it is registered in EPackage.Registry", uri); EClass c = (EClass) p.getEClassifier(name); checkNotNull(c, "Unable to find EClass '%s' from EPackage '%s'", name, uri); return c; }); }
/** * Constructs a new {@code ClassBean} for the represented {@code reference}. * * @param reference the represented {@link EClass} */ private ClassBean(EClass reference) { this(reference.getName(), reference.getEPackage().getNsURI()); lazyClass.update(reference); }
@Override public PersistentEObject eInternalContainer() { return lazyContainer.get(); }
/** * Constructs a new {@code BasicClass} from the represented meta-class. * * @param eClass the represented meta-class */ public BasicClass(EClass eClass) { this(BasicNamespace.Registry.getInstance().get(eClass.getEPackage()), eClass.getName()); this.eClass.update(eClass); }
@Override public EClass getReal() { return eClass.get(); }
@Nonnull @Override public BasicClass setReal(EClass eClass) { checkNotNull(eClass, "eClass"); this.eClass.update(eClass); return setName(eClass.getName()); }
@Nonnull @Override public List<E> basicList() { return nonResolvingList.get(); }
/** * Defines the containing edge from the specified {@code bean}. * * @param bean the simple representation of the containing edge */ public void setContainingEdge(SingleFeatureBean bean) { // Remove the existing container, if defined removeContainingEdge(); // Link this vertex with its container ContainingEdge edge = ContainingEdge.create(graph, this, bean); lazyContainingEdge.update(edge); }
/** * Retrieves the {@link org.eclipse.emf.ecore.EClass} corresponding to this {@code ClassBean}. * * @return a class, or {@code null} if it cannot be found */ @Nonnull public EClass get() { return lazyClass.get(); }
/** * Defines the meta-class vertex from the specified {@code bean}. If the meta-class is already defined, then this * method does nothing. * * @param bean the simple representation of the meta-class vertex * * @return {@code true} if the meta-class has been defined for this vertex, {@code false} if the meta-class was * already defined */ public boolean setClassVertex(ClassBean bean) { if (getClassVertex().isPresent()) { // The meta-class is already defined return false; } // Retrieve or create the meta-class vertex ClassVertex classVertex = ClassVertex.getOrCreate(graph, bean); lazyClassVertex.update(classVertex); // Link this vertex with its meta-class InstanceOfEdge.create(graph, this, classVertex); return true; }
/** * Returns the meta-class vertex. * * @return an {@link Optional} containing the meta-class vertex */ @Nonnull public Optional<ClassVertex> getClassVertex() { return Optional.ofNullable(lazyClassVertex.get()); }
@Override protected void eBasicSetContainer(@Nullable InternalEObject newContainer, int newContainerFeatureID) { if (nonNull(newContainer)) { PersistentEObject container = PersistentEObject.from(newContainer); EReference containmentFeature = eContainmentFeature(this, container, newContainerFeatureID); lazyContainer.update(container); eStore().updateContainment(this, containmentFeature, container); resource(container.resource()); } else { lazyContainer.update(null); eStore().removeContainment(this); resource(null); } }
/** * Returns the containing edge. * * @return an {@link Optional} containing the containing edge */ @Nonnull public Optional<ContainingEdge> getContainingEdge() { return Optional.ofNullable(lazyContainingEdge.get()); }
@Override public void resource(@Nullable Resource.Internal newResource) { if (locked || resource == newResource) { return; } locked = true; resource = newResource; // Refresh the container if necessary if (lazyStore.isLoaded()) { lazyContainer.get(); } // Define and copy the store if necessary StoreAdapter newStore = getOrCreateStore(newResource); refreshStore(newStore); locked = false; }