Refine search
protected Optional<String> optionalAttribute(String... attributeIds) { if (element.getAnyAttribute().isEmpty()) { return Optional.empty(); } final List<String> attributes = Arrays.asList(attributeIds); return element.getAnyAttribute().stream() .filter(e -> attributes.contains(e.getEStructuralFeature().getName())) .map(e -> e.getValue().toString()) .findFirst(); }
protected Object getValue(FeatureMap featureMap, String name, boolean remove) { for (Iterator<FeatureMap.Entry> entries = featureMap.iterator(); entries .hasNext();) { FeatureMap.Entry entry = entries.next(); if (name.equals(entry.getEStructuralFeature().getName())) { if (remove) { entries.remove(); } return entry.getValue(); } } return null; }
protected Object getValue(FeatureMap featureMap, String name, boolean remove) { for (Iterator<FeatureMap.Entry> entries = featureMap.iterator(); entries .hasNext();) { FeatureMap.Entry entry = entries.next(); if (name.equals(entry.getEStructuralFeature().getName())) { if (remove) { entries.remove(); } return entry.getValue(); } } return null; }
public Object remove(EStructuralFeature feature, int index) { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature); Entry [] entries = (Entry[])data; int count = 0; for (int i = 0; i < size; ++i) { Entry entry = entries[i]; if (validator.isValid(entry.getEStructuralFeature())) { if (count == index) { remove(i); return FeatureMapUtil.isFeatureMap(feature) ? entry : entry.getValue(); } ++count; } } throw new IndexOutOfBoundsException("index=" + index + ", size=" + count); }
@Override public boolean equals(Object that) { if (this == that) { return true; } else if (!(that instanceof FeatureMap.Entry)) { return false; } else { FeatureMap.Entry entry = (FeatureMap.Entry)that; return entry.getEStructuralFeature() == eStructuralFeature && (value == null ? entry.getValue() == null : value.equals(entry.getValue())); } }
/** * Returns {@code true} if the feature of the {@code entry} must be included in the result, {@code false} if it * should be ignored. * * @param entry the entry to test * * @return {@code true} if the feature of the {@code entry} must be included in the result, {@code false} if it * should be ignored * * @see #isIncluded(EStructuralFeature) */ protected boolean isIncludedEntry(FeatureMap.Entry entry) { final EStructuralFeature f = entry.getEStructuralFeature(); return nonNull(entry.getValue()) && isIncluded(f) && EFeatures.isReference(f) && EFeatures.asReference(f).isContainment(); }
/** * Returns {@code true} if the feature of the {@code entry} must be included in the result, {@code false} if it * should be ignored. * * @param entry the entry to test * * @return {@code true} if the feature of the {@code entry} must be included in the result, {@code false} if it * should be ignored * * @see #isIncluded(EStructuralFeature) */ protected boolean isIncludedEntry(FeatureMap.Entry entry) { final EStructuralFeature feature = entry.getEStructuralFeature(); return nonNull(entry.getValue()) && isIncluded(feature) && EFeatures.isReference(feature) && EFeatures.asReference(feature).isContainment(); }
public boolean retainAll(EStructuralFeature feature, Collection<?> collection) { boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature); FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature); List<Entry> entryCollection = new BasicEList<Entry>(collection.size()); Entry [] entries = (Entry[])data; for (int i = size; --i >= 0; ) { Entry entry = entries[i]; if (validator.isValid(entry.getEStructuralFeature())) { if (!collection.contains(isFeatureMap ? entry : entry.getValue())) { entryCollection.add(entry); } } } return removeAll(entryCollection); }
public boolean retainAll(EStructuralFeature feature, Collection<?> collection) { boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature); FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature); List<Entry> entryCollection = new BasicEList<Entry>(collection.size()); for (int i = delegateSize(); --i >= 0; ) { Entry entry = delegateGet(i); if (validator.isValid(entry.getEStructuralFeature())) { if (!collection.contains(isFeatureMap ? entry : entry.getValue())) { entryCollection.add(entry); } } } return removeAll(entryCollection); }
public Object remove(EStructuralFeature feature, int index) { FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature); int count = 0; for (int i = 0, size = delegateSize(); i < size; ++i) { Entry entry = delegateGet(i); if (validator.isValid(entry.getEStructuralFeature())) { if (count == index) { remove(i); return FeatureMapUtil.isFeatureMap(feature) ? entry : entry.getValue(); } ++count; } } throw new IndexOutOfBoundsException("index=" + index + ", size=" + count); }
private static String getText(FeatureMap root, String id) { Stack<FeatureMap> stack = new Stack<FeatureMap>(); stack.push(root); while (!stack.isEmpty()) { FeatureMap featureMap = stack.pop(); for (FeatureMap.Entry entry : featureMap) { if (entry.getEStructuralFeature() instanceof EReference) { AnyType anyType = (AnyType) entry.getValue(); String attributeValue = getAttributeValue(anyType.getAnyAttribute(), "ID"); if (attributeValue != null && attributeValue.equals(id)) { return getText(anyType.getMixed()); } stack.push(anyType.getMixed()); } } } return null; }
private String getAnyAttributeValue(BaseElement el, String attrName) { if (el == null || attrName == null || attrName.isEmpty()) { return null; } if (el.getAnyAttribute() != null && el.getAnyAttribute().size() > 0) { Iterator<FeatureMap.Entry> iter = el.getAnyAttribute().iterator(); while (iter.hasNext()) { FeatureMap.Entry entry = iter.next(); if (attrName.equals(entry.getEStructuralFeature().getName())) { return entry.getValue().toString(); } } } return null; }
@Override public boolean equals(Object that) { if (this == that) { return true; } else if (!(that instanceof FeatureMap.Entry)) { return false; } else { FeatureMap.Entry entry = (FeatureMap.Entry)that; return entry.getEStructuralFeature() == eStructuralFeature && (value == null ? entry.getValue() == null : value.equals(entry.getValue())); } }
public boolean retainAll(EStructuralFeature feature, Collection<?> collection) { boolean isFeatureMap = FeatureMapUtil.isFeatureMap(feature); FeatureMapUtil.Validator validator = FeatureMapUtil.getValidator(owner.eClass(), feature); List<Entry> entryCollection = new BasicEList<Entry>(collection.size()); for (int i = delegateSize(); --i >= 0; ) { Entry entry = delegateGet(i); if (validator.isValid(entry.getEStructuralFeature())) { if (!collection.contains(isFeatureMap ? entry : entry.getValue())) { entryCollection.add(entry); } } } return removeAll(entryCollection); }
/** * This returns the tool tip text for {@link CreateChildCommand}. */ public String getCreateChildToolTipText(Object owner, Object feature, Object child, Collection<?> selection) { if (feature instanceof EStructuralFeature && FeatureMapUtil.isFeatureMap((EStructuralFeature)feature)) { FeatureMap.Entry entry = (FeatureMap.Entry)child; feature = entry.getEStructuralFeature(); child = entry.getValue(); } String childType = feature instanceof EAttribute ? getTypeText((EAttribute)feature) : getTypeText(child); return getResourceLocator().getString ("_UI_CreateChild_tooltip", new Object[] {childType , getFeatureText(feature), getTypeText(owner) }); }
public static boolean isContainerAdHoc(FlowElementsContainer container) { if (container instanceof Process) { Process process = (Process) container; Iterator<FeatureMap.Entry> iter = process.getAnyAttribute().iterator(); while(iter.hasNext()) { FeatureMap.Entry entry = iter.next(); if(entry.getEStructuralFeature().getName().equals("adHoc")) { return Boolean.parseBoolean(((String)entry.getValue()).trim()); } } } else if (container instanceof AdHocSubProcess) { return true; } return false; } }
@Override public Object doAdjustReferences(CDOReferenceAdjuster adjuster, Object value, EStructuralFeature feature, int index) { FeatureMap.Entry entry = (FeatureMap.Entry)value; EStructuralFeature innerFeature = entry.getEStructuralFeature(); Object innerValue = entry.getValue(); CDOType innerType = CDOModelUtil.getType(innerFeature.getEType()); Object innerCopy = innerType.adjustReferences(adjuster, innerValue, feature, index); if (innerCopy != innerValue) // Just an optimization for NOOP adjusters { value = CDORevisionUtil.createFeatureMapEntry(innerFeature, innerCopy); } return value; } };
public static boolean isContainerAdHoc(FlowElementsContainer container) { if (container instanceof Process) { Process process = (Process) container; Iterator<FeatureMap.Entry> iter = process.getAnyAttribute().iterator(); while(iter.hasNext()) { FeatureMap.Entry entry = iter.next(); if(entry.getEStructuralFeature().getName().equals("adHoc")) { return Boolean.parseBoolean(((String)entry.getValue()).trim()); } } } else if (container instanceof AdHocSubProcess) { return true; } return false; } }
protected Collection<Object> getValues(FeatureMap featureMap, String name, boolean remove) { Collection<Object> values = new UniqueEList.FastCompare<Object>(); for (Iterator<FeatureMap.Entry> entries = featureMap.iterator(); entries .hasNext();) { FeatureMap.Entry entry = entries.next(); if (name.equals(entry.getEStructuralFeature().getName())) { if (remove) { entries.remove(); } values.add(entry.getValue()); } } return values; }
public static boolean isContainerAdHoc(FlowElementsContainer container) { if (container instanceof Process) { Process process = (Process) container; Iterator<FeatureMap.Entry> iter = process.getAnyAttribute().iterator(); while(iter.hasNext()) { FeatureMap.Entry entry = iter.next(); if(entry.getEStructuralFeature().getName().equals("adHoc")) { return Boolean.parseBoolean(((String)entry.getValue()).trim()); } } } else if (container instanceof AdHocSubProcess) { return true; } return false; } }