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