Skip to content

Commit bfe78cf

Browse files
author
Alexa
committed
Updating typed request handler interfaces
1 parent cd111c6 commit bfe78cf

File tree

3 files changed

+177
-0
lines changed

3 files changed

+177
-0
lines changed
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
5+
* except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://aws.amazon.com/apache2.0/
8+
*
9+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
11+
* the specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package com.amazon.ask.dispatcher.request.handler.impl;
15+
16+
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
17+
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
18+
import com.amazon.ask.model.interfaces.alexa.advertisement.AdCompleted;
19+
import com.amazon.ask.model.Response;
20+
21+
import java.util.Optional;
22+
23+
/**
24+
* Request handler for AdCompleted requests.
25+
*/
26+
public interface AdCompletedHandler extends RequestHandler {
27+
28+
/**
29+
* Returns true if the handler can dispatch the current request
30+
*
31+
* @param input input to the request handler
32+
* @param adCompleted AdCompleted request
33+
* @return true if the handler is capable of handling the current request and/or state
34+
*/
35+
boolean canHandle(HandlerInput input, AdCompleted adCompleted);
36+
37+
/**
38+
* Handles the request.
39+
*
40+
* @param input input to the request handler
41+
* @param adCompleted AdCompleted request
42+
* @return output from the handler.
43+
*/
44+
Optional<Response> handle(HandlerInput input, AdCompleted adCompleted);
45+
46+
@Override
47+
default boolean canHandle(HandlerInput handlerInput) {
48+
if (handlerInput.getRequest() instanceof AdCompleted) {
49+
return canHandle(handlerInput, (AdCompleted)handlerInput.getRequest());
50+
}
51+
return false;
52+
}
53+
54+
@Override
55+
default Optional<Response> handle(HandlerInput handlerInput) {
56+
return handle(handlerInput, (AdCompleted)handlerInput.getRequest());
57+
}
58+
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
5+
* except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://aws.amazon.com/apache2.0/
8+
*
9+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
11+
* the specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package com.amazon.ask.dispatcher.request.handler.impl;
15+
16+
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
17+
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
18+
import com.amazon.ask.model.interfaces.alexa.advertisement.AdNotRendered;
19+
import com.amazon.ask.model.Response;
20+
21+
import java.util.Optional;
22+
23+
/**
24+
* Request handler for AdNotRendered requests.
25+
*/
26+
public interface AdNotRenderedHandler extends RequestHandler {
27+
28+
/**
29+
* Returns true if the handler can dispatch the current request
30+
*
31+
* @param input input to the request handler
32+
* @param adNotRendered AdNotRendered request
33+
* @return true if the handler is capable of handling the current request and/or state
34+
*/
35+
boolean canHandle(HandlerInput input, AdNotRendered adNotRendered);
36+
37+
/**
38+
* Handles the request.
39+
*
40+
* @param input input to the request handler
41+
* @param adNotRendered AdNotRendered request
42+
* @return output from the handler.
43+
*/
44+
Optional<Response> handle(HandlerInput input, AdNotRendered adNotRendered);
45+
46+
@Override
47+
default boolean canHandle(HandlerInput handlerInput) {
48+
if (handlerInput.getRequest() instanceof AdNotRendered) {
49+
return canHandle(handlerInput, (AdNotRendered)handlerInput.getRequest());
50+
}
51+
return false;
52+
}
53+
54+
@Override
55+
default Optional<Response> handle(HandlerInput handlerInput) {
56+
return handle(handlerInput, (AdNotRendered)handlerInput.getRequest());
57+
}
58+
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file
5+
* except in compliance with the License. A copy of the License is located at
6+
*
7+
* http://aws.amazon.com/apache2.0/
8+
*
9+
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS,
10+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for
11+
* the specific language governing permissions and limitations under the License.
12+
*/
13+
14+
package com.amazon.ask.dispatcher.request.handler.impl;
15+
16+
import com.amazon.ask.dispatcher.request.handler.HandlerInput;
17+
import com.amazon.ask.dispatcher.request.handler.RequestHandler;
18+
import com.amazon.ask.model.interfaces.alexa.advertisement.ReadyToEnqueueAudio;
19+
import com.amazon.ask.model.Response;
20+
21+
import java.util.Optional;
22+
23+
/**
24+
* Request handler for ReadyToEnqueueAudio requests.
25+
*/
26+
public interface ReadyToEnqueueAudioHandler extends RequestHandler {
27+
28+
/**
29+
* Returns true if the handler can dispatch the current request
30+
*
31+
* @param input input to the request handler
32+
* @param readyToEnqueueAudio ReadyToEnqueueAudio request
33+
* @return true if the handler is capable of handling the current request and/or state
34+
*/
35+
boolean canHandle(HandlerInput input, ReadyToEnqueueAudio readyToEnqueueAudio);
36+
37+
/**
38+
* Handles the request.
39+
*
40+
* @param input input to the request handler
41+
* @param readyToEnqueueAudio ReadyToEnqueueAudio request
42+
* @return output from the handler.
43+
*/
44+
Optional<Response> handle(HandlerInput input, ReadyToEnqueueAudio readyToEnqueueAudio);
45+
46+
@Override
47+
default boolean canHandle(HandlerInput handlerInput) {
48+
if (handlerInput.getRequest() instanceof ReadyToEnqueueAudio) {
49+
return canHandle(handlerInput, (ReadyToEnqueueAudio)handlerInput.getRequest());
50+
}
51+
return false;
52+
}
53+
54+
@Override
55+
default Optional<Response> handle(HandlerInput handlerInput) {
56+
return handle(handlerInput, (ReadyToEnqueueAudio)handlerInput.getRequest());
57+
}
58+
59+
}

0 commit comments

Comments
 (0)