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 * Partial Copyright 2021 Wren Security 16 */ 17 18 package org.forgerock.api.annotations; 19 20 import java.lang.annotation.ElementType; 21 import java.lang.annotation.Retention; 22 import java.lang.annotation.RetentionPolicy; 23 import java.lang.annotation.Target; 24 25 /** 26 * Annotation to define JSON Schema {@code additionalProperties}, which is useful when working with key/value 27 * JSON data structures. 28 * <p> 29 * For example, the following JSON Schema defines a map from string (key) to string (value), 30 * </p> 31 * <pre> 32 * { 33 * "type": "object", 34 * "additionalProperties": { 35 * "type": "string" 36 * } 37 * } 38 * </pre> 39 * Note that keys are always strings in JSON, so the schema does not define that fact. 40 * <p> 41 * The annotation in this example would be used as follows, 42 * </p> 43 * <pre> 44 * @AdditionalProperties(String.class) 45 * private static class MyMap extends HashMap<String, String> {} 46 * </pre> 47 */ 48 @Retention(RetentionPolicy.RUNTIME) 49 @Target({ElementType.TYPE}) 50 public @interface AdditionalProperties { 51 /** 52 * The type to produce the additional-properties schema from. 53 */ 54 Class<?> value() default Void.class; 55 }