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.urlencoding; 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 UrlEncoding @UrlEncoding} annotation. 027 * 028 * <h5 class='section'>See Also:</h5><ul> 029 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/UrlEncodingSupport">URL-Encoding</a> 030 * </ul> 031 */ 032public class UrlEncodingAnnotation { 033 034 /** 035 * Prevents instantiation. 036 */ 037 private UrlEncodingAnnotation() {} 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 private boolean expandedParams; 049 050 /** 051 * Constructor. 052 */ 053 protected Builder() { 054 super(UrlEncoding.class); 055 } 056 057 /** 058 * Instantiates a new {@link UrlEncoding @UrlEncoding} object initialized with this builder. 059 * 060 * @return A new {@link UrlEncoding @UrlEncoding} object. 061 */ 062 public UrlEncoding build() { 063 return new Object(this); 064 } 065 066 /** 067 * Sets the description property on this annotation. 068 * 069 * @param value The new value for this property. 070 * @return This object. 071 */ 072 public Builder description(String...value) { 073 description = value; 074 return this; 075 } 076 077 /** 078 * Sets the {@link UrlEncoding#expandedParams} property on this annotation. 079 * 080 * @param value The new value for this property. 081 * @return This object. 082 */ 083 public Builder expandedParams(boolean value) { 084 expandedParams = value; 085 return this; 086 } 087 088 } 089 090 @SuppressWarnings({ 091 "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods 092 }) 093 private static class Object extends AnnotationObject implements UrlEncoding { 094 095 private final String[] description; 096 private final boolean expandedParams; 097 098 Object(UrlEncodingAnnotation.Builder b) { 099 super(b); 100 description = cp(b.description); 101 expandedParams = b.expandedParams; 102 } 103 104 @Override /* Overridden from UrlEncoding */ 105 public boolean expandedParams() { 106 return expandedParams; 107 } 108 109 @Override /* Overridden from annotation */ 110 public String[] description() { 111 return description; 112 } 113 } 114 115 /** Default value */ 116 public static final UrlEncoding DEFAULT = create().build(); 117 118 /** 119 * Instantiates a new builder for this class. 120 * 121 * @return A new builder object. 122 */ 123 public static Builder create() { 124 return new Builder(); 125 } 126}