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

io.ebeaninternal.server.deploy.ElementHelpSet Maven / Gradle / Ivy

There is a newer version: 15.8.1
Show newest version
package io.ebeaninternal.server.deploy;

import io.ebean.bean.BeanCollection;
import io.ebean.common.BeanSet;

import java.util.LinkedHashSet;
import java.util.Set;

final class ElementHelpSet implements ElementHelp {

  @Override
  public ElementCollector createCollector() {
    return new Collector();
  }

  private static class Collector implements ElementCollector {

    private final Set set = new LinkedHashSet<>();

    @Override
    public void addElement(Object element) {
      set.add(element);
    }

    @Override
    public void addKeyValue(Object key, Object element) {
      throw new IllegalStateException("never called");
    }

    @Override
    public Object collection() {
      BeanSet beanSet = new BeanSet<>(set);
      beanSet.setModifyListening(BeanCollection.ModifyListenMode.ALL);
      return beanSet;
    }
  }
}