
it.tidalwave.metadata.persistence.MetadataPropertySet Maven / Gradle / Ivy
The newest version!
/***********************************************************************************************************************
*
* blueMarine Metadata - open source media workflow
* Copyright (C) 2007-2011 by Tidalwave s.a.s. (http://www.tidalwave.it)
*
***********************************************************************************************************************
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
***********************************************************************************************************************
*
* WWW: http://bluemarine.tidalwave.it
* SCM: https://kenai.com/hg/bluemarine~metadata-src
*
**********************************************************************************************************************/
package it.tidalwave.metadata.persistence;
import javax.annotation.CheckForNull;
import javax.annotation.Nonnull;
import java.util.NoSuchElementException;
/*******************************************************************************
*
* This class represents a set of related metadata properties (for instance,
* all the EXIF or IPTC properties of a photo). Each
* MetadataPropertySet
logically matches a Java {@link Class} which
* provides the classes.
*
* @author Fabrizio Giudici
* @version $Id$
*
******************************************************************************/
public class MetadataPropertySet extends MetadataComposite
{
/***************************************************************************
*
* Creates a new property set given a model class.
*
* @param itemClass the class
*
**************************************************************************/
public MetadataPropertySet (@Nonnull final Class itemClass)
{
super(itemClass);
}
/***************************************************************************
*
*
**************************************************************************/
@CheckForNull
public String getName()
{
return propertyName;
}
/***************************************************************************
*
* Finds a {@link MetadataProperty} given its name.
*
* @param propertyName the property name
* @return the property
* @throws NoSuchElementException if nothing is found
*
**************************************************************************/
@Nonnull
public MetadataProperty findMetadataProperty (@Nonnull final String propertyName)
throws NoSuchElementException
{
for (final MetadataProperty property : getChildProperties())
{
if (propertyName.equals(property.getPropertyName()))
{
return property;
}
}
throw new NoSuchElementException(propertyName);
}
/***************************************************************************
*
*
**************************************************************************/
@Override
@Nonnull
public final String toString()
{
return String.format("MetadataPropertySet[%s]", itemClass.getSimpleName());
}
}