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; 014 015import org.apache.juneau.*; 016import org.apache.juneau.jena.annotation.*; 017 018/** 019 * Metadata on beans specific to the RDF serializers and parsers pulled from the {@link Rdf @Rdf} annotation on the 020 * class. 021 */ 022public class RdfBeanMeta extends ExtendedBeanMeta { 023 024 // RDF related fields 025 private final BeanPropertyMeta beanUriProperty; // Bean property that identifies the URI of the bean. 026 027 /** 028 * Constructor. 029 * 030 * @param beanMeta The metadata on the bean that this metadata applies to. 031 * @param mp RDF metadata provider (for finding information about other artifacts). 032 */ 033 public RdfBeanMeta(BeanMeta<?> beanMeta, RdfMetaProvider mp) { 034 super(beanMeta); 035 036 BeanPropertyMeta t_beanUriProperty = null; 037 for (BeanPropertyMeta p : beanMeta.getPropertyMetas()) { 038 RdfBeanPropertyMeta bpm = mp.getRdfBeanPropertyMeta(p); 039 if (bpm.isBeanUri()) 040 t_beanUriProperty = p; 041 } 042 043 this.beanUriProperty = t_beanUriProperty; 044 } 045 046 /** 047 * Returns <jk>true</jk> if one of the properties on this bean is annotated with {@link Rdf#beanUri() @Rdf(beanUri)} as 048 * <jk>true</jk> 049 * 050 * @return <jk>true</jk> if there is a URI property associated with this bean. 051 */ 052 public boolean hasBeanUri() { 053 return beanUriProperty != null; 054 } 055 056 /** 057 * Returns the bean property marked as the URI for the bean (annotated with {@link Rdf#beanUri() @Rdf(beanUri)} as <jk>true</jk>). 058 * 059 * @return The URI property, or <jk>null</jk> if no URI property exists on this bean. 060 */ 061 public BeanPropertyMeta getBeanUriProperty() { 062 return beanUriProperty; 063 } 064}