001// ***************************************************************************************************************************
002// * Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements.  See the NOTICE file *
003// * distributed with this work for additional information regarding copyright ownership.  The ASF licenses this file        *
004// * to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance            *
005// * with the License.  You may obtain a copy of the License at                                                              *
006// *                                                                                                                         *
007// *  http://www.apache.org/licenses/LICENSE-2.0                                                                             *
008// *                                                                                                                         *
009// * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an  *
010// * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the License for the        *
011// * specific language governing permissions and limitations under the License.                                              *
012// ***************************************************************************************************************************
013package org.apache.juneau.jena.annotation;
014
015import java.lang.annotation.*;
016import java.lang.reflect.*;
017
018import org.apache.juneau.*;
019import org.apache.juneau.jena.*;
020import org.apache.juneau.reflect.*;
021
022/**
023 * A concrete implementation of the {@link Rdf} annotation.
024 *
025 * <ul class='seealso'>
026 *    <li class='jm'>{@link BeanContextBuilder#annotations(Annotation...)}
027 * </ul>
028 */
029public class RdfAnnotation implements Rdf {
030
031   private String
032      on = "",
033      namespace = "",
034      prefix = "";
035   private boolean
036      beanUri = false;
037   private RdfCollectionFormat
038      collectionFormat = RdfCollectionFormat.DEFAULT;
039
040   /**
041    * Constructor.
042    *
043    * @param on The initial value for the <c>on</c> property.
044    *    <br>See {@link Rdf#on()}
045    */
046   public RdfAnnotation(String on) {
047      on(on);
048   }
049
050   /**
051    * Constructor.
052    *
053    * @param on The initial value for the <c>on</c> property.
054    *    <br>See {@link Rdf#on()}
055    */
056   public RdfAnnotation(Class<?> on) {
057      on(on);
058   }
059
060   /**
061    * Constructor.
062    *
063    * @param on The initial value for the <c>on</c> property.
064    *    <br>See {@link Rdf#on()}
065    */
066   public RdfAnnotation(Method on) {
067      on(on);
068   }
069
070   /**
071    * Constructor.
072    *
073    * @param on The initial value for the <c>on</c> property.
074    *    <br>See {@link Rdf#on()}
075    */
076   public RdfAnnotation(Field on) {
077      on(on);
078   }
079
080   @Override
081   public Class<? extends Annotation> annotationType() {
082      return Rdf.class;
083   }
084
085   @Override
086   public boolean beanUri() {
087      return beanUri;
088   }
089
090   /**
091    * Sets the <c>beanUri</c> property on this annotation.
092    *
093    * @param value The new value for this property.
094    * @return This object (for method chaining).
095    */
096   public RdfAnnotation beanUri(boolean value) {
097      this.beanUri = value;
098      return this;
099   }
100
101   @Override
102   public RdfCollectionFormat collectionFormat() {
103      return collectionFormat;
104   }
105
106   /**
107    * Sets the <c>collectionFormat</c> property on this annotation.
108    *
109    * @param value The new value for this property.
110    * @return This object (for method chaining).
111    */
112   public RdfAnnotation collectionFormat(RdfCollectionFormat value) {
113      this.collectionFormat = value;
114      return this;
115   }
116
117   @Override
118   public String namespace() {
119      return namespace;
120   }
121
122   /**
123    * Sets the <c>namespace</c> property on this annotation.
124    *
125    * @param value The new value for this property.
126    * @return This object (for method chaining).
127    */
128   public RdfAnnotation namespace(String value) {
129      this.namespace = value;
130      return this;
131   }
132
133   @Override
134   public String on() {
135      return on;
136   }
137
138   /**
139    * Sets the <c>on</c> property on this annotation.
140    *
141    * @param value The new value for this property.
142    * @return This object (for method chaining).
143    */
144   public RdfAnnotation on(String value) {
145      this.on = value;
146      return this;
147   }
148
149
150   /**
151    * Sets the <c>on</c> property on this annotation.
152    *
153    * @param value The new value for this property.
154    * @return This object (for method chaining).
155    */
156   public RdfAnnotation on(Class<?> value) {
157      this.on = value.getName();
158      return this;
159   }
160
161   /**
162    * Sets the <c>on</c> property on this annotation.
163    *
164    * @param value The new value for this property.
165    * @return This object (for method chaining).
166    */
167   public RdfAnnotation on(Method value) {
168      this.on = MethodInfo.of(value).getFullName();
169      return this;
170   }
171
172   /**
173    * Sets the <c>on</c> property on this annotation.
174    *
175    * @param value The new value for this property.
176    * @return This object (for method chaining).
177    */
178   public RdfAnnotation on(Field value) {
179      this.on = value.getName();
180      return this;
181   }
182
183   @Override
184   public String prefix() {
185      return prefix;
186   }
187
188   /**
189    * Sets the <c>prefix</c> property on this annotation.
190    *
191    * @param value The new value for this property.
192    * @return This object (for method chaining).
193    */
194   public RdfAnnotation prefix(String value) {
195      this.prefix = value;
196      return this;
197   }
198}