- java.lang.Object
-
- de.carne.test.swt.tester.accessor.Accessor<T>
-
- Type Parameters:
T- the actual object type to access.
- All Implemented Interfaces:
java.util.function.Supplier<T>
- Direct Known Subclasses:
ControlAccessor,ItemAccessor,MenuAccessor
public class Accessor<T> extends java.lang.Object implements java.util.function.Supplier<T>Base class for all kinds of accessor classes.
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(@Nullable java.lang.Object obj)Tget()Gets the object instance wrapped by this accessor.static <T> Tget(@Nullable T object)Convenience function to access an object instance directly.java.util.Optional<T>getOptional()Gets the optional object instance wrapped by this accessor.inthashCode()static <T> Accessor<T>notPresent()Gets the empty accessor.java.lang.StringtoString()
-
-
-
Constructor Detail
-
Accessor
public Accessor(@Nullable T object)
Constructs a new Accessor instance.- Parameters:
object- the object to access.
-
Accessor
public Accessor(java.util.Optional<T> objectHolder)
Constructs a new Accessor instance.- Parameters:
objectHolder- to the optional object to access.
-
-
Method Detail
-
get
public T get()
Gets the object instance wrapped by this accessor.A test failure is signaled if the accessor is empty.
- Specified by:
getin interfacejava.util.function.Supplier<T>- Returns:
- the object instance wrapped by this accessor.
-
getOptional
public java.util.Optional<T> getOptional()
Gets the optional object instance wrapped by this accessor.- Returns:
- the optional object instance wrapped by this accessor.
-
get
public static <T> T get(@Nullable T object)
Convenience function to access an object instance directly.A test failure is signaled if the given object is
null.- Type Parameters:
T- the object type to access.- Parameters:
object- the object instance to access (may benull).- Returns:
- the object instance.
-
notPresent
public static <T> Accessor<T> notPresent()
Gets the empty accessor.- Type Parameters:
T- the actual object type to access.- Returns:
- the empty accessor.
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(@Nullable java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-