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 static org.apache.juneau.commons.utils.Shorts.*; 020 021import org.apache.juneau.commons.bean.*; 022import org.apache.juneau.marshall.*; 023 024/** 025 * Metadata on beans specific to the RDF serializers and parsers pulled from the {@link Rdf @Rdf} annotation on the 026 * class. 027 * 028 * <h5 class='section'>See Also:</h5><ul> 029 * <li class='link'>{doc jmr.RdfDetails} 030 031 * </ul> 032 */ 033public class RdfBeanMeta extends ExtendedBeanMeta { 034 035 // RDF related fields 036 private final BeanPropertyMeta beanUriProperty; // Bean property that identifies the URI of the bean. 037 038 /** 039 * Constructor. 040 * 041 * @param beanMeta The metadata on the bean that this metadata applies to. 042 * Must not be <jk>null</jk>. 043 * @param mp RDF metadata provider (for finding information about other artifacts). 044 * Must not be <jk>null</jk>. 045 */ 046 public RdfBeanMeta(BeanMeta<?> beanMeta, RdfMetaProvider mp) { 047 super(beanMeta); 048 this.beanUriProperty = beanMeta.getProperties().values().stream().filter(x -> mp.getRdfBeanPropertyMeta(x).isBeanUri()).findFirst().orElse(null); 049 } 050 051 /** 052 * Returns the bean property marked as the URI for the bean (annotated with {@link Rdf#beanUri() @Rdf(beanUri)} as <jk>true</jk>). 053 * 054 * @return The URI property, or <jk>null</jk> if no URI property exists on this bean. 055 */ 056 public BeanPropertyMeta getBeanUriProperty() { return beanUriProperty; } 057 058 /** 059 * Returns <jk>true</jk> if one of the properties on this bean is annotated with {@link Rdf#beanUri() @Rdf(beanUri)} as 060 * <jk>true</jk> 061 * 062 * @return <jk>true</jk> if there is a URI property associated with this bean. 063 */ 064 public boolean hasBeanUri() { 065 return nn(beanUriProperty); 066 } 067}