Skip to content

Instantly share code, notes, and snippets.

@gregturn
Created August 11, 2017 17:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregturn/1073134bb9a114e23193dab9c6caa1b6 to your computer and use it in GitHub Desktop.
Save gregturn/1073134bb9a114e23193dab9c6caa1b6 to your computer and use it in GitHub Desktop.
public interface Affordance {
/**
* HTTP method this affordance covers. For multiple methods, add multiple {@link Affordance}s.
*
* @return
*/
String getHttpMethod();
/**
* Name for the REST action this {@link Affordance} can take.
*
* @return
*/
String getName();
/**
* Are the properties on this {@link Affordance} required or not? Distinguish between PUT (all required)
* vs. PATCH (none required).
*
* @return
*/
boolean isRequired();
/**
* Collection of the {@link Affordance}'s properties, mapped by {@literal name} and {@link Class}.
* For example, a class Employee { String name, String role } would be mapped as:
* Map(name -> java.lang.String, role -> java.lang.String)
*
* @return
*/
Map<String, Class<?>> getProperties();
/**
* The URI of the {@link Affordance} because certain mediatypes need to list it. Other
* mediatypes need to validate that the URI matches the {@literal self} link.
*
* @return
*/
String getUri();
List<AffordanceModel> getAffordanceModel(MediaType mediaType);
void addAffordanceModels(MediaType mediaType, List<AffordanceModel> affordanceModels);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment