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.bson;
018
019import static org.apache.juneau.commons.utils.Shorts.*;
020
021import org.apache.juneau.commons.*;
022
023/**
024 * Utility classes and methods for the {@link Bson @Bson} annotation.
025 *
026 * <h5 class='section'>See Also:</h5><ul>
027 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/Bson">BSON</a>
028 * </ul>
029 */
030public class BsonAnnotation {
031
032   /**
033    * Prevents instantiation.
034    */
035   private BsonAnnotation() {}
036
037   /**
038    * Builder class.
039    */
040   public static class Builder extends AnnotationObject.Builder {
041
042      private String[] description = {};
043
044      /**
045       * Constructor.
046       */
047      protected Builder() {
048         super(Bson.class);
049      }
050
051      /**
052       * Instantiates a new {@link Bson @Bson} object initialized with this builder.
053       *
054       * @return A new {@link Bson @Bson} object.
055       */
056      public Bson build() {
057         return new BsonAnnotation.Object(this);
058      }
059
060      /**
061       * Sets the description property.
062       *
063       * @param value The new value.
064       * @return This object.
065       */
066      public Builder description(String...value) {
067         description = value;
068         return this;
069      }
070   }
071
072   @SuppressWarnings({
073      "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods
074   })
075   private static class Object extends AnnotationObject implements Bson {
076
077      private final String[] description;
078
079      Object(BsonAnnotation.Builder b) {
080         super(b);
081         description = cp(b.description);
082      }
083
084      @Override /* Bson */
085      public String[] description() {
086         return description;
087      }
088   }
089
090   /** Default value */
091   public static final Bson DEFAULT = create().build();
092
093   /**
094    * Instantiates a new builder for this class.
095    *
096    * @return A new builder object.
097    */
098   public static BsonAnnotation.Builder create() {
099      return new BsonAnnotation.Builder();
100   }
101}