Package org.tensorics.core.tensor
Class Coordinates
- java.lang.Object
-
- org.tensorics.core.tensor.Coordinates
-
public final class Coordinates extends java.lang.Object
Utility methods to handle coordinates
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static void
checkClassesRelations(java.lang.Iterable<java.lang.Class<?>> coordinates)
Validates dependence between given classes (interfaces) such that two interfaces in the same inheritance line are not given.static void
checkClassRelations(java.lang.Class<?> classToCheck, java.lang.Iterable<java.lang.Class<?>> dimensions)
Validates dependence between given class (interface) such that ANY o the given coordinates is assignable from it.static java.lang.String
dimensionsWithoutClassPath(java.util.Set<java.lang.Class<?>> dimensionSet)
Provides the way to reduce long classpath names of the coordinates classes to only short Class names.static java.lang.String
dimensionsWithoutClassPath(Position position)
Provides the way to reduce long classpath names of the coordinates classes to only short Class names.static java.lang.String
dimensionsWithoutClassPath(Tensor<?> tensor)
Provides the way to reduce long classpath names of the coordinates classes to only short Class names.static <C> C
firstCoordinateOfTyp(java.util.Set<?> coordinates, java.lang.Class<C> dimension)
Extracts from a set of coordinates, the coordinate which corresponds to the given dimension.static java.util.Set<java.lang.Class<?>>
getDimensionsFrom(java.util.Set<?> coordinates)
Utility method that extract the final classes of the given coordinates instances.static void
initialCheckForClassRelations(java.lang.Class<?> classToCheck, java.lang.Iterable<java.lang.Class<?>> coordinates)
Validates dependence between given class (interface) such that NONE of the classes can be assignable from it.static <C> com.google.common.collect.ClassToInstanceMap<C>
mapOf(java.lang.Iterable<? extends C> coordinates)
Deprecated.static <C> java.lang.Class<? super C>
mapToAnEntry(java.lang.Class<C> classToCheck, java.lang.Iterable<java.lang.Class<?>> dimensions)
static java.util.Set<java.lang.Class<?>>
parentClassDifference(java.util.Set<java.lang.Class<?>> originalDimensions, java.util.Set<? extends java.lang.Class<?>> dimensionsToStrip)
Returns the difference of two sets of coordinates, by removing the dimensionToStrip set from the originalDimensions.static java.util.Set<java.lang.Class<?>>
parentClassIntersection(java.util.Set<java.lang.Class<?>> left, java.util.Set<java.lang.Class<?>> right)
Finds the intersection of the two dimension sets, taking correctly into account the class hierarchy of the set dimensions.static java.util.Set<?>
requireValidCoordinates(java.lang.Iterable<?> coordinates)
static java.util.Set<java.lang.Class<?>>
requireValidDimensions(com.google.common.collect.Multiset<java.lang.Class<?>> dimensions)
-
-
-
Method Detail
-
mapOf
@Deprecated public static <C> com.google.common.collect.ClassToInstanceMap<C> mapOf(java.lang.Iterable<? extends C> coordinates)
Deprecated.Creates a class to instance map, from the given coordinates. The map will contain the classes of the coordinates as keys and the coordinates themselves as values. Duplicate keys (dimensions) are not allowed and will result in anIllegalArgumentException
.- Parameters:
coordinates
- the coordinates to be added to the map- Returns:
- an immutable map from dimensions (coordinate classes) to coordinate
- Throws:
java.lang.IllegalArgumentException
- if more than one coordinate per dimension are provided
-
checkClassesRelations
public static void checkClassesRelations(java.lang.Iterable<java.lang.Class<?>> coordinates)
Validates dependence between given classes (interfaces) such that two interfaces in the same inheritance line are not given.- Parameters:
coordinates
-- Throws:
java.lang.IllegalArgumentException
- when any of the given classes are linked by the inheritance line.
-
initialCheckForClassRelations
public static void initialCheckForClassRelations(java.lang.Class<?> classToCheck, java.lang.Iterable<java.lang.Class<?>> coordinates)
Validates dependence between given class (interface) such that NONE of the classes can be assignable from it.- Parameters:
classToCheck
- a class to verifycoordinates
- available coordinates classes- Throws:
java.lang.IllegalArgumentException
- when any of the given classes are linked by the inheritance line.
-
checkClassRelations
public static void checkClassRelations(java.lang.Class<?> classToCheck, java.lang.Iterable<java.lang.Class<?>> dimensions)
Validates dependence between given class (interface) such that ANY o the given coordinates is assignable from it.- Parameters:
classToCheck
- a class to verifydimensions
- available coordinates classes- Throws:
java.lang.IllegalArgumentException
- when any of the given classes are linked by the inheritance line.
-
mapToAnEntry
public static <C> java.lang.Class<? super C> mapToAnEntry(java.lang.Class<C> classToCheck, java.lang.Iterable<java.lang.Class<?>> dimensions)
-
parentClassIntersection
public static java.util.Set<java.lang.Class<?>> parentClassIntersection(java.util.Set<java.lang.Class<?>> left, java.util.Set<java.lang.Class<?>> right)
Finds the intersection of the two dimension sets, taking correctly into account the class hierarchy of the set dimensions.example: If class A inherits from class B and one set contains A and the other B, then B will be returned.
- Parameters:
left
- one set of dimensionsright
- the other set of dimensions- Returns:
- the intersection of the two sets, considering the class hierarchy
- Throws:
java.lang.IllegalArgumentException
- if a combination of elements of the two sets would result in duplicated entries (e.g. the sets are not disjunct in hierarchy)
-
dimensionsWithoutClassPath
public static java.lang.String dimensionsWithoutClassPath(Tensor<?> tensor)
Provides the way to reduce long classpath names of the coordinates classes to only short Class names. It produces a combination of the tensor and it's context result.- Parameters:
tensor
- to extract the dimension set and reduce their length of the output string- Returns:
- a reduced string
-
dimensionsWithoutClassPath
public static java.lang.String dimensionsWithoutClassPath(Position position)
Provides the way to reduce long classpath names of the coordinates classes to only short Class names.- Parameters:
position
- to extract the dimension set and reduce their ength of the output string- Returns:
- a reduced string
-
dimensionsWithoutClassPath
public static java.lang.String dimensionsWithoutClassPath(java.util.Set<java.lang.Class<?>> dimensionSet)
Provides the way to reduce long classpath names of the coordinates classes to only short Class names.- Parameters:
dimensionSet
- to reduce length of the output string- Returns:
- a reduced string
-
requireValidCoordinates
public static java.util.Set<?> requireValidCoordinates(java.lang.Iterable<?> coordinates)
-
requireValidDimensions
public static java.util.Set<java.lang.Class<?>> requireValidDimensions(com.google.common.collect.Multiset<java.lang.Class<?>> dimensions)
-
firstCoordinateOfTyp
public static <C> C firstCoordinateOfTyp(java.util.Set<?> coordinates, java.lang.Class<C> dimension)
Extracts from a set of coordinates, the coordinate which corresponds to the given dimension. Hereby 'corresponding' means that the cooridnate is an instance of the given dimension (class).- Parameters:
coordinates
- the set of coordinates from which to extract the coordinatedimension
- the dimension for which to find the coordinate.- Returns:
- the (first) coordinate which is an instance of the given dimension or
null
if none is contained in the set.
-
getDimensionsFrom
public static java.util.Set<java.lang.Class<?>> getDimensionsFrom(java.util.Set<?> coordinates)
Utility method that extract the final classes of the given coordinates instances.- Parameters:
coordinates
- to scan- Returns:
- classes of the coordinates
-
parentClassDifference
public static java.util.Set<java.lang.Class<?>> parentClassDifference(java.util.Set<java.lang.Class<?>> originalDimensions, java.util.Set<? extends java.lang.Class<?>> dimensionsToStrip)
Returns the difference of two sets of coordinates, by removing the dimensionToStrip set from the originalDimensions. This method correctly considers the class hierarchy: subclasses of the classes specified in dimensionsToStrip are also removed from originalDimensions.- Parameters:
originalDimensions
- the original set of dimensionsdimensionsToStrip
- the dimensions to remove- Returns:
- the original dimension set minus the dimensions to strip
-
-