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 BeanMetaExtended { 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 */ 032 public RdfBeanMeta(BeanMeta<?> beanMeta) { 033 super(beanMeta); 034 035 BeanPropertyMeta t_beanUriProperty = null; 036 for (BeanPropertyMeta p : beanMeta.getPropertyMetas()) { 037 RdfBeanPropertyMeta bpm = p.getExtendedMeta(RdfBeanPropertyMeta.class); 038 if (bpm.isBeanUri()) 039 t_beanUriProperty = p; 040 } 041 042 this.beanUriProperty = t_beanUriProperty; 043 } 044 045 /** 046 * Returns <jk>true</jk> if one of the properties on this bean is annotated with {@link Rdf#beanUri() @Rdf.beanUri()} as 047 * <jk>true</jk> 048 * 049 * @return <jk>true</jk> if there is a URI property associated with this bean. 050 */ 051 public boolean hasBeanUri() { 052 return beanUriProperty != null; 053 } 054 055 /** 056 * Returns the bean property marked as the URI for the bean (annotated with {@link Rdf#beanUri() @Rdf.beanUri()} as <jk>true</jk>). 057 * 058 * @return The URI property, or <jk>null</jk> if no URI property exists on this bean. 059 */ 060 public BeanPropertyMeta getBeanUriProperty() { 061 return beanUriProperty; 062 } 063}