
com.google.code.siren4j.annotations.Siren4JAction Maven / Gradle / Ivy
/*******************************************************************************************
* The MIT License (MIT)
*
* Copyright (c) 2013 Erik R Serating
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
* persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
* WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*********************************************************************************************/
package com.google.code.siren4j.annotations;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import com.google.code.siren4j.component.impl.ActionImpl.Method;
/**
* Annotation that defines an action to be added to the entity.
*
* *
*
* @Siren4JAction(
* name = "addReview",
* title = "Add a Review",
* method = Method.POST,
* href = "/courseReviews/course/{courseid}",
* type = "application/json",
* fields = {
* @Siren4JActionField(name = "userid", type = "text", required = true ),
* @Siren4JActionField(name = "body", type = "text", required = true, maxLength = 250)
* }
* condition = @Siren4JCondition(name = "somefield", logic=Is.TRUE)
* )
*
*
*
*
*
*
*
*
*
*
*
*
*
*
* Property Required Description name yes Unique name for the action. href yes URI of the action. method no Method for the action {@link Method}, defaults to Method.GET actionClass no Array of string to classify the action. title no Display title for the action. fields no One or more {@link Siren4JActionField} annotation condition no A condition must evaluate to true
for the action to be rendered.
*
* This annotation is used within a {@link Siren4JEntity} or {@link Siren4JSubEntity}. *
*
*
*
*
*/
@Target({ ElementType.ANNOTATION_TYPE })
@Retention(RetentionPolicy.RUNTIME)
@com.google.code.siren4j.annotations.Siren4JAnnotation
public @interface Siren4JAction {
String name();
String[] actionClass() default {};
Method method() default Method.GET;
String href();
String title() default "";
String type() default "";
Siren4JActionField[] fields() default {};
Siren4JCondition condition() default @Siren4JCondition(name="null");
}