Exemplo n.º 1
0
 /**
  * Check that ph is not null and returns the property value by calling
  * ph.getSimplePropertyValue(pd)
  *
  * @param ph The property holder from which to retrieve the property value.
  * @param pd The property to retrieve.
  * @return The retrieved property value.
  * @throws InvalidModelException Thrown if the property value cannot be retrieved because the
  *     model is incomplete or otherwise invalid.
  * @throws PropertyNotPresentException Thrown if the property is undefined for ph.
  * @throws PropertyIsModalException Thrown if ph is modal and declarative.
  * @throws IllegalStateException Thrown if the lookup encounters a cycle of property reference
  *     dependencies.
  * @throws IllegalArgumentException Thrown if ph or pd is null.
  * @throws PropertyDoesNotApplyToHolderException Thrown if pd does not apply to ph.
  * @throws PropertyIsListException Thrown if the property is not scalar.
  */
 public static PropertyExpression getSimplePropertyValue(final NamedElement ph, final Property pd)
     throws InvalidModelException, PropertyNotPresentException, PropertyIsModalException,
         IllegalStateException, IllegalArgumentException, PropertyDoesNotApplyToHolderException,
         PropertyIsListException {
   if (ph == null) {
     throw new IllegalArgumentException("NamedElement ph cannot be null.");
   }
   PropertyExpression res = ph.getSimplePropertyValue(pd);
   if (res instanceof NamedValue) {
     AbstractNamedValue nv = ((NamedValue) res).getNamedValue();
     if (nv instanceof Property) {
       res = ph.getSimplePropertyValue((Property) nv);
     } else if (nv instanceof PropertyConstant) {
       res = ((PropertyConstant) nv).getConstantValue();
     }
   }
   return res;
 }
Exemplo n.º 2
0
 public static Classifier getClassifierReference(final NamedElement ph, final Property pd) {
   if (ph == null) {
     return null;
   }
   try {
     final PropertyExpression pv = ph.getSimplePropertyValue(pd);
     final Classifier ref = ((ClassifierValueImpl) pv).getClassifier();
     return ref;
   } catch (PropertyLookupException e) {
     return null;
   }
 }