public final class RelativePath extends Path implements Serializable
I.e. it is quite usual only associate resources and metrics from a single environment. It would be cumbersome to require the full canonical path for every metric one wants to associate with a resource. Therefore a partial path is used to refer to the metric.
The relative path contains one special segment type - encoded as ".." and represented using the
RelativePath.Up class that can be used to go up in the relative path.
| Modifier and Type | Class and Description |
|---|---|
static class |
RelativePath.Builder |
static class |
RelativePath.EnvironmentBuilder |
static class |
RelativePath.Extender |
static class |
RelativePath.FeedBuilder |
static class |
RelativePath.MetadataPackBuilder |
static class |
RelativePath.MetricBuilder |
static class |
RelativePath.MetricTypeBuilder |
static class |
RelativePath.OperationTypeBuilder |
static class |
RelativePath.RelationshipBuilder |
static class |
RelativePath.ResourceBuilder |
static class |
RelativePath.ResourceTypeBuilder |
static class |
RelativePath.StructuredDataBuilder |
static class |
RelativePath.TenantBuilder |
static class |
RelativePath.Up |
static class |
RelativePath.UpBuilder |
Path.ExtenderConstructor, Path.HintedTypeProvider, Path.Segment, Path.StructuredDataHintingTypeProvider, Path.TypeProviderendIdx, path, PATH_DELIM, startIdx, TYPE_DELIM| Modifier and Type | Method and Description |
|---|---|
CanonicalPath |
applyTo(CanonicalPath path)
Applies this relative path on the provided canonical path.
|
Iterator<RelativePath> |
ascendingIterator() |
Iterator<RelativePath> |
descendingIterator() |
RelativePath |
down()
If this path was created by going
up from another path, then this method can be used to go back
down to the previous paths representing some child resource of the resource represented by this path object. |
RelativePath |
down(int distance)
If this path was created by going
up from another path, then this method can be used to go back
down n steps to the previous paths representing some (grand-)child resource of the resource represented by
this path object. |
static RelativePath.Extender |
empty() |
static RelativePath |
fromPartiallyUntypedString(String path,
CanonicalPath initialPosition,
SegmentType intendedFinalType)
An overload of
Path.fromPartiallyUntypedString(String, TypeProvider) which uses the provided initial position
to figure out the possible type if is missing in the provided relative path. |
static RelativePath |
fromPartiallyUntypedString(String path,
Path.TypeProvider typeProvider) |
static RelativePath |
fromString(String path) |
boolean |
isParentOf(RelativePath other) |
RelativePath.Extender |
modified() |
protected Path |
newInstance(int startIdx,
int endIdx,
List<Path.Segment> segments) |
RelativePath |
slide(int startDelta,
int endDelta)
Moves the start and end of the path by the provided distances.
|
static RelativePath.Builder |
to() |
CanonicalPath |
toCanonicalPath()
Tries to convert this relative path to a canonical path.
|
RelativePath |
toRelativePath()
Tries to convert this path to a relative path.
|
String |
toString() |
RelativePath |
up()
Returns a path corresponding to the direct ancestor of the resource represented by this path object.
|
RelativePath |
up(int distance)
Returns a path corresponding to the n-th ancestor in the hierarchy.
|
equals, fromPartiallyUntypedString, getDepth, getPath, getSegment, getTop, hashCode, isCanonical, isDefined, isParentOf, isRelativepublic static RelativePath fromString(String path)
public static RelativePath fromPartiallyUntypedString(String path, Path.TypeProvider typeProvider)
path - the relative path to parsetypeProvider - the type provider used to figure out types of segments that don't explicitly mention itPath.fromPartiallyUntypedString(String, TypeProvider)public static RelativePath fromPartiallyUntypedString(String path, CanonicalPath initialPosition, SegmentType intendedFinalType)
Path.fromPartiallyUntypedString(String, TypeProvider) which uses the provided initial position
to figure out the possible type if is missing in the provided relative path.path - the relative path to parseinitialPosition - the initial position using which the types will be deduced for the segments that don't
specify the type explicitlyintendedFinalType - the type of the final segment in the path. This can resolve potentially ambiguous
situations where, given the initial position, more choices are possible.public static RelativePath.Extender empty()
public static RelativePath.Builder to()
protected Path newInstance(int startIdx, int endIdx, List<Path.Segment> segments)
newInstance in class Pathpublic CanonicalPath applyTo(CanonicalPath path)
path - public CanonicalPath toCanonicalPath()
I.e. this will not work on relative paths like ../r;id which doesn't itself represent a full canonical
path.
toCanonicalPath in class PathIllegalArgumentException - if the attempt to convert to canonical path failspublic RelativePath toRelativePath()
PathtoRelativePath in class Pathpublic RelativePath.Extender modified()
public Iterator<RelativePath> ascendingIterator()
ascendingIterator in class Pathpublic Iterator<RelativePath> descendingIterator()
descendingIterator in class Pathpublic RelativePath down()
Pathup from another path, then this method can be used to go back
down to the previous paths representing some child resource of the resource represented by this path object.public RelativePath down(int distance)
Pathup from another path, then this method can be used to go back
down n steps to the previous paths representing some (grand-)child resource of the resource represented by
this path object.public RelativePath up()
Pathpublic RelativePath up(int distance)
Pathpublic RelativePath slide(int startDelta, int endDelta)
Consider the path:
a/b/c
p1 = p.slide(1, 0) will produce p1 = "b/c", p1.slide(-1, 0) will produce a path
equivalent to the original one. p.slide(-1, 0) will produce an undefined path, because it would go past
the known start of the path (i.e. beyond "a").
startDelta - the number of steps to move the start of the pathendDelta - the number of steps to move the end of the pathpublic boolean isParentOf(RelativePath other)
Copyright © 2014–2016 Red Hat, Inc.. All rights reserved.