/** * @see org.eclipse.uml2.uml.TypedElement#getType() */ public Type getType() { return this.property.getType(); }
/** * @see org.eclipse.uml2.uml.NamedElement#getName() */ public String getName() { return this.property.getName(); }
/** * @see org.eclipse.uml2.uml.Element#getOwner() */ public Element getOwner() { return this.property.getOwner(); }
public static UmlgCollectionKindEnum from(Property p) { if (p.isOrdered() && p.isUnique()) { return ORDERED_SET; } else if (p.isOrdered() && !p.isUnique()) { return SEQUENCE; } else if (!p.isOrdered() && !p.isUnique()) { return BAG; } else if (!p.isOrdered() && p.isUnique()) { return SET; } else { throw new RuntimeException("wtf"); } }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Sets the default value for this property to the null value. * @param property The receiving '<em><b>Property</b></em>' model object. * <!-- end-model-doc --> * @generated NOT */ public static void setNullDefaultValue(Property property) { if (!(property.getDefaultValue() instanceof LiteralNull)) { property.createDefaultValue(null, null, UMLPackage.Literals.LITERAL_NULL); } }
protected static boolean otherEndIsOne(Property p) { if (p.getOtherEnd() != null) { Property otherEnd = p.getOtherEnd(); return isOne(otherEnd) && otherEnd.getQualifiers().size() == 0; } else { // TODO think about, this was false //if the other end does not exist treat as a many return false; } }
Type type = property.getType(); logger.log(Level.FINE, "Class: " + clazz.getName() + " - " + "Property: " + property.getName() + " - " + "Property Upper: " + property.getUpper() + " - " + "Property Lower: " + property.getLower()); String umlTypeName = type.getName(); String umlQualifiedTypeName = type.getQualifiedName(); if (property.getName().equals("")) { Type targetType = property.getType(); String newPropertyName = ""; if (property.getUpper() >= 0) { .getName()); property.setName(StringUtils.uncapitalize(newPropertyName)); umlQualifiedTypeName); if (!property.isReadOnly()) {
@Override public Object caseProperty(Property property) { Namespace namespace = property.getNamespace(); Classifier type = (Classifier) property.getType(); elementToEModelElementMap.put(property, eReference); eReference.setContainment(property.isComposite() || type instanceof DataType); } else { elementToEModelElementMap.put(property, eAttribute); String default_ = property.getDefault(); eStructuralFeature.setChangeable(!property.isReadOnly()); eStructuralFeature.setDerived(property.isDerived()); Property opposite = property.getOpposite(); if (property.isDerived() && !eOpposite.isDerived()) { eOpposite.setDerived(true);
public static boolean isControllingSide(Property p) { boolean result = p.isComposite(); if (p.getOtherEnd() == null) { result = true; } else if (isOneToOne(p) && !p.isComposite() && !p.getOtherEnd().isComposite()) { // If association is OneToOne and both sides are non composite then // if there is a 1-1 and 0-1 then take the 1-1 side as inverse=true else compare alphabetically if ((p.getLower() == 0 && p.getOtherEnd().getLower() == 0) || (p.getLower() == 1 && p.getOtherEnd().getLower() == 1)) { result = p.getName().compareTo(p.getOtherEnd().getName()) > -1; } else { result = p.getLower() == 1 && p.getUpper() == 1; } } else if (isOneToMany(p) && !p.isComposite() && !p.getOtherEnd().isComposite()) { // If association is OneToMany and both sides are non composite then // take the many side as inverse=true //result = p.getUpper() == -1 || p.getUpper() > 1; result = true; } else if (isManyToMany(p) && !p.isComposite() && !p.getOtherEnd().isComposite()) { // If association is ManyToMany and both sides are non composite // then take any side consistently result = 0 > p.getName().compareTo(p.getOtherEnd().getName()); } return result; }
public static Property getOtherEndToComposite(Interface inf) { Set<Association> associations = getAllAssociations(inf); for (Association association : associations) { List<Property> memberEnds = association.getMemberEnds(); for (Property property : memberEnds) { if (!property.isComposite() && property.getType() != inf && property.getOtherEnd().isComposite() && UmlgClassOperations.isSpecializationOf(inf, property.getOtherEnd().getType())) { return property; } } } return null; }
public static OJPathName getTypePath(Property p) { Objects.requireNonNull(p.getType(), "property " + p.getName() + "'s type is not defined"); if (!(p.getType() instanceof PrimitiveType) && !(p.getType() instanceof Enumeration) && p.getType() instanceof DataType) { return DataTypeEnum.getPathNameFromDataType((DataType) p.getType()); } else { return new OJPathName(Namer.name(p.getType().getNearestPackage()) + "." + UmlgPropertyOperations.umlPrimitiveTypeToJava(p.getType())); } }
@Override public void visitBefore(Property element) { //Can not get find the stereotype in the constructor as the model is not loaded yet. if (this.stereotype == null) { this.stereotype = ModelLoader.INSTANCE.findStereotype("Index"); } PropertyWrapper pWrap = new PropertyWrapper(element); if (element.isStereotypeApplied(this.stereotype) && (pWrap.isMany() || !(element.getType() instanceof DataType))) { throw new IllegalStateException(String.format("Only PrimitiveType may be indexed currently! Current element %s is a %s", new String[]{element.getQualifiedName(), element.getType().getQualifiedName()})); } }
/** * @return this.property.getUpper() * @see org.eclipse.uml2.uml.Property#getUpper() */ public int upper() { return this.property.getUpper(); }
protected static EList<org.eclipse.uml2.uml.Class> getExtendedMetaclasses( Stereotype stereotype, EList<org.eclipse.uml2.uml.Class> extendedMetaclasses) { for (Property ownedAttribute : stereotype.getOwnedAttributes()) { if (ownedAttribute.getAssociation() instanceof Extension) { Type type = ownedAttribute.getType(); if (type instanceof org.eclipse.uml2.uml.Class) { extendedMetaclasses.add((org.eclipse.uml2.uml.Class) type); } } } return extendedMetaclasses; }
/** * <!-- begin-user-doc --> * <!-- end-user-doc --> * <!-- begin-model-doc --> * Only a navigable property can be marked as readOnly. * isReadOnly implies isNavigable() * @param property The receiving '<em><b>Property</b></em>' model object. * @param diagnostics The chain of diagnostics to which problems are to be appended. * @param context The cache of context-specific information. * <!-- end-model-doc --> * @generated NOT */ public static boolean validateNavigableReadonly(Property property, DiagnosticChain diagnostics, Map<Object, Object> context) { boolean result = true; if (property.isReadOnly() && property.getAssociation() != null && !property.isNavigable()) { result = false; if (diagnostics != null) { diagnostics.add(new BasicDiagnostic(Diagnostic.WARNING, UMLValidator.DIAGNOSTIC_SOURCE, UMLValidator.PROPERTY__NAVIGABLE_READONLY, UMLPlugin.INSTANCE.getString( "_UI_Property_NavigableReadOnly_diagnostic", //$NON-NLS-1$ getMessageSubstitutions(context, property)), new Object[]{property})); } } return result; }
@Override public void visitBefore(Property p) { PropertyWrapper pWrap = new PropertyWrapper(p); if (pWrap.isComponent()) { OJAnnotatedClass owner = findOJClass(p); OJAnnotatedOperation createComponents = owner.findOperation("createComponents"); OJAnnotatedOperation init = (OJAnnotatedOperation) owner.findOperation("init", Arrays.asList(UmlgClassOperations.getPathName(p.getOtherEnd().getType()))); OJIfStatement ifNull = new OJIfStatement(pWrap.getter() + "() == null", pWrap.setter() + "(new " + pWrap.javaBaseTypePath().getLast() + "(true))"); owner.addToImports(pWrap.javaBaseTypePath()); createComponents.getBody().addToStatements(ifNull); if (p.getType() instanceof org.eclipse.uml2.uml.Class && init != null) { init.getBody().addToStatements(pWrap.getter() + "().init(this)"); } } }
public boolean isQualifier() { Element owner = this.property.getOwner(); return owner instanceof Property && ((Property) owner).getQualifiers().contains(this.property); }
/** * @see org.eclipse.uml2.uml.StructuralFeature#isReadOnly() */ public boolean isReadOnly() { return this.property.isReadOnly(); }
public boolean hasLookup() { if (!isComposite() && !(getType() instanceof Enumeration) && !isDerived() && !isQualifier() && getOtherEnd() != null && !(getOtherEnd().getType() instanceof Enumeration) && !getOtherEnd().isComposite()) { return true; } else { return false; } }
/** * @see org.eclipse.uml2.uml.Property#getQualifiers() */ public EList getQualifiers() { return this.property.getQualifiers(); }