Package com.cedarsoft.utils.tags

Source Code of com.cedarsoft.utils.tags.MemoryTagProvider

package com.cedarsoft.utils.tags;

import com.cedarsoft.NotFoundException;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import java.lang.Override;
import java.util.List;

/**
* Holds the tags within a tag set
*/
public class MemoryTagProvider extends AbstractTagProvider {
  @NotNull
  protected final TagSet tags = new TagSet( this );

  @Override
  @NotNull
  public Tag createTag( @NotNull @NonNls String description ) {
    Tag newTag = new Tag( description );
    tags.addTag( newTag );
    return newTag;
  }

  @Override
  public void addTagChangeListener( @NotNull TagChangeListener listener ) {
    tags.addTagChangeListener( listener );
  }

  @Override
  public void removeTagChangeListener( @NotNull TagChangeListener listener ) {
    tags.removeTagChangeListener( listener );
  }

  @Override
  @NotNull
  public List<? extends Tag> getTags() {
    return tags.getTags();
  }

  @Override
  public void removeTag( @NotNull Tag tag ) {
    tags.removeTag( tag );
  }

  @Override
  @NotNull
  public Tag findTag( @NonNls @NotNull String description ) throws NotFoundException {
    for ( Tag tag : tags.getTags() ) {
      if ( tag.getDescription().equals( description ) ) {
        return tag;
      }
    }
    throw new NotFoundException( "No tag found for description <" + description + '>' );
  }
}
TOP

Related Classes of com.cedarsoft.utils.tags.MemoryTagProvider

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.