Top Description Fields Constructors Methods
org.junit.platform.engine.discovery

public final Class FilePosition

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@API
status:STABLE
since:1.7
Static Imports
org.apiguardian.api.API.Status.STABLE

Position inside a file represented by line and column numbers.

Implementation Note

This class is a copy of FilePosition, which is not accessible from this package. The decision to duplicate it is motivated by an eventual divergence between the two classes in the future.

Since
1.7

Field Summary

Modifier and TypeField and Description
private final @Nullable Integer
private final int
private static final Logger
private static final long

Constructor Summary

AccessConstructor and Description
private
FilePosition(int line)

private
FilePosition(int line, int column)

Method Summary

Modifier and TypeMethod and Description
public boolean
equals(Object o)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

public static FilePosition

Returns:

a FilePosition with the given line number
from
(int
the line number; must be greater than zero
line
)

Create a new FilePosition using the supplied line number and an undefined column number.

public static FilePosition

Returns:

a FilePosition with the given line and column numbers
from
(int
the line number; must be greater than zero
line
,
int
the column number; must be greater than zero
column
)

Create a new FilePosition using the supplied line and column numbers.

public static Optional<FilePosition>

Returns:

an Optional containing a FilePosition with the parsed line and column numbers; never null but potentially empty
fromQuery
(String
the query string; may be null
query
)

Create an optional FilePosition by parsing the supplied query string.

public Optional<Integer>

Returns:

an Optional containing the column number; never null but potentially empty
getColumn
()

Get the column number of this FilePosition, if available.

public int

Returns:

the line number
getLine
()

Get the line number of this FilePosition.

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for this object.

pack-priv String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAllwaitwaitwait

Field Detail

columnback to summary
private final @Nullable Integer column
lineback to summary
private final int line
loggerback to summary
private static final Logger logger
serialVersionUIDback to summary
private static final long serialVersionUID
Annotations
@Serial

Constructor Detail

FilePositionback to summary
private FilePosition(int line)
FilePositionback to summary
private FilePosition(int line, int column)

Method Detail

equalsback to summary
public boolean equals(Object o)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Annotations
@Override
fromback to summary
public static FilePosition from(int line)

Create a new FilePosition using the supplied line number and an undefined column number.

Parameters
line:int

the line number; must be greater than zero

Returns:FilePosition

a FilePosition with the given line number

fromback to summary
public static FilePosition from(int line, int column)

Create a new FilePosition using the supplied line and column numbers.

Parameters
line:int

the line number; must be greater than zero

column:int

the column number; must be greater than zero

Returns:FilePosition

a FilePosition with the given line and column numbers

fromQueryback to summary
public static Optional<FilePosition> fromQuery(String query)

Create an optional FilePosition by parsing the supplied query string.

Examples of valid query strings:

  • "line=23"
  • "line=23&column=42"
Parameters
query:String

the query string; may be null

Returns:Optional<FilePosition>

an Optional containing a FilePosition with the parsed line and column numbers; never null but potentially empty

Since
1.3
See Also
from(int), from(int, int)
getColumnback to summary
public Optional<Integer> getColumn()

Get the column number of this FilePosition, if available.

Returns:Optional<Integer>

an Optional containing the column number; never null but potentially empty

getLineback to summary
public int getLine()

Get the line number of this FilePosition.

Returns:int

the line number

hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for this object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Annotations
@Override
toQueryPartback to summary
pack-priv String toQueryPart()
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Annotations
@Override