@Override
    public SemanticAxiom joinWith(SemanticAxiom other) throws SemanticModelException
    {
        if (!(other instanceof Instance))
        {
            throw new SemanticModelException("Not an instance: " + other.toString(), null);
        }
        Collection<PropertyValue> propertiesToAdd = new ArrayList<PropertyValue>();
        for (PropertyValue otherPropertyValue : ((Instance) other).getPropertiesAsPropertyValue())
        {
            if (null != otherPropertyValue.getObject() && otherPropertyValue.getObject() instanceof SemanticAxiom)
            {
                PropertyValue propertyValue = containsPropertyWithObject(((SemanticAxiom) otherPropertyValue.getObject()).getSemanticIdentifier());
                if (null == propertyValue)
                {
                    if (null == containsProperty(otherPropertyValue))
                    {
                        propertiesToAdd.add(otherPropertyValue);
                    }
                } else
                {
                    if (null != otherPropertyValue.getObject()
                            && otherPropertyValue.getObject() instanceof SemanticAxiom
                            && null != propertyValue.getObject()
                            && propertyValue.getObject() instanceof SemanticAxiom)
                    {
                        SemanticAxiom joinWith = ((SemanticAxiom) propertyValue.getObject()).joinWith((SemanticAxiom) otherPropertyValue.getObject());
                        propertyValue.setObject(joinWith);
                    }
                }
            }
        }
        for (PropertyValue propertyToAdd : propertiesToAdd)
        {
            addProperty(propertyToAdd);
        }
        return this;
    }
@ Override public SemanticAxiom joinWith ( SemanticAxiom other ) throws SemanticModelException { if ( ! ( other instanceof Instance ) ) { throw new SemanticModelException ( "Not an instance: " + other . toString ( ) , null ) ; } Collection < PropertyValue > propertiesToAdd = new ArrayList < PropertyValue > ( ) ; for ( PropertyValue otherPropertyValue : ( ( Instance ) other ) . getPropertiesAsPropertyValue ( ) ) { if ( null != otherPropertyValue . getObject ( ) && otherPropertyValue . getObject ( ) instanceof SemanticAxiom ) { PropertyValue propertyValue = containsPropertyWithObject ( ( ( SemanticAxiom ) otherPropertyValue . getObject ( ) ) . getSemanticIdentifier ( ) ) ; if ( null == propertyValue ) { if ( null == containsProperty ( otherPropertyValue ) ) { propertiesToAdd . add ( otherPropertyValue ) ; } } else { if ( null != otherPropertyValue . getObject ( ) && otherPropertyValue . getObject ( ) instanceof SemanticAxiom && null != propertyValue . getObject ( ) && propertyValue . getObject ( ) instanceof SemanticAxiom ) { SemanticAxiom joinWith = ( ( SemanticAxiom ) propertyValue . getObject ( ) ) . joinWith ( ( SemanticAxiom ) otherPropertyValue . getObject ( ) ) ; propertyValue . setObject ( joinWith ) ; } } } } for ( PropertyValue propertyToAdd : propertiesToAdd ) { addProperty ( propertyToAdd ) ; } return this ; }
<p>
Precondition: only intented for Instances with the same
ISemanticIdentifier.
<p>
The "other" Instance may have properties not referenced by this: those
properties are added.

<p>
When the "other" Instance has a property that this one also has, but the
"other" Instance property is different, joinWith proceeds recursively.