- java.lang.Object
-
- org.palladiosimulator.pcm.dataprocessing.prolog.prologmodel.provider.extension.Util
-
public class Util extends Object
-
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <S> Collection<S>
addNull(Collection<S> collection)
static <T> Optional<T>
getContainerOfType(EObject obj, Class<? extends T> type)
static Optional<EObject>
getFeatureBasedContainer(EObject obj, EStructuralFeature containingFeature)
Walks up the containment tree until the given feauter is found.static <S> S
getOrElse(Optional<? extends S> opt, Supplier<? extends S> elseValue)
static <S> Stream<S>
streamOfNullable(Collection<S> nullableCollection)
static <T> Optional<T>
tryCast(Class<T> clazz, Object elem)
-
-
-
Method Detail
-
getOrElse
public static <S> S getOrElse(Optional<? extends S> opt, Supplier<? extends S> elseValue)
-
addNull
public static <S> Collection<S> addNull(Collection<S> collection)
-
streamOfNullable
public static <S> Stream<S> streamOfNullable(Collection<S> nullableCollection)
-
getContainerOfType
public static <T> Optional<T> getContainerOfType(EObject obj, Class<? extends T> type)
-
getFeatureBasedContainer
public static Optional<EObject> getFeatureBasedContainer(EObject obj, EStructuralFeature containingFeature)
Walks up the containment tree until the given feauter is found. If the feature is found, the owner of the feature is returned as container. Otherwise an empty optional is returned.- Parameters:
obj
- the object whose containers shall be traversedcontainingFeature
- the feature type to look for- Returns:
- the foudn container or an empty Optional otherwise
-
-