File tree Expand file tree Collapse file tree
api/src/main/java/org/mapstruct/tools/gem Expand file tree Collapse file tree Original file line number Diff line number Diff line change 88import java .util .ArrayList ;
99import java .util .List ;
1010import java .util .function .Function ;
11+ import java .util .function .Supplier ;
1112import javax .lang .model .element .AnnotationMirror ;
1213import javax .lang .model .element .AnnotationValue ;
1314import javax .lang .model .element .AnnotationValueVisitor ;
@@ -113,6 +114,16 @@ public T getValue() {
113114 return value ;
114115 }
115116
117+ /**
118+ * Returns the value set by the user, if present, otherwise invoke other and return the result of that invocation.
119+ *
120+ * @param other a Supplier whose result is returned if no value is present
121+ * @return the value set by the user, if present, otherwise the result of {@code other.get()}
122+ */
123+ public T getValueOrElseGet (Supplier <T > other ) {
124+ return value != null ? value : other .get ();
125+ }
126+
116127 /**
117128 * The default value, as declared in the annotation
118129 *
You can’t perform that action at this time.
0 commit comments