# PropertyPath

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/PropertyPath.java+class:androidx.appsearch.app.PropertyPath) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***


```
class PropertyPath : (Mutable)Iterable<PropertyPath.PathSegment!>
```

<br />

*** ** * ** ***

Represents a property path returned from searching the AppSearch Database.

One of the use cases for this class is when searching the AppSearch Database for the snippet matching use case. In this case you will get back `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.MatchInfo` objects that contain a property path signifying the location of a match within the database. This is a string that may look something like "foo.bar\[0\]". `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath` parses this string and breaks it up into a List of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment`s. These may represent either a property or a property and a 0-based index into the property. For instance, "foo.bar\[1\]" would be parsed into a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment` with a property name of foo and a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment` with a property name of bar and an index of 1. This allows for easier manipulation of the property path.

This class won't perform any retrievals, it will only parse the path string. As such, it may not necessarily refer to a valid path in the database.

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/SearchResult.MatchInfo` |   |

## Summary

| ### Nested types |
|---|
| `class https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment` A segment of a PropertyPath, which includes the name of the property and a 0-based index into this property. |

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#PropertyPath(java.util.List<androidx.appsearch.app.PropertyPath.PathSegment>)(pathList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment!>)` Constructor directly accepting a path list |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#PropertyPath(java.lang.String)(path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)` Constructor that parses a string representing the path to populate a List of PathSegments |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#equals(java.lang.Object)(o: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#get(int)(index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Returns the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment` at a specified index of the PropertyPath. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#hashCode()()` |
| `(https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-iterator/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterator/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment!>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#iterator()()` Returns an iterator over the PathSegments within the PropertyPath |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#size()()` Returns the number of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment`s in the PropertyPath. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath#toString()()` Returns a valid path string representing this PropertyPath |

### Inherited functions

From [java.lang.Iterable](https://developer.android.com/reference/java/lang/Iterable.html) `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterable/for-each.html(action: https://developer.android.com/reference/java/util/function/Consumer.html<T!>!)` `https://developer.android.com/reference/java/util/Spliterator.html<T!>!` `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-iterable/spliterator.html()`

## Public constructors

### PropertyPath

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
PropertyPath(pathList: (Mutable)List<PropertyPath.PathSegment!>)
```

Constructor directly accepting a path list

| Parameters |
|---|---|
| `pathList: (https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-mutable-list/index.html)https://kotlinlang.org/api/core/kotlin-stdlib/kotlin.collections/-list/index.html<https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment!>` | a list of PathSegments |

### PropertyPath

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
PropertyPath(path: String)
```

Constructor that parses a string representing the path to populate a List of PathSegments

| Parameters |
|---|---|
| `path: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | the string to be validated and parsed into PathSegments |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/IllegalArgumentException.html` | when the path is invalid or malformed |

## Public functions

### equals

```
fun equals(o: Any?): Boolean
```

### get

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun get(index: Int): PropertyPath.PathSegment
```

Returns the `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment` at a specified index of the PropertyPath.

Calling `get(1)` on a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath` representing "foo.bar\[1\]" will return a `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment` representing "bar\[1\]". `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment`s both with and without a property index of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment#NON_REPEATED_CARDINALITY()` are retrieved the same.

| Parameters |
|---|---|
| `index: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | the position into the PropertyPath |

| Throws |
|---|---|
| `https://developer.android.com/reference/java/lang/ArrayIndexOutOfBoundsException.html` | if index is not a valid index in the path list |

### hashCode

```
fun hashCode(): Int
```

### iterator

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun iterator(): (Mutable)Iterator<PropertyPath.PathSegment!>
```

Returns an iterator over the PathSegments within the PropertyPath

### size

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun size(): Int
```

Returns the number of `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment`s in the PropertyPath.

Paths representing "foo.bar" and "foo\[1\].bar\[1\]" will have the same size, as a property and an index into that property are stored in one `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PropertyPath.PathSegment`.

### toString

```
fun toString(): String
```

Returns a valid path string representing this PropertyPath