Skip to content

Commit fbff1f6

Browse files
committed
Add annotations for use in algorithm development to deal with unparsed JSON
1 parent 2834af8 commit fbff1f6

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.algorithmia.algo;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* For algorithm development, labels an apply method indicating it
10+
* should be passed in the raw/unparsed JSON input from the user. If the user did not call
11+
* the algorithm with a JSON content-type, this apply method will not be called.
12+
* <b>Note: You can only have a single apply method if you use @AcceptsJson</b>
13+
*/
14+
@Retention(RetentionPolicy.RUNTIME)
15+
@Target(ElementType.METHOD)
16+
public @interface AcceptsJson {}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.algorithmia.algo;
2+
3+
import java.lang.annotation.ElementType;
4+
import java.lang.annotation.Retention;
5+
import java.lang.annotation.RetentionPolicy;
6+
import java.lang.annotation.Target;
7+
8+
/**
9+
* For algorithm development, indicates that a java method is returning a JSON-serialized String.
10+
* This will result in the API server returning a Content-Type of JSON. If the String returned is
11+
* not valid JSON, then the call will result in a JSON parsing exception.
12+
*/
13+
@Retention(RetentionPolicy.RUNTIME)
14+
@Target(ElementType.METHOD)
15+
public @interface ReturnsJson {}

0 commit comments

Comments
 (0)