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

com.antwerkz.critter.CritterContext Maven / Gradle / Ivy

There is a newer version: 3.0.5
Show newest version
package com.antwerkz.critter;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import static java.lang.String.format;
import org.jboss.forge.roaster.model.source.JavaClassSource;

public class CritterContext {
  private Map classes = new HashMap<>();

  private String criteriaPkg;

  public CritterContext(final String criteriaPkg) {

    this.criteriaPkg = criteriaPkg;
  }

  public void add(CritterClass critterClass) {
    classes.put(format("%s.%s", critterClass.getPackage(), critterClass.getName()), critterClass);
    critterClass.setPackage(criteriaPkg);
  }

  public CritterClass get(String name) {
    return classes.get(name);
  }

  public Collection getClasses() {
    return classes.values();
  }

  public boolean isEmbedded(final JavaClassSource clazz) {
    final CritterClass critterClass = get(clazz.getName());
    return critterClass != null && critterClass.isEmbedded();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy