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.jena; 018 019import java.lang.annotation.*; 020 021import org.apache.juneau.commons.*; 022 023/** 024 * Utility classes and methods for the {@link Rdf @Rdf} annotation. 025 * 026 * <h5 class='section'>See Also:</h5><ul> 027 * <li class='link'>{doc jmr.RdfDetails} 028 * </ul> 029 */ 030public class RdfAnnotation { 031 032 private RdfAnnotation() {} 033 034 /** 035 * Builder class. 036 * 037 * <h5 class='section'>See Also:</h5><ul> 038 * <li class='jm'>{@link org.apache.juneau.marshall.MarshallingContext.Builder#annotations(Annotation...)} 039 * </ul> 040 */ 041 public static class Builder extends AnnotationObject.Builder { 042 043 private String namespace = ""; 044 private String prefix = ""; 045 private boolean beanUri; 046 private RdfCollectionFormat collectionFormat = RdfCollectionFormat.DEFAULT; 047 048 /** 049 * Constructor. 050 */ 051 protected Builder() { 052 super(Rdf.class); 053 } 054 055 /** 056 * Sets the {@link Rdf#beanUri} property on this annotation. 057 * 058 * @param value The new value for this property. 059 * @return This object. 060 */ 061 public Builder beanUri(boolean value) { 062 beanUri = value; 063 return this; 064 } 065 066 /** 067 * Instantiates a new {@link Rdf @Rdf} object initialized with this builder. 068 * 069 * @return A new {@link Rdf @Rdf} object. 070 */ 071 public Rdf build() { 072 return new Object(this); 073 } 074 075 /** 076 * Sets the {@link Rdf#collectionFormat} property on this annotation. 077 * 078 * @param value The new value for this property. 079 * @return This object. 080 */ 081 public Builder collectionFormat(RdfCollectionFormat value) { 082 collectionFormat = value; 083 return this; 084 } 085 086 /** 087 * Sets the {@link Rdf#namespace} property on this annotation. 088 * 089 * @param value The new value for this property. 090 * @return This object. 091 */ 092 public Builder namespace(String value) { 093 namespace = value; 094 return this; 095 } 096 097 /** 098 * Sets the {@link Rdf#prefix} property on this annotation. 099 * 100 * @param value The new value for this property. 101 * @return This object. 102 */ 103 public Builder prefix(String value) { 104 prefix = value; 105 return this; 106 } 107 } 108 109 @SuppressWarnings({ 110 "java:S2160" // equals() inherited from AnnotationObject compares all annotation interface methods; subclass fields are accessed via those methods 111 }) 112 private static class Object extends AnnotationObject implements Rdf { 113 114 private final boolean beanUri; 115 private final RdfCollectionFormat collectionFormat; 116 private final String namespace; 117 private final String prefix; 118 119 Object(RdfAnnotation.Builder b) { 120 super(b); 121 beanUri = b.beanUri; 122 collectionFormat = b.collectionFormat; 123 namespace = b.namespace; 124 prefix = b.prefix; 125 } 126 127 @Override /* Overridden from Rdf */ 128 public boolean beanUri() { 129 return beanUri; 130 } 131 132 @Override /* Overridden from Rdf */ 133 public RdfCollectionFormat collectionFormat() { 134 return collectionFormat; 135 } 136 137 @Override /* Overridden from Rdf */ 138 public String namespace() { 139 return namespace; 140 } 141 142 @Override /* Overridden from Rdf */ 143 public String prefix() { 144 return prefix; 145 } 146 } 147 148 /** Default value */ 149 public static final Rdf DEFAULT = create().build(); 150 151 /** 152 * Instantiates a new builder for this class. 153 * 154 * @return A new builder object. 155 */ 156 public static Builder create() { 157 return new Builder(); 158 } 159}