1 /* 2 * The contents of this file are subject to the terms of the Common Development and 3 * Distribution License (the License). You may not use this file except in compliance with the 4 * License. 5 * 6 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 7 * specific language governing permission and limitations under the License. 8 * 9 * When distributing Covered Software, include this CDDL Header Notice in each file and include 10 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 11 * Header, with the fields enclosed by brackets [] replaced by your own identifying 12 * information: "Portions copyright [year] [name of copyright owner]". 13 * 14 * Copyright 2016 ForgeRock AS. 15 */ 16 17 package org.forgerock.api.models; 18 19 import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 20 21 /** 22 * Class that represents the Delete operation type in API descriptor. 23 * 24 */ 25 @JsonDeserialize(builder = Delete.Builder.class) 26 public final class Delete extends Operation { 27 28 /** 29 * Protected contstructor of the Delete. 30 * 31 * @param builder Delete Builder 32 */ 33 private Delete(Builder builder) { 34 super(builder); 35 } 36 37 /** 38 * Creates a new builder for Delete. 39 * @return New builder instance 40 */ 41 public static final Builder delete() { 42 return new Builder(); 43 } 44 45 /** 46 * Allocates the Delete operation type to the given Resource Builder. 47 * @param resourceBuilder - Resource Builder to add the operation 48 */ 49 @Override 50 protected void allocateToResource(Resource.Builder resourceBuilder) { 51 resourceBuilder.delete(this); 52 } 53 54 /** 55 * Builds a Delete object from the data in the Delete annotation. 56 * @param delete Delete annotation where the data stored 57 * @param descriptor The root descriptor to add definitions to. 58 * @param relativeType The type relative to which schema resources should be resolved. 59 * @return Delete instance 60 */ 61 public static Delete fromAnnotation(org.forgerock.api.annotations.Delete delete, ApiDescription descriptor, 62 Class<?> relativeType) { 63 return delete() 64 .detailsFromAnnotation(delete.operationDescription(), descriptor, relativeType) 65 .build(); 66 } 67 68 /** 69 * Builder for the Delete. 70 */ 71 public static final class Builder extends Operation.Builder<Builder> { 72 73 private Builder() { 74 super(); 75 } 76 77 @Override 78 protected Builder self() { 79 return this; 80 } 81 82 /** 83 * Builds the Delete instance. 84 * 85 * @return Delete instance 86 */ 87 public Delete build() { 88 return new Delete(this); 89 } 90 } 91 92 }