1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.maven.internal.impl;
20
21 import java.util.Optional;
22 import org.apache.maven.api.Event;
23 import org.apache.maven.api.EventType;
24 import org.apache.maven.api.MojoExecution;
25 import org.apache.maven.api.Project;
26 import org.apache.maven.api.Session;
27 import org.apache.maven.execution.ExecutionEvent;
28
29 public class DefaultEvent implements Event {
30 private final AbstractSession session;
31 private final ExecutionEvent delegate;
32
33 public DefaultEvent(AbstractSession session, ExecutionEvent delegate) {
34 this.session = session;
35 this.delegate = delegate;
36 }
37
38 @Override
39 public EventType getType() {
40 return EventType.valueOf(delegate.getType().name());
41 }
42
43 @Override
44 public Session getSession() {
45 return session;
46 }
47
48 @Override
49 public Optional<Project> getProject() {
50 return Optional.ofNullable(delegate.getProject()).map(session::getProject);
51 }
52
53 @Override
54 public Optional<MojoExecution> getMojoExecution() {
55 return Optional.ofNullable(delegate.getMojoExecution()).map(DefaultMojoExecution::new);
56 }
57
58 @Override
59 public Optional<Exception> getException() {
60 return Optional.empty();
61 }
62 }