001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.juneau.marshall.cbor; 018 019import static org.apache.juneau.commons.utils.Shorts.*; 020 021import java.lang.annotation.*; 022 023import org.apache.juneau.commons.*; 024 025/** 026 * Utility classes and methods for the {@link Cbor @Cbor} annotation. 027 * 028 * <h5 class='section'>See Also:</h5><ul> 029 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/Cbor">CBOR</a> 030 * </ul> 031 */ 032public class CborAnnotation { 033 034 /** 035 * Prevents instantiation. 036 */ 037 private CborAnnotation() {} 038 /** 039 * Builder class. 040 * 041 * <h5 class='section'>See Also:</h5><ul> 042 * <li class='jm'>{@link org.apache.juneau.marshall.MarshallingContext.Builder#annotations(Annotation...)} 043 * </ul> 044 */ 045 public static class Builder extends AnnotationObject.Builder { 046 047 private String[] description = {}; 048 049 /** 050 * Constructor. 051 */ 052 protected Builder() { 053 super(Cbor.class); 054 } 055 056 /** 057 * Instantiates a new {@link Cbor @Cbor} object initialized with this builder. 058 * 059 * @return A new {@link Cbor @Cbor} object. 060 */ 061 public Cbor build() { 062 return new Object(this); 063 } 064 065 /** 066 * Sets the description property on this annotation. 067 * 068 * @param value The new value for this property. 069 * @return This object. 070 */ 071 public Builder description(String...value) { 072 description = value; 073 return this; 074 } 075 } 076 077 @SuppressWarnings({ 078 "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods 079 }) 080 private static class Object extends AnnotationObject implements Cbor { 081 082 private final String[] description; 083 084 Object(CborAnnotation.Builder b) { 085 super(b); 086 this.description = cp(b.description); 087 } 088 089 @Override /* Overridden from annotation */ 090 public String[] description() { 091 return description; 092 } 093 } 094 095 /** Default value */ 096 public static final Cbor DEFAULT = create().build(); 097 098 /** 099 * Instantiates a new builder for this class. 100 * 101 * @return A new builder object. 102 */ 103 public static Builder create() { 104 return new Builder(); 105 } 106}