001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2016 ForgeRock AS. 015 */ 016 017package org.forgerock.api.models; 018 019import com.fasterxml.jackson.databind.annotation.JsonDeserialize; 020 021/** 022 * Class that represents the Create Operation type in API descriptor. 023 * 024 */ 025@JsonDeserialize(builder = Update.Builder.class) 026public final class Update extends Operation { 027 028 /** 029 * Protected contstructor of the Operation. 030 * 031 * @param builder Operation Builder 032 */ 033 private Update(Builder builder) { 034 super(builder); 035 } 036 037 /** 038 * Creates a new builder for Operation. 039 * @return New builder instance 040 */ 041 public static final Builder update() { 042 return new Builder(); 043 } 044 045 /** 046 * Allocates the Update operation type to the given Resource Builder. 047 * @param resourceBuilder - Resource Builder to add the operation 048 */ 049 @Override 050 protected void allocateToResource(Resource.Builder resourceBuilder) { 051 resourceBuilder.update(this); 052 } 053 054 /** 055 * Builds an Update object from the data stored in the annotation. 056 * @param update Update annotation that stores the data 057 * @param descriptor The root descriptor to add definitions to. 058 * @param relativeType The type relative to which schema resources should be resolved. 059 * @return Update instance 060 */ 061 public static Update fromAnnotation(org.forgerock.api.annotations.Update update, ApiDescription descriptor, 062 Class<?> relativeType) { 063 return update() 064 .detailsFromAnnotation(update.operationDescription(), descriptor, relativeType) 065 .build(); 066 } 067 068 /** 069 * Builder to help construct Update. 070 */ 071 public static final class Builder extends Operation.Builder<Builder> { 072 073 private Builder() { 074 super(); 075 } 076 077 @Override 078 protected Builder self() { 079 return this; 080 } 081 082 /** 083 * Builds the Create instance. 084 * 085 * @return Create instance 086 */ 087 public Update build() { 088 return new Update(this); 089 } 090 } 091 092}