Package org.eclipse.emf.compare.match.eobject

## Class URIDistance

- java.lang.Object
- - org.eclipse.emf.compare.match.eobject.URIDistance

All Implemented Interfaces:
  `com.google.common.base.Function<EObject,​Iterable<String>>`, `Function<EObject,​Iterable<String>>`

    public class URIDistance
    extends Object
    implements com.google.common.base.Function<EObject,​Iterable<String>>

This class is able to measure similarity between "URI like" strings, basically strings separated by "/". This is mainly intended to be used with EMF's fragments.

### Constructor Summary

Constructors
`URIDistance()` Create a new `URIDistance`.

### Method Summary

All Methods Instance Methods Concrete Methods
`Iterable<String>` `apply​(EObject input)`
`int` `getUpperBoundDistance()` return the maximum value we can get for this distance.
`int` `proximity​(Iterable<String> aPath, Iterable<String> bPath)` Return a metric result URI similarities.
`int` `proximity​(EObject a, EObject b)` Return a metric result URI similarities.
`String` `retrieveFragment​(EObject input)` the containing fragment for a given `EObject`.
`void` `setComparison​(Comparison comparison)` Set an optional comparison used to retrieve matches already computed.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface com.google.common.base.Function

`equals`

### Methods inherited from interface java.util.function.Function

`andThen, compose`

### Constructor Detail

#### URIDistance

    public URIDistance()

Create a new `URIDistance`.

### Method Detail

#### setComparison

    public void setComparison​(Comparison comparison)

Set an optional comparison used to retrieve matches already computed. This will impact the way the uri is computed by making sure two matching objects will have the same URI.

Parameters:
  `comparison` - the comparison to use to retrieve the matches.

#### proximity

    public int proximity​(EObject a,
                         EObject b)

Return a metric result URI similarities. It compares 2 strings splitting those by "/" and return an int representing the level of similarity. 0 - they are exactly the same to 10 - they are completely different. "adding a fragment", "removing a fragment".

Parameters:
  `a` - First of the two `EObject`s to compare.
  `b` - Second of the two `EObject`s to compare.
Returns:
  The number of changes to transform one uri to another one.

#### proximity

    public int proximity​(Iterable<String> aPath,
                         Iterable<String> bPath)

Return a metric result URI similarities. It compares 2 lists of fragments and return an int representing the level of similarity. 0 - they are exactly the same to 10 - they are completely different. "adding a fragment", "removing a fragment".

Parameters:
  `aPath` - First of the two list of `String`s to compare.
  `bPath` - Second of the two list of `String`s to compare.
Returns:
  The number of changes to transform one uri to another one.

#### apply

    public Iterable<String> apply​(EObject input)

Specified by:
  `apply` in interface `com.google.common.base.Function<EObject,​Iterable<String>>`
Specified by:
  `apply` in interface `Function<EObject,​Iterable<String>>`
See Also:
  `Function.apply(java.lang.Object)`

#### retrieveFragment

    public String retrieveFragment​(EObject input)

the containing fragment for a given `EObject`.

Parameters:
  `input` - an EObject.
Returns:
  a String representation of its containing fragment.

#### getUpperBoundDistance

    public int getUpperBoundDistance()

return the maximum value we can get for this distance.

Returns:
  the maximum value we can get for this distance.