public final class Positions
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Positions.DimensionStripper
A functional object to transform positions to other positions with the dimensions stripped as given in the
constructor.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
areDimensionsConsistent(java.util.Set<java.lang.Class<?>> dimensions,
java.util.Set<java.lang.Class<?>> positionCoordinatesToCheck) |
static boolean |
areDimensionsConsistentWithCoordinates(java.util.Set<java.lang.Class<?>> dimensions,
Position position)
Searches if given position coordinates match acceptable dimensions.
|
static void |
assertConsistentDimensions(Position position,
java.util.Set<java.lang.Class<?>> dimensions)
Checks if the given position is conform with the given coordinate and throws an exception, if not.
|
static java.lang.Iterable<Position> |
cartesianEnumProduct(java.lang.Class<?>... enumClasses)
Returns all positions which can be built from the values of the passed in classes that are assumed to be enum
classes.
|
static java.lang.Iterable<Position> |
cartesianEnumProduct(java.util.Set<java.lang.Class<?>> classes)
Returns all positions which can be built from the values of the passed in classes that are assumed to be enum
classes.
|
static java.lang.Iterable<Position> |
cartesianProduct(java.lang.Class<? extends java.lang.Enum<?>>... enumClasses)
Returns all positions which can be built from all combinations of the values of the given enum classes.
|
static java.lang.Iterable<Position> |
cartesianProduct(java.util.Set<java.lang.Class<? extends java.lang.Enum<?>>> enumClasses)
Returns all positions which can be built from all combinations of the values of the given enum classes.
|
static com.google.common.collect.ImmutableSetMultimap<Position,PositionPair> |
combineAll(java.util.Set<PositionPair> positionPairs,
java.util.Set<java.lang.Class<?>> targetDimensions)
Combines all position pairs into positions containing the given dimensions and returns a map from the combined
positions to the original position pairs.
|
static Position |
combineDimensions(PositionPair pair,
java.util.Set<java.lang.Class<?>> targetDimensions)
Combines the both positions of the pair in such a way, that for each coordinate of the types given in the given
set of dimensions have to be
either present in both positions of the pair, and then have to be the same
or be present in only one of the both positions
|
static Position |
combineDimensions(Position left,
Position right,
java.util.Set<java.lang.Class<?>> targetDimensions)
Combines the both positions in such a way, that for each coordinate of the types given in the given set of
dimensions have to be
either present in both positions of the pair, and then have to be the same
or be present in only one of the both positions
|
static <T> java.util.Set<T> |
coordinatesOfType(java.util.Set<Position> positions,
java.lang.Class<T> ofClass)
Extracts the provided class of the coordinate from the set of the positions.
|
static Position |
difference(Position left,
Position right)
Returns a position which contains the coordinates which are contained in the left position but not in the right
position.
|
static java.lang.Iterable<Position> |
from(java.lang.Class<? extends java.lang.Enum<?>> enumClass)
Returns one position for each value of the given enum.
|
static com.google.common.collect.Multimap<Position,Position> |
mapByStripping(java.lang.Iterable<Position> positions,
java.util.Set<java.lang.Class<?>> dimensionsToStrip) |
static <T> boolean |
oneIsNull(T left,
T right) |
static Positions.DimensionStripper |
strip(java.lang.Class<?> dimensionsToStrip)
Convenience delegation method to
stripping(Class) , for a bit more fluent syntax. |
static Positions.DimensionStripper |
stripping(java.lang.Class<?> dimensionsToStrip)
Factory method for a dimension stripper with one dimension to strip only
|
static Positions.DimensionStripper |
stripping(java.util.Set<? extends java.lang.Class<?>> dimensionsToStrip)
Factory method for a dimension stripper.
|
static Position |
union(Position left,
Position right)
Constructs a position, whose coordinates are the union of the coordinates of the two individual positions.
|
static java.util.Set<Position> |
unique(java.lang.Iterable<Position> positions)
Copies the given positions to a set, to be sure that each element is contained only once
|
public static Position union(Position left, Position right)
left
- the first position to use construct the union positionright
- the second position to construct the union positionjava.lang.NullPointerException
- if one of the arguments is null
java.lang.IllegalArgumentException
- if the given aguments have an overlap of dimensions and therefor the union of
the position is not well definedpublic static java.util.Set<Position> unique(java.lang.Iterable<Position> positions)
positions
- the positions, which shall be ensured that they are uniquepublic static Positions.DimensionStripper stripping(java.util.Set<? extends java.lang.Class<?>> dimensionsToStrip)
dimensionsToStrip
- the dimensions which shall be stripped from the positions passed to the stripper.public static Positions.DimensionStripper stripping(java.lang.Class<?> dimensionsToStrip)
dimensionsToStrip
- the dimension to stripstripping(Set)
public static Positions.DimensionStripper strip(java.lang.Class<?> dimensionsToStrip)
stripping(Class)
, for a bit more fluent syntax.dimensionsToStrip
- the dimension to stripstripping(Class)
public static void assertConsistentDimensions(Position position, java.util.Set<java.lang.Class<?>> dimensions)
position
- the position for which to check the consistencydimensions
- the dimensions for which the conformity has to be verified.java.lang.IllegalArgumentException
- if the position is not conformPosition.isConsistentWith(Set)
public static boolean areDimensionsConsistentWithCoordinates(java.util.Set<java.lang.Class<?>> dimensions, Position position)
dimensions
- position
- public static boolean areDimensionsConsistent(java.util.Set<java.lang.Class<?>> dimensions, java.util.Set<java.lang.Class<?>> positionCoordinatesToCheck)
public static Position combineDimensions(PositionPair pair, java.util.Set<java.lang.Class<?>> targetDimensions)
pair
- the pair, whose dimensions should be unitedtargetDimensions
- the dimension in which the positions shall be unitedpublic static Position combineDimensions(Position left, Position right, java.util.Set<java.lang.Class<?>> targetDimensions)
left
- the first of the two positions, whose dimensions should be unitedright
- the second of the two positions whose dimensions should be combinedtargetDimensions
- the dimension in which the positions shall be unitedpublic static <T> boolean oneIsNull(T left, T right)
public static com.google.common.collect.ImmutableSetMultimap<Position,PositionPair> combineAll(java.util.Set<PositionPair> positionPairs, java.util.Set<java.lang.Class<?>> targetDimensions)
positionPairs
- the position pairs to combine the final positionstargetDimensions
- the dimensions in which to combine the positionspublic static com.google.common.collect.Multimap<Position,Position> mapByStripping(java.lang.Iterable<Position> positions, java.util.Set<java.lang.Class<?>> dimensionsToStrip)
public static <T> java.util.Set<T> coordinatesOfType(java.util.Set<Position> positions, java.lang.Class<T> ofClass)
positions
- ofClass
- a class of the coordinate to be extracted@SafeVarargs public static final java.lang.Iterable<Position> cartesianProduct(java.lang.Class<? extends java.lang.Enum<?>>... enumClasses)
enumClasses
- the enum classes from which to get the values frompublic static final java.lang.Iterable<Position> from(java.lang.Class<? extends java.lang.Enum<?>> enumClass)
cartesianProduct(Class...)
with only one class given.enumClass
- the class of the enum from which to take the values as coordinatespublic static final java.lang.Iterable<Position> cartesianEnumProduct(java.lang.Class<?>... enumClasses)
cartesianProduct(Class...)
enumClasses
- the enum classes from which to get their valuesjava.lang.IllegalArgumentException
- in case not all clases are enumspublic static java.lang.Iterable<Position> cartesianProduct(java.util.Set<java.lang.Class<? extends java.lang.Enum<?>>> enumClasses)
enumClasses
- the enums whose values will be used to create the positionspublic static java.lang.Iterable<Position> cartesianEnumProduct(java.util.Set<java.lang.Class<?>> classes)
cartesianProduct(Set)
classes
- the enum classes from which to get their valuesjava.lang.IllegalArgumentException
- in case not all clases are enumspublic static final Position difference(Position left, Position right)
left
- the position from which the coordinates of the right position shall be substractedright
- the position whose coordinates shall be substracted from the left position