/** * @param element not null * @return not null qualified name of the element */ private static String getQualifiedName(RefObject element) { String result; try { result = element.refGetValue( ATTRIBUTE_QUALIFIED_NAME ).toString(); } catch (Exception ex) { // comparing MOF models in MDR, which does not provide names of result = ""; } return result; }
public Collection<T> execute(Collection<T> collection) throws RuntimeException, IllegalArgumentException { Collection<T> result; Object value; result = new ArrayList<>(); for (T element:collection) { value = element.refGetValue( "name" ); if ( target.equals(value) ) { result.add(element); } } return result; }
public Collection<T> execute(Collection<T> collection) throws RuntimeException, IllegalArgumentException { Collection<T> result; Object value; result = new ArrayList<>(); for (T element:collection) { value = element.refGetValue( fieldName ); if ( target.equals(value) ) { result.add(element); } } return result; }
/** * This method requires an M1 object object and a StringBuilder where to describe the object. * * @param result is the buffer where to add the obect's description * @param object is the M1 object to investigate */ private void append(StringBuilder result, RefClass object, Set visited) { result.append( "RefClass ") .append( object.refMetaObject().refGetValue( "name" ) ); }
/** * This method requires an M1 object object and a StringBuilder where to describe the object. * * @param result is the buffer where to add the obect's description * @param object is the M1 object to investigate */ private void append(StringBuilder result, RefPackage object, Set visited) { result.append( "RefPackage ") .append( object.refMetaObject().refGetValue( "name" ) ); }
/** * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object) */ public int compare(RefBaseObject o1, RefBaseObject o2) { int result; String left; String right; if ( o1 instanceof RefObject && o2 instanceof RefObject ) { try { left = ""+((RefObject) o1).refGetValue( fieldName ); right= ""+((RefObject) o2).refGetValue( fieldName ); result = left.trim().compareTo( right.trim() ); } catch (Exception ex) { // wrong name // suppress the exception result=0; } } else { result = 0; } return result; } }
/** * @param wrapped not null * @param attributeNames * @param associationNames */ private CachedModelElement(RefObject wrapped, Collection<String> attributeNames, Collection<String> associationNames) { Object value; if ( wrapped == null ) { throw new IllegalArgumentException("Expected a non-null model element to wrap"); } this.wrapped = wrapped; for (String attributeName : attributeNames) { value = wrapped.refGetValue( attributeName ); attributeValues.put( attributeName, value); } for (String associationName : associationNames) { value = wrapped.refGetValue( associationName ); if ( value instanceof Collection ) { associationValues.put( associationName, new ArrayList<>((Collection) value)); } else { associationValues.put( associationName, value); } } }
/** * This method requires an M1 object object and a StringBuilder where to describe the object. * * @param result is the buffer where to add the obect's description * @param object is the M1 object/association to investigate */ private void append(StringBuilder result, String prefix, RefAssociation object, Set visited) { Iterator<RefAssociationLink> linksIterator; RefAssociationLink link; result.append( "RefAssociation ") .append( object.refMetaObject().refGetValue( "name" ) ); result.append( " {\n"); // linksIterator = object.refAllLinks().iterator(); // while ( linksIterator.hasNext() ) { // link = linksIterator.next(); // // result.append( prefix ); // toString( link, result, prefix+" ", visited ); // result.append( "\n"); // } result.append( prefix ) .append( "}"); }
/** * @param convertedValue not null * @param target not null */ private void setValue(Object convertedValue, RefObject target) { Object targetValue; try { targetValue = target.refGetValue(targetName); if ( targetValue instanceof Collection ) { if ( convertedValue instanceof Collection ) { ((Collection) targetValue).addAll((Collection) convertedValue); } else { ((Collection) targetValue).add( convertedValue ); } } else { target.refSetValue( targetName, convertedValue ); } } catch (Exception ex) { throw new IllegalArgumentException( "Setting '"+targetName+"' to value: '" +PRINT_MODEL_ELEMENT.execute( convertedValue ) +"' on target object " +PRINT_MODEL_ELEMENT.execute( target ) + " instance of " +PRINT_MODEL_ELEMENT.execute( target.refMetaObject() )+" failed with: ", ex); } }
if ( target != null ) { try { sourceValue = source.refGetValue( sourceName );