Package com.vercer.engine.persist.util

Source Code of com.vercer.engine.persist.util.PropertyMapToSet

/**
*
*/
package com.vercer.engine.persist.util;

import java.util.AbstractSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;

import com.vercer.engine.persist.Path;
import com.vercer.engine.persist.Property;

public final class PropertyMapToSet extends AbstractSet<Property>
{
  private final Map<String, Object> properties;
  private final boolean indexed;

  public PropertyMapToSet(Map<String, Object> properties, boolean indexed)
  {
    this.properties = properties;
    this.indexed = indexed;
  }

  @Override
  public Iterator<Property> iterator()
  {
    final Iterator<Entry<String, Object>> iterator = properties.entrySet().iterator();
    return new Iterator<Property>()
    {
      public boolean hasNext()
      {
        return iterator.hasNext();
      }

      public Property next()
      {
        Entry<String, Object> next = iterator.next();
        return new SimpleProperty(new Path(next.getKey()), next.getValue(), indexed);
      }

      public void remove()
      {
        iterator.remove();
      }
    };
  }

  @Override
  public int size()
  {
    return properties.size();
  }
}
TOP

Related Classes of com.vercer.engine.persist.util.PropertyMapToSet

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.