Class PropertyEdge<T extends Node>
- java.lang.Object
-
- de.fraunhofer.aisec.cpg.graph.edge.PropertyEdge<T>
-
- All Implemented Interfaces:
Persistable
public class PropertyEdge<T extends Node> extends java.lang.Object implements Persistable
-
-
Field Summary
Fields Modifier and Type Field Description protected static org.slf4j.Loggerlog
-
Constructor Summary
Constructors Constructor Description PropertyEdge(PropertyEdge<T> propertyEdge)PropertyEdge(Node start, T end)PropertyEdge(Node start, T end, java.util.Map<Properties,java.lang.Object> properties)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProperties(java.util.Map<Properties,java.lang.Object> propertyMap)voidaddProperty(Properties property, java.lang.Object value)Adds a property to aPropertyEdgeIf the object is not a built-in type you must provide a serializer and deserializer in thePropertyEdgeConverterstatic <T extends Node>
java.util.List<PropertyEdge<T>>applyIndexProperty(java.util.List<PropertyEdge<T>> propertyEdges)Add/Update index element of list of PropertyEdgesstatic booleancheckForPropertyEdge(java.lang.reflect.Field f, java.lang.Object obj)Checks if an Object is a PropertyEdge or a collection of PropertyEdgesbooleanequals(java.lang.Object obj)Note that the start and end node cannot be checked for equality here, as it would create an endless loop.static <S extends PropertyEdge<?>>
java.util.List<S>findPropertyEdgesByPredicate(java.util.Collection<S> edges, java.util.function.Predicate<S> predicate)TgetEnd()java.lang.ObjectgetProperty(Properties property)static <T extends Node>
java.util.List<Node>getSource(java.util.List<PropertyEdge<T>> propertyEdges)NodegetStart()static <T extends Node>
java.util.List<T>getTarget(java.util.List<PropertyEdge<T>> propertyEdges)inthashCode()static <T extends Node>
java.util.List<PropertyEdge<T>>removeElementFromList(java.util.List<PropertyEdge<T>> propertyEdges, T element, boolean end)voidsetEnd(T end)voidsetStart(Node start)static <T extends Node>
java.util.List<PropertyEdge<T>>transformIntoIncomingPropertyEdgeList(java.util.List<? extends Node> nodes, T commonRelationshipNode)Transforms a List of Nodes into sources of PropertyEdges.static <T extends Node>
java.util.List<PropertyEdge<T>>transformIntoOutgoingPropertyEdgeList(java.util.List<T> nodes, Node commonRelationshipNode)Transforms a List of Nodes into targets of PropertyEdges.static <T extends Node>
java.util.List<T>unwrap(@NonNull java.util.List<PropertyEdge<T>> collection)Unwraps this outgoing property edge into a list of its target nodes.static <T extends Node>
java.util.List<T>unwrap(@NonNull java.util.List<PropertyEdge<T>> collection, boolean outgoing)Unwraps this property edge into a list of its target nodes.static java.lang.ObjectunwrapPropertyEdge(java.lang.Object obj, boolean outgoing)
-
-
-
Constructor Detail
-
PropertyEdge
public PropertyEdge(PropertyEdge<T> propertyEdge)
-
PropertyEdge
public PropertyEdge(Node start, T end, java.util.Map<Properties,java.lang.Object> properties)
-
-
Method Detail
-
findPropertyEdgesByPredicate
public static <S extends PropertyEdge<?>> java.util.List<S> findPropertyEdgesByPredicate(java.util.Collection<S> edges, java.util.function.Predicate<S> predicate)
-
getProperty
public java.lang.Object getProperty(Properties property)
-
addProperty
public void addProperty(Properties property, java.lang.Object value)
Adds a property to aPropertyEdgeIf the object is not a built-in type you must provide a serializer and deserializer in thePropertyEdgeConverter- Parameters:
property- String containing the name of the propertyvalue- Object containing the value of the property
-
addProperties
public void addProperties(java.util.Map<Properties,java.lang.Object> propertyMap)
-
getEnd
public T getEnd()
-
getStart
public Node getStart()
-
setEnd
public void setEnd(T end)
-
setStart
public void setStart(Node start)
-
applyIndexProperty
public static <T extends Node> java.util.List<PropertyEdge<T>> applyIndexProperty(java.util.List<PropertyEdge<T>> propertyEdges)
Add/Update index element of list of PropertyEdges- Parameters:
propertyEdges- propertyEdge list- Returns:
- new PropertyEdge list with updated index property
-
transformIntoOutgoingPropertyEdgeList
public static <T extends Node> java.util.List<PropertyEdge<T>> transformIntoOutgoingPropertyEdgeList(java.util.List<T> nodes, Node commonRelationshipNode)
Transforms a List of Nodes into targets of PropertyEdges. Include Index Property as Lists are indexed- Parameters:
nodes- List of nodes that should be transformed into PropertyEdgescommonRelationshipNode- node where all the Edges should start- Returns:
- List of PropertyEdges with the targets of the nodes and index property.
-
transformIntoIncomingPropertyEdgeList
public static <T extends Node> java.util.List<PropertyEdge<T>> transformIntoIncomingPropertyEdgeList(java.util.List<? extends Node> nodes, T commonRelationshipNode)
Transforms a List of Nodes into sources of PropertyEdges. Include Index Property as Lists are indexed- Parameters:
nodes- List of nodes that should be transformed into PropertyEdgescommonRelationshipNode- node where all the Edges should end.- Returns:
- List of PropertyEdges with the nodes as sources and index property.
-
unwrap
public static <T extends Node> java.util.List<T> unwrap(@NonNull java.util.List<PropertyEdge<T>> collection)
Unwraps this outgoing property edge into a list of its target nodes.- Type Parameters:
T- the type of the edges- Parameters:
collection- the collection of edges- Returns:
- the list of target nodes
-
unwrap
public static <T extends Node> java.util.List<T> unwrap(@NonNull java.util.List<PropertyEdge<T>> collection, boolean outgoing)
Unwraps this property edge into a list of its target nodes.- Type Parameters:
T- the type of the edges- Parameters:
collection- the collection of edgesoutgoing- whether it is outgoing or not- Returns:
- the list of target nodes
-
unwrapPropertyEdge
public static java.lang.Object unwrapPropertyEdge(java.lang.Object obj, boolean outgoing)- Parameters:
obj- PropertyEdge or collection of property edges that must be unwrappedoutgoing- direction of the edge- Returns:
- node or collection representing target of edge
-
checkForPropertyEdge
public static boolean checkForPropertyEdge(java.lang.reflect.Field f, java.lang.Object obj)Checks if an Object is a PropertyEdge or a collection of PropertyEdges- Parameters:
f- Field containing the objectobj- object that is checked if it is a PropertyEdge- Returns:
- true if obj is/contains a PropertyEdge
-
getTarget
public static <T extends Node> java.util.List<T> getTarget(java.util.List<PropertyEdge<T>> propertyEdges)
- Parameters:
propertyEdges- List of PropertyEdges- Returns:
- List of nodes corresponding to the targets of the edges
-
getSource
public static <T extends Node> java.util.List<Node> getSource(java.util.List<PropertyEdge<T>> propertyEdges)
- Parameters:
propertyEdges- List of PropertyEdges- Returns:
- List of nodes corresponding to the targets of the edges
-
removeElementFromList
public static <T extends Node> java.util.List<PropertyEdge<T>> removeElementFromList(java.util.List<PropertyEdge<T>> propertyEdges, T element, boolean end)
-
equals
public boolean equals(java.lang.Object obj)
Note that the start and end node cannot be checked for equality here, as it would create an endless loop. Check of start and end node must be done separately.- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
-