All Downloads are FREE. Search and download functionalities are using the official Maven repository.

thredds.catalog2.builder.util.MetadataBuilderUtils Maven / Gradle / Ivy

Go to download

The NetCDF-Java Library is a Java interface to NetCDF files, as well as to many other types of scientific data formats.

There is a newer version: 4.3.22
Show newest version
package thredds.catalog2.builder.util;

import thredds.catalog2.builder.MetadataBuilder;
import thredds.catalog2.builder.ThreddsBuilderFactory;

/**
 * Utility methods for copying MetadataBuilders.
 *
 * @author edavis
 * @since 4.0
 */
public class MetadataBuilderUtils
{
  private MetadataBuilderUtils() {}

  public static MetadataBuilder copyIntoNewMetadataBuilder( MetadataBuilder source,
                                                            ThreddsBuilderFactory builderFactory )
  {
    if ( source == null )
      throw new IllegalArgumentException( "Source builder may not be null." );
    if ( builderFactory == null )
      throw new IllegalArgumentException( "Builder factory may not be null.");

    MetadataBuilder result = builderFactory.newMetadataBuilder();
    copyMetadataBuilder( source, result );
    return result;
  }

  public static MetadataBuilder copyMetadataBuilder( MetadataBuilder source,
                                                     MetadataBuilder recipient )
  {
    if ( source == null )
      throw new IllegalArgumentException( "Source builder may not be null.");
    if ( recipient == null )
      throw new IllegalArgumentException( "Recipient builder may not be null.");

    recipient.setContainedContent( source.isContainedContent() );
    if ( source.isContainedContent())
      recipient.setContent( source.getContent() );
    else
    {
      recipient.setTitle( source.getTitle() );
      recipient.setExternalReference( source.getExternalReference() );
    }

    return recipient;
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy